123 |
12 Jul 06 |
jari |
1 |
/* |
123 |
12 Jul 06 |
jari |
$Id$ |
123 |
12 Jul 06 |
jari |
3 |
|
266 |
07 May 07 |
peter |
Copyright (C) 2007 Peter Johansson |
858 |
02 Dec 08 |
jari |
Copyright (C) 2008 Jari Häkkinen |
123 |
12 Jul 06 |
jari |
6 |
|
858 |
02 Dec 08 |
jari |
This file is part of WeNNI, |
858 |
02 Dec 08 |
jari |
http://baseplugins.thep.lu.se/wiki/se.lu.thep.WeNNI |
123 |
12 Jul 06 |
jari |
9 |
|
858 |
02 Dec 08 |
jari |
WeNNI is free software; you can redistribute it and/or modify it |
858 |
02 Dec 08 |
jari |
under the terms of the GNU General Public License as published by |
824 |
26 Nov 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
123 |
12 Jul 06 |
jari |
(at your option) any later version. |
123 |
12 Jul 06 |
jari |
14 |
|
858 |
02 Dec 08 |
jari |
WeNNI is distributed in the hope that it will be useful, but WITHOUT |
858 |
02 Dec 08 |
jari |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
858 |
02 Dec 08 |
jari |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
858 |
02 Dec 08 |
jari |
License for more details. |
123 |
12 Jul 06 |
jari |
19 |
|
123 |
12 Jul 06 |
jari |
You should have received a copy of the GNU General Public License |
824 |
26 Nov 08 |
jari |
along with WeNNI. If not, see <http://www.gnu.org/licenses/>. |
123 |
12 Jul 06 |
jari |
22 |
*/ |
123 |
12 Jul 06 |
jari |
23 |
|
334 |
12 Jun 07 |
peter |
24 |
package se.lu.thep.wenni; |
123 |
12 Jul 06 |
jari |
25 |
|
844 |
01 Dec 08 |
jari |
26 |
import net.sf.basedb.plugins.AbstractRunBinaryPlugin; |
311 |
28 May 07 |
peter |
27 |
|
863 |
02 Dec 08 |
jari |
28 |
import net.sf.basedb.core.DbControl; // Jari, remove this? |
863 |
02 Dec 08 |
jari |
29 |
import net.sf.basedb.core.Item; |
863 |
02 Dec 08 |
jari |
30 |
import net.sf.basedb.core.Permission; |
123 |
12 Jul 06 |
jari |
31 |
|
123 |
12 Jul 06 |
jari |
32 |
import net.sf.basedb.core.plugin.AboutImpl; |
863 |
02 Dec 08 |
jari |
33 |
import net.sf.basedb.core.plugin.Permissions; |
858 |
02 Dec 08 |
jari |
34 |
import net.sf.basedb.core.plugin.Plugin; |
123 |
12 Jul 06 |
jari |
35 |
|
908 |
08 Dec 08 |
jari |
36 |
import net.sf.basedb.plugins.BioAssaySetExporter; |
908 |
08 Dec 08 |
jari |
37 |
|
908 |
08 Dec 08 |
jari |
38 |
import java.io.File; |
908 |
08 Dec 08 |
jari |
39 |
import java.io.FileOutputStream; |
123 |
12 Jul 06 |
jari |
40 |
import java.io.IOException; |
123 |
12 Jul 06 |
jari |
41 |
|
908 |
08 Dec 08 |
jari |
42 |
import java.sql.SQLException; |
908 |
08 Dec 08 |
jari |
43 |
|
863 |
02 Dec 08 |
jari |
44 |
import java.util.EnumSet; |
123 |
12 Jul 06 |
jari |
45 |
import java.util.List; |
123 |
12 Jul 06 |
jari |
46 |
|
123 |
12 Jul 06 |
jari |
47 |
/** |
867 |
03 Dec 08 |
jari |
WeNNI plug-in. An unreliable expression value of a gene is imputed |
858 |
02 Dec 08 |
jari |
as the average expression in the most similar genes. |
123 |
12 Jul 06 |
jari |
50 |
|
858 |
02 Dec 08 |
jari |
The method is published in "Improving missing value imputation of |
858 |
02 Dec 08 |
jari |
microarray data by using spot quality weights", P. Johansson and |
858 |
02 Dec 08 |
jari |
J. Häkkinen. BMC Bioinformatics 7, 306 (2006) |
123 |
12 Jul 06 |
jari |
54 |
|
858 |
02 Dec 08 |
jari |
@author Jari Häkkinen, Peter Johansson |
287 |
22 May 07 |
jari |
@version MAKESUBSTOFVERSIONNUMBER |
858 |
02 Dec 08 |
jari |
@since BASE 2.9 |
126 |
20 Jul 06 |
jari |
@base.modified $Date$ |
123 |
12 Jul 06 |
jari |
59 |
*/ |
123 |
12 Jul 06 |
jari |
60 |
|
334 |
12 Jun 07 |
peter |
61 |
public class WeNNI |
844 |
01 Dec 08 |
jari |
62 |
extends AbstractRunBinaryPlugin |
123 |
12 Jul 06 |
jari |
63 |
{ |
123 |
12 Jul 06 |
jari |
64 |
|
858 |
02 Dec 08 |
jari |
65 |
public WeNNI() { |
863 |
02 Dec 08 |
jari |
66 |
|
893 |
07 Dec 08 |
jari |
67 |
if (debug_output) System.err.println("Initalizing WeNNI"); |
893 |
07 Dec 08 |
jari |
68 |
|
858 |
02 Dec 08 |
jari |
69 |
about = new AboutImpl |
867 |
03 Dec 08 |
jari |
70 |
( "WeNNI", "An unreliable expression value of a gene is " + |
858 |
02 Dec 08 |
jari |
71 |
"imputed as the average expression in the most similar genes.\n" + |
858 |
02 Dec 08 |
jari |
72 |
"\nThe method is published in \"Improving missing value imputation " + |
858 |
02 Dec 08 |
jari |
73 |
"of microarray data by using spot quality weights\", P. Johansson " + |
858 |
02 Dec 08 |
jari |
74 |
"and J. Häkkinen. BMC Bioinformatics 7, 306 (2006)", |
893 |
07 Dec 08 |
jari |
75 |
"Version: MAKESUBSTOFVERSIONNUMBER", |
858 |
02 Dec 08 |
jari |
76 |
"2008 Jari Häkkinen, Peter Johansson", |
858 |
02 Dec 08 |
jari |
77 |
null, null, |
858 |
02 Dec 08 |
jari |
78 |
"http://baseplugins.thep.lu.se/wiki/se.lu.thep.WeNNI" ); |
863 |
02 Dec 08 |
jari |
79 |
|
863 |
02 Dec 08 |
jari |
80 |
defaultChildName = "WeNNI imputed bioassayset"; |
863 |
02 Dec 08 |
jari |
81 |
|
863 |
02 Dec 08 |
jari |
// Permisssions to request |
863 |
02 Dec 08 |
jari |
83 |
permissions.add(new Permissions(Item.EXPERIMENT, null, |
863 |
02 Dec 08 |
jari |
84 |
EnumSet.of(Permission.USE))); |
863 |
02 Dec 08 |
jari |
85 |
permissions.add(new Permissions(Item.JOB, null, |
863 |
02 Dec 08 |
jari |
86 |
EnumSet.of(Permission.READ))); |
863 |
02 Dec 08 |
jari |
87 |
|
858 |
02 Dec 08 |
jari |
// set the type of the plug-in |
858 |
02 Dec 08 |
jari |
89 |
plugin_maintype=Plugin.MainType.ANALYZE; |
858 |
02 Dec 08 |
jari |
90 |
} |
123 |
12 Jul 06 |
jari |
91 |
|
863 |
02 Dec 08 |
jari |
92 |
/** |
863 |
02 Dec 08 |
jari |
List of background correction methods. |
123 |
12 Jul 06 |
jari |
94 |
|
863 |
02 Dec 08 |
jari |
Note, changing the string in the list will affect the behaviour |
863 |
02 Dec 08 |
jari |
of the plug-in and most certaintly unexpected results will be |
863 |
02 Dec 08 |
jari |
generated. As an example, changing 'Illumina BeadStudio median' |
863 |
02 Dec 08 |
jari |
will break the median method. |
863 |
02 Dec 08 |
jari |
99 |
|
863 |
02 Dec 08 |
jari |
private static final |
863 |
02 Dec 08 |
jari |
PluginParameter<String> methodParameter = new PluginParameter<String> |
863 |
02 Dec 08 |
jari |
( "method", |
863 |
02 Dec 08 |
jari |
"Correction method", |
863 |
02 Dec 08 |
jari |
"These methods are implemented:\n\n" + |
863 |
02 Dec 08 |
jari |
"Illumina BeadStudio inspired mean 'negative control'\n" + |
863 |
02 Dec 08 |
jari |
"Illumina BeadStudio inspired median 'negative control'", |
863 |
02 Dec 08 |
jari |
new StringParameterType(255, "Illumina BeadStudio median", true, 1, 0, 0, |
863 |
02 Dec 08 |
jari |
Arrays.asList( |
863 |
02 Dec 08 |
jari |
new String[] { "Illumina BeadStudio mean" , |
863 |
02 Dec 08 |
jari |
"Illumina BeadStudio median" } |
863 |
02 Dec 08 |
jari |
111 |
) |
863 |
02 Dec 08 |
jari |
112 |
) |
863 |
02 Dec 08 |
jari |
113 |
); |
863 |
02 Dec 08 |
jari |
114 |
*/ |
863 |
02 Dec 08 |
jari |
115 |
|
893 |
07 Dec 08 |
jari |
116 |
protected void runBinary() |
123 |
12 Jul 06 |
jari |
117 |
throws InterruptedException, IOException |
123 |
12 Jul 06 |
jari |
118 |
{ |
908 |
08 Dec 08 |
jari |
119 |
FileOutputStream os = new FileOutputStream(new File(getExecDirectory(), |
908 |
08 Dec 08 |
jari |
120 |
"data.data")); |
908 |
08 Dec 08 |
jari |
121 |
BioAssaySetExporter base=new BioAssaySetExporter(); |
908 |
08 Dec 08 |
jari |
122 |
try |
908 |
08 Dec 08 |
jari |
123 |
{ |
908 |
08 Dec 08 |
jari |
124 |
base.exportPlainMatrix(sourceBAS, os, null); |
908 |
08 Dec 08 |
jari |
125 |
subprocess_stdout="stdout.txt"; |
908 |
08 Dec 08 |
jari |
126 |
String[] cmd = { "nni", "-weight", "data.data" }; |
908 |
08 Dec 08 |
jari |
127 |
execute(cmd); |
908 |
08 Dec 08 |
jari |
128 |
} |
908 |
08 Dec 08 |
jari |
129 |
catch (SQLException e) |
908 |
08 Dec 08 |
jari |
130 |
{ |
908 |
08 Dec 08 |
jari |
131 |
e.printStackTrace(); |
908 |
08 Dec 08 |
jari |
// response.setError(e.getMessage(), Arrays.asList(e)); |
908 |
08 Dec 08 |
jari |
133 |
} |
123 |
12 Jul 06 |
jari |
134 |
} |
123 |
12 Jul 06 |
jari |
135 |
|
123 |
12 Jul 06 |
jari |
136 |
|
893 |
07 Dec 08 |
jari |
137 |
protected void storeResult(DbControl dc, String name) |
123 |
12 Jul 06 |
jari |
138 |
{ |
123 |
12 Jul 06 |
jari |
139 |
} |
123 |
12 Jul 06 |
jari |
140 |
|
123 |
12 Jul 06 |
jari |
141 |
} |