783 |
18 Sep 08 |
jari |
1 |
/* |
783 |
18 Sep 08 |
jari |
$Id$ |
149 |
10 Aug 06 |
enell |
3 |
|
783 |
18 Sep 08 |
jari |
Copyright (C) 2006 Johan Enell |
783 |
18 Sep 08 |
jari |
5 |
|
783 |
18 Sep 08 |
jari |
This file is part of the se.lu.onk.MergeBioAssay plug-in for |
783 |
18 Sep 08 |
jari |
BASE. Available at http://baseplugins.thep.lu.se/ and BASE web |
783 |
18 Sep 08 |
jari |
site is http://base.thep.lu.se |
783 |
18 Sep 08 |
jari |
9 |
|
783 |
18 Sep 08 |
jari |
This is free software; you can redistribute it and/or modify it |
783 |
18 Sep 08 |
jari |
under the terms of the GNU General Public License as published by |
783 |
18 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
783 |
18 Sep 08 |
jari |
(at your option) any later version. |
783 |
18 Sep 08 |
jari |
14 |
|
783 |
18 Sep 08 |
jari |
The software is distributed in the hope that it will be useful, but |
783 |
18 Sep 08 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
783 |
18 Sep 08 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
783 |
18 Sep 08 |
jari |
General Public License for more details. |
783 |
18 Sep 08 |
jari |
19 |
|
783 |
18 Sep 08 |
jari |
You should have received a copy of the GNU General Public License |
783 |
18 Sep 08 |
jari |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
783 |
18 Sep 08 |
jari |
22 |
*/ |
149 |
10 Aug 06 |
enell |
23 |
package mergebioassay; |
149 |
10 Aug 06 |
enell |
24 |
|
149 |
10 Aug 06 |
enell |
25 |
import java.io.IOException; |
149 |
10 Aug 06 |
enell |
26 |
import java.util.List; |
149 |
10 Aug 06 |
enell |
27 |
import java.util.ArrayList; |
149 |
10 Aug 06 |
enell |
28 |
|
149 |
10 Aug 06 |
enell |
29 |
import mergebioassay.mergers.Merge_assay; |
149 |
10 Aug 06 |
enell |
30 |
|
149 |
10 Aug 06 |
enell |
31 |
import basefile.BASEFileException; |
149 |
10 Aug 06 |
enell |
32 |
import basefile.BASEFileReader; |
149 |
10 Aug 06 |
enell |
33 |
import basefile.BASEFileSection; |
149 |
10 Aug 06 |
enell |
34 |
|
149 |
10 Aug 06 |
enell |
35 |
/** |
149 |
10 Aug 06 |
enell |
* A simple utility class to handle the assyas that doesn't fit in any group. It is basically |
149 |
10 Aug 06 |
enell |
* a List with a print method added. |
149 |
10 Aug 06 |
enell |
38 |
* |
149 |
10 Aug 06 |
enell |
* @author Johan Enell |
149 |
10 Aug 06 |
enell |
40 |
*/ |
149 |
10 Aug 06 |
enell |
41 |
public class NoGroup extends ArrayList<Merge_assay> |
149 |
10 Aug 06 |
enell |
42 |
{ |
149 |
10 Aug 06 |
enell |
43 |
|
149 |
10 Aug 06 |
enell |
44 |
/** |
149 |
10 Aug 06 |
enell |
* A method that will print the assays as a "spots" section on System.out. |
149 |
10 Aug 06 |
enell |
46 |
* |
149 |
10 Aug 06 |
enell |
* @param section - the spots section to read |
149 |
10 Aug 06 |
enell |
* @param reader - the baseFile where the data is located |
149 |
10 Aug 06 |
enell |
49 |
*/ |
149 |
10 Aug 06 |
enell |
50 |
public void printNoGroup(BASEFileSection section, BASEFileReader reader) |
149 |
10 Aug 06 |
enell |
51 |
{ |
149 |
10 Aug 06 |
enell |
52 |
int intensity1Pos = -1; |
149 |
10 Aug 06 |
enell |
53 |
int intensity2Pos = -1; |
149 |
10 Aug 06 |
enell |
54 |
int assayDataPos = -1; |
149 |
10 Aug 06 |
enell |
55 |
int positionPos = -1; |
149 |
10 Aug 06 |
enell |
56 |
int reporterPos = -1; |
149 |
10 Aug 06 |
enell |
57 |
|
149 |
10 Aug 06 |
enell |
58 |
int nbrOfColumns = -1; |
149 |
10 Aug 06 |
enell |
59 |
|
149 |
10 Aug 06 |
enell |
60 |
List<String> assayFieldsMap; |
149 |
10 Aug 06 |
enell |
61 |
List<String> assaysMap; |
149 |
10 Aug 06 |
enell |
62 |
List<String> columnsMap; |
149 |
10 Aug 06 |
enell |
63 |
|
149 |
10 Aug 06 |
enell |
64 |
assaysMap = section.findFieldList("assays"); |
149 |
10 Aug 06 |
enell |
65 |
if (assaysMap == null) |
149 |
10 Aug 06 |
enell |
66 |
{ |
149 |
10 Aug 06 |
enell |
67 |
System.err.print("assaysMap row in spots section not found\n"); |
149 |
10 Aug 06 |
enell |
68 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
69 |
} |
149 |
10 Aug 06 |
enell |
70 |
|
149 |
10 Aug 06 |
enell |
71 |
columnsMap = section.findFieldList("columns"); |
149 |
10 Aug 06 |
enell |
72 |
if (columnsMap == null) |
149 |
10 Aug 06 |
enell |
73 |
{ |
149 |
10 Aug 06 |
enell |
74 |
System.err.print("Columns row in spots section not found\n"); |
149 |
10 Aug 06 |
enell |
75 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
76 |
} |
149 |
10 Aug 06 |
enell |
77 |
|
149 |
10 Aug 06 |
enell |
78 |
assayFieldsMap = section.findFieldList("assayFields"); |
149 |
10 Aug 06 |
enell |
79 |
if (assayFieldsMap == null) |
149 |
10 Aug 06 |
enell |
80 |
{ |
149 |
10 Aug 06 |
enell |
81 |
System.err.print("assayFields row in spots section not found\n"); |
149 |
10 Aug 06 |
enell |
82 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
83 |
} |
149 |
10 Aug 06 |
enell |
84 |
nbrOfColumns = (columnsMap.size() - 1) + (assayFieldsMap.size() * assaysMap.size()); |
149 |
10 Aug 06 |
enell |
85 |
|
149 |
10 Aug 06 |
enell |
86 |
positionPos = columnsMap.indexOf("position"); |
149 |
10 Aug 06 |
enell |
87 |
if (positionPos == -1) |
149 |
10 Aug 06 |
enell |
88 |
{ |
149 |
10 Aug 06 |
enell |
89 |
System.err.print("position column in columns row missing\n"); |
149 |
10 Aug 06 |
enell |
90 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
91 |
} |
149 |
10 Aug 06 |
enell |
92 |
|
149 |
10 Aug 06 |
enell |
93 |
reporterPos = columnsMap.indexOf("reporter"); |
149 |
10 Aug 06 |
enell |
94 |
if (reporterPos == -1) |
149 |
10 Aug 06 |
enell |
95 |
{ |
149 |
10 Aug 06 |
enell |
96 |
System.err.print("reporter column in columns row missing\n"); |
149 |
10 Aug 06 |
enell |
97 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
98 |
} |
149 |
10 Aug 06 |
enell |
99 |
|
149 |
10 Aug 06 |
enell |
100 |
intensity1Pos = assayFieldsMap.indexOf("intensity1"); |
149 |
10 Aug 06 |
enell |
101 |
if (intensity1Pos == -1) |
149 |
10 Aug 06 |
enell |
102 |
{ |
149 |
10 Aug 06 |
enell |
103 |
System.err.print("intensity1 field in assayFields row missing\n"); |
149 |
10 Aug 06 |
enell |
104 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
105 |
} |
149 |
10 Aug 06 |
enell |
106 |
|
149 |
10 Aug 06 |
enell |
107 |
intensity2Pos = assayFieldsMap.indexOf("intensity2"); |
149 |
10 Aug 06 |
enell |
108 |
if (intensity2Pos == -1) |
149 |
10 Aug 06 |
enell |
109 |
{ |
149 |
10 Aug 06 |
enell |
110 |
System.err.print("intensity2 field in assayFields row missing\n"); |
149 |
10 Aug 06 |
enell |
111 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
112 |
} |
149 |
10 Aug 06 |
enell |
113 |
|
149 |
10 Aug 06 |
enell |
114 |
assayDataPos = columnsMap.indexOf("assayData"); |
149 |
10 Aug 06 |
enell |
115 |
if (assayDataPos == -1) |
149 |
10 Aug 06 |
enell |
116 |
{ |
149 |
10 Aug 06 |
enell |
117 |
System.err.print("assayData column in columns row missing\n"); |
149 |
10 Aug 06 |
enell |
118 |
System.exit(0); |
149 |
10 Aug 06 |
enell |
119 |
} |
149 |
10 Aug 06 |
enell |
120 |
|
149 |
10 Aug 06 |
enell |
121 |
System.out.println(); |
149 |
10 Aug 06 |
enell |
122 |
System.out.print("section\tspots\n"); |
149 |
10 Aug 06 |
enell |
123 |
System.out.print("columns\tposition\treporter\tassayData\n"); |
149 |
10 Aug 06 |
enell |
124 |
System.out.print("assayFields\tintensity1\tintensity2\tJE_nbrOfElements\n"); |
149 |
10 Aug 06 |
enell |
125 |
System.out.print("setExtraFloats\tJE_nbrOfElements\n"); |
149 |
10 Aug 06 |
enell |
126 |
|
149 |
10 Aug 06 |
enell |
127 |
System.out.print("assays"); |
149 |
10 Aug 06 |
enell |
128 |
for (int i = 0; i < size(); i++) |
149 |
10 Aug 06 |
enell |
129 |
{ |
149 |
10 Aug 06 |
enell |
130 |
BioAssay tmp = get(i); |
149 |
10 Aug 06 |
enell |
131 |
System.out.print("\t" + tmp.id); |
149 |
10 Aug 06 |
enell |
132 |
} |
149 |
10 Aug 06 |
enell |
133 |
|
149 |
10 Aug 06 |
enell |
134 |
System.out.print("\n%\n"); |
149 |
10 Aug 06 |
enell |
135 |
|
149 |
10 Aug 06 |
enell |
136 |
try |
149 |
10 Aug 06 |
enell |
137 |
{ |
149 |
10 Aug 06 |
enell |
138 |
String[] row = reader.readDataRow(nbrOfColumns); |
149 |
10 Aug 06 |
enell |
139 |
float int1 = 0, int2 = 0; |
149 |
10 Aug 06 |
enell |
140 |
|
149 |
10 Aug 06 |
enell |
141 |
while (row != null) |
149 |
10 Aug 06 |
enell |
142 |
{ |
149 |
10 Aug 06 |
enell |
143 |
System.out.print(row[positionPos] + "\t" + row[reporterPos]); |
149 |
10 Aug 06 |
enell |
144 |
for (int i = 0; i < size(); i++) |
149 |
10 Aug 06 |
enell |
145 |
{ |
149 |
10 Aug 06 |
enell |
146 |
BioAssay tmp = get(i); |
149 |
10 Aug 06 |
enell |
147 |
int assay = assaysMap.indexOf(tmp.id); |
149 |
10 Aug 06 |
enell |
148 |
try |
149 |
10 Aug 06 |
enell |
149 |
{ |
149 |
10 Aug 06 |
enell |
150 |
int1 = Float.parseFloat(row[assayDataPos + intensity1Pos + assay * assayFieldsMap.size()]); |
149 |
10 Aug 06 |
enell |
151 |
int2 = Float.parseFloat(row[assayDataPos + intensity2Pos + assay * assayFieldsMap.size()]); |
149 |
10 Aug 06 |
enell |
152 |
System.out.print("\t" + int1 + "\t" + int2 + "\t1"); |
149 |
10 Aug 06 |
enell |
153 |
} |
149 |
10 Aug 06 |
enell |
154 |
catch (NumberFormatException nfe) |
149 |
10 Aug 06 |
enell |
155 |
{ |
149 |
10 Aug 06 |
enell |
156 |
System.out.print("\t\t\t0"); |
149 |
10 Aug 06 |
enell |
157 |
} |
149 |
10 Aug 06 |
enell |
158 |
} |
149 |
10 Aug 06 |
enell |
159 |
System.out.print("\n"); |
149 |
10 Aug 06 |
enell |
160 |
row = reader.readDataRow(nbrOfColumns); |
149 |
10 Aug 06 |
enell |
161 |
} |
149 |
10 Aug 06 |
enell |
162 |
} |
149 |
10 Aug 06 |
enell |
163 |
catch (BASEFileException bfe) |
149 |
10 Aug 06 |
enell |
164 |
{ |
149 |
10 Aug 06 |
enell |
165 |
bfe.printStackTrace(); |
149 |
10 Aug 06 |
enell |
166 |
} |
149 |
10 Aug 06 |
enell |
167 |
} |
149 |
10 Aug 06 |
enell |
168 |
} |