11 |
13 Sep 07 |
nicklas |
1 |
///////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
2 |
// |
11 |
13 Sep 07 |
nicklas |
// Copyright (C) 2005 Affymetrix, Inc. |
11 |
13 Sep 07 |
nicklas |
4 |
// |
11 |
13 Sep 07 |
nicklas |
// This library is free software; you can redistribute it and/or modify |
11 |
13 Sep 07 |
nicklas |
// it under the terms of the GNU Lesser General Public License as published |
11 |
13 Sep 07 |
nicklas |
// by the Free Software Foundation; either version 2.1 of the License, |
11 |
13 Sep 07 |
nicklas |
// or (at your option) any later version. |
11 |
13 Sep 07 |
nicklas |
9 |
// |
11 |
13 Sep 07 |
nicklas |
// This library is distributed in the hope that it will be useful, but |
11 |
13 Sep 07 |
nicklas |
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
11 |
13 Sep 07 |
nicklas |
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
11 |
13 Sep 07 |
nicklas |
// for more details. |
11 |
13 Sep 07 |
nicklas |
14 |
// |
11 |
13 Sep 07 |
nicklas |
// You should have received a copy of the GNU Lesser General Public License |
11 |
13 Sep 07 |
nicklas |
// along with this library; if not, write to the Free Software Foundation, Inc., |
11 |
13 Sep 07 |
nicklas |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
11 |
13 Sep 07 |
nicklas |
18 |
// |
11 |
13 Sep 07 |
nicklas |
19 |
///////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
20 |
|
11 |
13 Sep 07 |
nicklas |
21 |
package affymetrix.fusion.cel; |
11 |
13 Sep 07 |
nicklas |
22 |
|
11 |
13 Sep 07 |
nicklas |
23 |
import java.util.*; |
11 |
13 Sep 07 |
nicklas |
24 |
import java.io.*; |
15 |
17 Sep 07 |
nicklas |
25 |
|
11 |
13 Sep 07 |
nicklas |
26 |
import affymetrix.gcos.cel.*; |
11 |
13 Sep 07 |
nicklas |
27 |
import affymetrix.gcos.*; |
11 |
13 Sep 07 |
nicklas |
28 |
import affymetrix.fusion.*; |
11 |
13 Sep 07 |
nicklas |
29 |
import affymetrix.calvin.utils.*; |
11 |
13 Sep 07 |
nicklas |
30 |
import affymetrix.calvin.data.*; |
11 |
13 Sep 07 |
nicklas |
31 |
import affymetrix.calvin.parameter.*; |
11 |
13 Sep 07 |
nicklas |
32 |
import affymetrix.calvin.parsers.*; |
11 |
13 Sep 07 |
nicklas |
33 |
|
11 |
13 Sep 07 |
nicklas |
/** Provides an interface to read CEL files in either GCOS or Calvin format. */ |
11 |
13 Sep 07 |
nicklas |
35 |
public class FusionCELData { |
11 |
13 Sep 07 |
nicklas |
36 |
|
11 |
13 Sep 07 |
nicklas |
/** Flag to read all of the data in a CEL file. */ |
11 |
13 Sep 07 |
nicklas |
38 |
public static final int CEL_ALL=1; |
11 |
13 Sep 07 |
nicklas |
39 |
|
11 |
13 Sep 07 |
nicklas |
/** Flag to read only the data from a CEL file. */ |
11 |
13 Sep 07 |
nicklas |
41 |
public static final int CEL_DATA=2; |
11 |
13 Sep 07 |
nicklas |
42 |
|
11 |
13 Sep 07 |
nicklas |
/** Flag to read the outlier and data sections from a CEL file. */ |
11 |
13 Sep 07 |
nicklas |
44 |
public static final int CEL_OUTLIER=4; |
11 |
13 Sep 07 |
nicklas |
45 |
|
11 |
13 Sep 07 |
nicklas |
/** Flag to read the mask and data sections from a CEL file. */ |
11 |
13 Sep 07 |
nicklas |
47 |
public static final int CEL_MASK=8; |
11 |
13 Sep 07 |
nicklas |
48 |
|
11 |
13 Sep 07 |
nicklas |
/** The GCOS file object. */ |
11 |
13 Sep 07 |
nicklas |
50 |
private CELFileData gcosFile; |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
/** The Calvin file object. */ |
11 |
13 Sep 07 |
nicklas |
53 |
private CELData calvinFile; |
11 |
13 Sep 07 |
nicklas |
54 |
|
11 |
13 Sep 07 |
nicklas |
/** Error string */ |
11 |
13 Sep 07 |
nicklas |
56 |
private String strError; |
11 |
13 Sep 07 |
nicklas |
57 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the error. |
11 |
13 Sep 07 |
nicklas |
* @return The last error message. |
11 |
13 Sep 07 |
nicklas |
60 |
*/ |
15 |
17 Sep 07 |
nicklas |
61 |
public String getError() { |
15 |
17 Sep 07 |
nicklas |
62 |
if (gcosFile != null) return gcosFile.getError(); |
15 |
17 Sep 07 |
nicklas |
63 |
return strError; |
15 |
17 Sep 07 |
nicklas |
64 |
} |
11 |
13 Sep 07 |
nicklas |
65 |
|
11 |
13 Sep 07 |
nicklas |
/** The file name. */ |
11 |
13 Sep 07 |
nicklas |
67 |
private String fileName; |
11 |
13 Sep 07 |
nicklas |
68 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the file name. |
11 |
13 Sep 07 |
nicklas |
* @return The file name. |
11 |
13 Sep 07 |
nicklas |
71 |
*/ |
11 |
13 Sep 07 |
nicklas |
72 |
public String getFileName() { return fileName; } |
11 |
13 Sep 07 |
nicklas |
73 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the file name. |
11 |
13 Sep 07 |
nicklas |
* @param value The name of the CEL file to read. |
11 |
13 Sep 07 |
nicklas |
76 |
*/ |
11 |
13 Sep 07 |
nicklas |
77 |
public void setFileName(String value) { fileName = value; } |
15 |
17 Sep 07 |
nicklas |
78 |
|
15 |
17 Sep 07 |
nicklas |
79 |
/** |
15 |
17 Sep 07 |
nicklas |
* If set, we will read data from this input stream instead of |
15 |
17 Sep 07 |
nicklas |
* from the file specified by fileName |
15 |
17 Sep 07 |
nicklas |
82 |
*/ |
15 |
17 Sep 07 |
nicklas |
83 |
private InputStream in; |
11 |
13 Sep 07 |
nicklas |
84 |
|
19 |
15 Nov 07 |
nicklas |
85 |
/** |
19 |
15 Nov 07 |
nicklas |
* Temporary file in case we need to copy the entire InputStream |
19 |
15 Nov 07 |
nicklas |
87 |
*/ |
19 |
15 Nov 07 |
nicklas |
88 |
private File tempFile; |
19 |
15 Nov 07 |
nicklas |
89 |
|
15 |
17 Sep 07 |
nicklas |
90 |
/** |
15 |
17 Sep 07 |
nicklas |
* Set the input stream to read from. If set |
15 |
17 Sep 07 |
nicklas |
* we use the stream instead of the file given by filename |
15 |
17 Sep 07 |
nicklas |
93 |
*/ |
15 |
17 Sep 07 |
nicklas |
94 |
public void setInputStream(InputStream in) |
15 |
17 Sep 07 |
nicklas |
95 |
{ |
15 |
17 Sep 07 |
nicklas |
96 |
this.in = in; |
15 |
17 Sep 07 |
nicklas |
97 |
} |
15 |
17 Sep 07 |
nicklas |
98 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the id of the file (only valid for Command Console "calvin" files) |
11 |
13 Sep 07 |
nicklas |
* @return The unique file id. |
11 |
13 Sep 07 |
nicklas |
101 |
*/ |
11 |
13 Sep 07 |
nicklas |
102 |
public AffymetrixGuidType getFileId() { |
11 |
13 Sep 07 |
nicklas |
103 |
if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
104 |
return calvinFile.getFileHeader().getGenericDataHdr().getFileId(); |
11 |
13 Sep 07 |
nicklas |
105 |
return null; |
11 |
13 Sep 07 |
nicklas |
106 |
} |
11 |
13 Sep 07 |
nicklas |
107 |
|
11 |
13 Sep 07 |
nicklas |
/** Number of columns in array */ |
11 |
13 Sep 07 |
nicklas |
109 |
public int getCols() { |
11 |
13 Sep 07 |
nicklas |
110 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
111 |
return gcosFile.getHeader().getCols(); |
11 |
13 Sep 07 |
nicklas |
112 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
113 |
return calvinFile.getCols(); |
11 |
13 Sep 07 |
nicklas |
114 |
return 0; |
11 |
13 Sep 07 |
nicklas |
115 |
} |
11 |
13 Sep 07 |
nicklas |
116 |
|
11 |
13 Sep 07 |
nicklas |
/** Number of rows in array */ |
11 |
13 Sep 07 |
nicklas |
118 |
public int getRows() { |
11 |
13 Sep 07 |
nicklas |
119 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
120 |
return gcosFile.getHeader().getRows(); |
11 |
13 Sep 07 |
nicklas |
121 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
122 |
return calvinFile.getRows(); |
11 |
13 Sep 07 |
nicklas |
123 |
return 0; |
11 |
13 Sep 07 |
nicklas |
124 |
} |
11 |
13 Sep 07 |
nicklas |
125 |
|
11 |
13 Sep 07 |
nicklas |
/** Number of cells in array */ |
11 |
13 Sep 07 |
nicklas |
127 |
public int getCells() { |
11 |
13 Sep 07 |
nicklas |
128 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
129 |
return gcosFile.getHeader().getCells(); |
11 |
13 Sep 07 |
nicklas |
130 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
131 |
return calvinFile.getNumCells(); |
11 |
13 Sep 07 |
nicklas |
132 |
return 0; |
11 |
13 Sep 07 |
nicklas |
133 |
} |
11 |
13 Sep 07 |
nicklas |
134 |
|
11 |
13 Sep 07 |
nicklas |
/** Header information concatenated in a string */ |
11 |
13 Sep 07 |
nicklas |
136 |
public String getHeader() { |
11 |
13 Sep 07 |
nicklas |
137 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
138 |
return gcosFile.getHeader().getHeader(); |
11 |
13 Sep 07 |
nicklas |
139 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
140 |
return ""; |
11 |
13 Sep 07 |
nicklas |
141 |
return null; |
11 |
13 Sep 07 |
nicklas |
142 |
} |
11 |
13 Sep 07 |
nicklas |
143 |
|
11 |
13 Sep 07 |
nicklas |
/** Algorithm name */ |
11 |
13 Sep 07 |
nicklas |
145 |
public String getAlg() { |
11 |
13 Sep 07 |
nicklas |
146 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
147 |
return gcosFile.getHeader().getAlg(); |
11 |
13 Sep 07 |
nicklas |
148 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
149 |
return calvinFile.getAlgorithmName(); |
11 |
13 Sep 07 |
nicklas |
150 |
return null; |
11 |
13 Sep 07 |
nicklas |
151 |
} |
11 |
13 Sep 07 |
nicklas |
152 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieve algorithm parameters |
11 |
13 Sep 07 |
nicklas |
* @return Algorithm parameters |
11 |
13 Sep 07 |
nicklas |
155 |
*/ |
11 |
13 Sep 07 |
nicklas |
156 |
public String getParams() { |
11 |
13 Sep 07 |
nicklas |
157 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
158 |
{ |
11 |
13 Sep 07 |
nicklas |
159 |
String strparam = ""; |
11 |
13 Sep 07 |
nicklas |
160 |
int n=gcosFile.getHeader().getParameters().size(); |
11 |
13 Sep 07 |
nicklas |
161 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
162 |
{ |
11 |
13 Sep 07 |
nicklas |
163 |
if (i > 0) |
11 |
13 Sep 07 |
nicklas |
164 |
strparam += ";"; |
11 |
13 Sep 07 |
nicklas |
165 |
TagValuePair param = (TagValuePair) gcosFile.getHeader().getParameters().elementAt(i); |
11 |
13 Sep 07 |
nicklas |
166 |
strparam += param.getTag(); |
11 |
13 Sep 07 |
nicklas |
167 |
strparam += ":"; |
11 |
13 Sep 07 |
nicklas |
168 |
if (param.getValue() != null) |
11 |
13 Sep 07 |
nicklas |
169 |
strparam += param.getValue(); |
11 |
13 Sep 07 |
nicklas |
170 |
} |
11 |
13 Sep 07 |
nicklas |
171 |
return strparam; |
11 |
13 Sep 07 |
nicklas |
172 |
} |
11 |
13 Sep 07 |
nicklas |
173 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
174 |
{ |
11 |
13 Sep 07 |
nicklas |
175 |
String strparam = ""; |
11 |
13 Sep 07 |
nicklas |
176 |
Vector params = calvinFile.getAlgorithmParameters(); |
11 |
13 Sep 07 |
nicklas |
177 |
for (int i=0; i<params.size(); i++) |
11 |
13 Sep 07 |
nicklas |
178 |
{ |
11 |
13 Sep 07 |
nicklas |
179 |
if (i > 0) |
11 |
13 Sep 07 |
nicklas |
180 |
strparam += ";"; |
11 |
13 Sep 07 |
nicklas |
181 |
ParameterNameValue param = (ParameterNameValue) params.elementAt(i); |
11 |
13 Sep 07 |
nicklas |
182 |
strparam += param.getName(); |
11 |
13 Sep 07 |
nicklas |
183 |
strparam += ":"; |
11 |
13 Sep 07 |
nicklas |
184 |
if (param.toString() != null) |
11 |
13 Sep 07 |
nicklas |
185 |
strparam += param.toString(); |
11 |
13 Sep 07 |
nicklas |
186 |
} |
11 |
13 Sep 07 |
nicklas |
187 |
} |
11 |
13 Sep 07 |
nicklas |
188 |
return null; |
11 |
13 Sep 07 |
nicklas |
189 |
} |
11 |
13 Sep 07 |
nicklas |
190 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieve algorithm parameter of specified tag |
11 |
13 Sep 07 |
nicklas |
* @param tag Algorithm parameter tag |
11 |
13 Sep 07 |
nicklas |
* @return Algorithm parameter value |
11 |
13 Sep 07 |
nicklas |
194 |
*/ |
11 |
13 Sep 07 |
nicklas |
195 |
public String getAlgorithmParameter(String tag) { |
11 |
13 Sep 07 |
nicklas |
196 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
197 |
{ |
11 |
13 Sep 07 |
nicklas |
198 |
int n=gcosFile.getHeader().getParameters().size(); |
11 |
13 Sep 07 |
nicklas |
199 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
200 |
{ |
11 |
13 Sep 07 |
nicklas |
201 |
TagValuePair param = (TagValuePair) gcosFile.getHeader().getParameters().elementAt(i); |
11 |
13 Sep 07 |
nicklas |
202 |
if (tag.compareTo(param.getTag()) == 0) |
11 |
13 Sep 07 |
nicklas |
203 |
return param.getValue(); |
11 |
13 Sep 07 |
nicklas |
204 |
} |
11 |
13 Sep 07 |
nicklas |
205 |
} |
11 |
13 Sep 07 |
nicklas |
206 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
207 |
{ |
11 |
13 Sep 07 |
nicklas |
208 |
Vector params = calvinFile.getAlgorithmParameters(); |
11 |
13 Sep 07 |
nicklas |
209 |
for (int i=0; i<params.size(); i++) |
11 |
13 Sep 07 |
nicklas |
210 |
{ |
11 |
13 Sep 07 |
nicklas |
211 |
ParameterNameValue param = (ParameterNameValue) params.elementAt(i); |
11 |
13 Sep 07 |
nicklas |
212 |
if (tag.compareTo(param.getName()) == 0) |
11 |
13 Sep 07 |
nicklas |
213 |
return param.toString(); |
11 |
13 Sep 07 |
nicklas |
214 |
} |
11 |
13 Sep 07 |
nicklas |
215 |
} |
11 |
13 Sep 07 |
nicklas |
216 |
return null; |
11 |
13 Sep 07 |
nicklas |
217 |
} |
11 |
13 Sep 07 |
nicklas |
218 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves the algorithm parameter name (tag) for a given index position. |
11 |
13 Sep 07 |
nicklas |
* @param index The zero based index to the parameter array (0 to the number of alg parameters - 1). |
11 |
13 Sep 07 |
nicklas |
* @return The parameter name (tag). |
11 |
13 Sep 07 |
nicklas |
222 |
*/ |
11 |
13 Sep 07 |
nicklas |
223 |
public String getAlgorithmParameterTag(int index) { |
11 |
13 Sep 07 |
nicklas |
224 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
225 |
{ |
11 |
13 Sep 07 |
nicklas |
226 |
TagValuePair param = (TagValuePair) gcosFile.getHeader().getParameters().elementAt(index); |
11 |
13 Sep 07 |
nicklas |
227 |
return param.getTag(); |
11 |
13 Sep 07 |
nicklas |
228 |
} |
11 |
13 Sep 07 |
nicklas |
229 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
230 |
{ |
11 |
13 Sep 07 |
nicklas |
231 |
ParameterNameValue param = (ParameterNameValue) calvinFile.getAlgorithmParameters().elementAt(index); |
11 |
13 Sep 07 |
nicklas |
232 |
return param.getName(); |
11 |
13 Sep 07 |
nicklas |
233 |
} |
11 |
13 Sep 07 |
nicklas |
234 |
return null; |
11 |
13 Sep 07 |
nicklas |
235 |
} |
11 |
13 Sep 07 |
nicklas |
236 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves the number of algorithm parameters. |
11 |
13 Sep 07 |
nicklas |
* @return The number of algorithm parameters. |
11 |
13 Sep 07 |
nicklas |
239 |
*/ |
11 |
13 Sep 07 |
nicklas |
240 |
public int getNumberAlgorithmParameters() { |
11 |
13 Sep 07 |
nicklas |
241 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
242 |
return gcosFile.getHeader().getParameters().size(); |
11 |
13 Sep 07 |
nicklas |
243 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
244 |
return calvinFile.getAlgorithmParameters().size(); |
11 |
13 Sep 07 |
nicklas |
245 |
return 0; |
11 |
13 Sep 07 |
nicklas |
246 |
} |
11 |
13 Sep 07 |
nicklas |
247 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieve algorithm parameters |
11 |
13 Sep 07 |
nicklas |
* @return Algorithm parameters |
11 |
13 Sep 07 |
nicklas |
250 |
*/ |
11 |
13 Sep 07 |
nicklas |
251 |
public String getAlgorithmParameters() { return getParams(); } |
11 |
13 Sep 07 |
nicklas |
252 |
|
11 |
13 Sep 07 |
nicklas |
/** Algorithm parameters as a vector of FusionTagValuePair objects*/ |
11 |
13 Sep 07 |
nicklas |
254 |
public Vector getParameters() { |
11 |
13 Sep 07 |
nicklas |
255 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
256 |
{ |
11 |
13 Sep 07 |
nicklas |
257 |
Vector gcosParams = gcosFile.getHeader().getParameters(); |
11 |
13 Sep 07 |
nicklas |
258 |
int n = gcosParams.size(); |
11 |
13 Sep 07 |
nicklas |
259 |
Vector params = new Vector(); |
11 |
13 Sep 07 |
nicklas |
260 |
params.setSize(n); |
11 |
13 Sep 07 |
nicklas |
261 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
262 |
{ |
11 |
13 Sep 07 |
nicklas |
263 |
FusionTagValuePair param = new FusionTagValuePair(); |
11 |
13 Sep 07 |
nicklas |
264 |
TagValuePair gcosParam = (TagValuePair) gcosParams.elementAt(i); |
11 |
13 Sep 07 |
nicklas |
265 |
param.setTag(gcosParam.getTag()); |
11 |
13 Sep 07 |
nicklas |
266 |
param.setValue(gcosParam.getValue()); |
11 |
13 Sep 07 |
nicklas |
267 |
params.set(i, param); |
11 |
13 Sep 07 |
nicklas |
268 |
} |
11 |
13 Sep 07 |
nicklas |
269 |
return params; |
11 |
13 Sep 07 |
nicklas |
270 |
} |
11 |
13 Sep 07 |
nicklas |
271 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
272 |
{ |
11 |
13 Sep 07 |
nicklas |
273 |
Vector calvinParams = calvinFile.getAlgorithmParameters(); |
11 |
13 Sep 07 |
nicklas |
274 |
int n = calvinParams.size(); |
11 |
13 Sep 07 |
nicklas |
275 |
Vector params = new Vector(); |
11 |
13 Sep 07 |
nicklas |
276 |
params.setSize(n); |
11 |
13 Sep 07 |
nicklas |
277 |
for (int i=0; i<n; i++) |
11 |
13 Sep 07 |
nicklas |
278 |
{ |
11 |
13 Sep 07 |
nicklas |
279 |
FusionTagValuePair param = new FusionTagValuePair(); |
11 |
13 Sep 07 |
nicklas |
280 |
ParameterNameValue calvinParam = (ParameterNameValue) calvinParams.elementAt(i); |
11 |
13 Sep 07 |
nicklas |
281 |
param.setTag(calvinParam.getName()); |
11 |
13 Sep 07 |
nicklas |
282 |
param.setValue(calvinParam.toString()); |
11 |
13 Sep 07 |
nicklas |
283 |
param.setDetailed(calvinParam); |
11 |
13 Sep 07 |
nicklas |
284 |
params.set(i, param); |
11 |
13 Sep 07 |
nicklas |
285 |
} |
11 |
13 Sep 07 |
nicklas |
286 |
return params; |
11 |
13 Sep 07 |
nicklas |
287 |
} |
11 |
13 Sep 07 |
nicklas |
288 |
return null; |
11 |
13 Sep 07 |
nicklas |
289 |
} |
11 |
13 Sep 07 |
nicklas |
290 |
|
11 |
13 Sep 07 |
nicklas |
/** Chip type of array */ |
11 |
13 Sep 07 |
nicklas |
292 |
public String getChipType() { |
11 |
13 Sep 07 |
nicklas |
293 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
294 |
return gcosFile.getHeader().getChipType(); |
11 |
13 Sep 07 |
nicklas |
295 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
296 |
return calvinFile.getArrayType(); |
11 |
13 Sep 07 |
nicklas |
297 |
return null; |
11 |
13 Sep 07 |
nicklas |
298 |
} |
11 |
13 Sep 07 |
nicklas |
299 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the master file |
11 |
13 Sep 07 |
nicklas |
* @return The name of the master file (null if GCOS format CEL file) |
11 |
13 Sep 07 |
nicklas |
302 |
*/ |
11 |
13 Sep 07 |
nicklas |
303 |
public String getMasterFileName() { |
11 |
13 Sep 07 |
nicklas |
304 |
if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
305 |
return calvinFile.getMasterFileName(); |
11 |
13 Sep 07 |
nicklas |
306 |
else |
11 |
13 Sep 07 |
nicklas |
307 |
return null; |
11 |
13 Sep 07 |
nicklas |
308 |
} |
11 |
13 Sep 07 |
nicklas |
309 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the library package |
11 |
13 Sep 07 |
nicklas |
* @return The name of the library package (null if GCOS format CEL file) |
11 |
13 Sep 07 |
nicklas |
312 |
*/ |
11 |
13 Sep 07 |
nicklas |
313 |
public String getLibraryPackageName() { |
11 |
13 Sep 07 |
nicklas |
314 |
if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
315 |
return calvinFile.getLibraryPackageName(); |
11 |
13 Sep 07 |
nicklas |
316 |
else |
11 |
13 Sep 07 |
nicklas |
317 |
return null; |
11 |
13 Sep 07 |
nicklas |
318 |
} |
11 |
13 Sep 07 |
nicklas |
319 |
|
11 |
13 Sep 07 |
nicklas |
/** DAT header string */ |
11 |
13 Sep 07 |
nicklas |
321 |
public String getDatHeader() { |
11 |
13 Sep 07 |
nicklas |
322 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
323 |
return gcosFile.getHeader().getDatHeader(); |
11 |
13 Sep 07 |
nicklas |
324 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
325 |
{ |
11 |
13 Sep 07 |
nicklas |
326 |
GenericDataHeader gdh = calvinFile.getFileHeader().getGenericDataHdr().findParent(AffymetrixParameterConsts.SCAN_ACQUISITION_DATA_TYPE); |
11 |
13 Sep 07 |
nicklas |
327 |
if (gdh != null) |
11 |
13 Sep 07 |
nicklas |
328 |
{ |
11 |
13 Sep 07 |
nicklas |
// found the right header, now look for the parameter |
11 |
13 Sep 07 |
nicklas |
330 |
ParameterNameValue nvt = gdh.findNameValParam(AffymetrixParameterConsts.DAT_HEADER_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
331 |
if (nvt != null) |
11 |
13 Sep 07 |
nicklas |
332 |
{ |
11 |
13 Sep 07 |
nicklas |
333 |
if (nvt.getParameterType() == ParameterNameValue.TextType) |
11 |
13 Sep 07 |
nicklas |
334 |
return nvt.getValueText(); |
11 |
13 Sep 07 |
nicklas |
335 |
} |
11 |
13 Sep 07 |
nicklas |
336 |
|
11 |
13 Sep 07 |
nicklas |
337 |
nvt = gdh.findNameValParam(AffymetrixParameterConsts.PARTIAL_DAT_HEADER_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
338 |
if (nvt != null) |
11 |
13 Sep 07 |
nicklas |
339 |
{ |
11 |
13 Sep 07 |
nicklas |
340 |
if (nvt.getParameterType() == ParameterNameValue.TextType) |
11 |
13 Sep 07 |
nicklas |
341 |
{ |
11 |
13 Sep 07 |
nicklas |
342 |
String partialDatHeader = nvt.getValueText(); |
11 |
13 Sep 07 |
nicklas |
343 |
|
11 |
13 Sep 07 |
nicklas |
344 |
int min = 0; |
11 |
13 Sep 07 |
nicklas |
345 |
int max = 0; |
11 |
13 Sep 07 |
nicklas |
346 |
|
11 |
13 Sep 07 |
nicklas |
// Find the max and min parameters and append to the string. |
11 |
13 Sep 07 |
nicklas |
348 |
nvt = gdh.findNameValParam(AffymetrixParameterConsts.MAX_PIXEL_INTENSITY_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
349 |
if (nvt != null) |
11 |
13 Sep 07 |
nicklas |
350 |
{ |
11 |
13 Sep 07 |
nicklas |
351 |
if (nvt.getParameterType() == ParameterNameValue.UInt16Type) |
11 |
13 Sep 07 |
nicklas |
352 |
max = nvt.getValueUInt16(); |
11 |
13 Sep 07 |
nicklas |
353 |
} |
11 |
13 Sep 07 |
nicklas |
354 |
|
11 |
13 Sep 07 |
nicklas |
355 |
nvt = gdh.findNameValParam(AffymetrixParameterConsts.MIN_PIXEL_INTENSITY_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
356 |
if (nvt != null) |
11 |
13 Sep 07 |
nicklas |
357 |
{ |
11 |
13 Sep 07 |
nicklas |
358 |
if (nvt.getParameterType() == ParameterNameValue.UInt16Type) |
11 |
13 Sep 07 |
nicklas |
359 |
min = nvt.getValueUInt16(); |
11 |
13 Sep 07 |
nicklas |
360 |
} |
11 |
13 Sep 07 |
nicklas |
361 |
|
11 |
13 Sep 07 |
nicklas |
362 |
return "[" + Integer.toString(min) + ".." + Integer.toString(max) + "]" + partialDatHeader; |
11 |
13 Sep 07 |
nicklas |
363 |
} |
11 |
13 Sep 07 |
nicklas |
364 |
} |
11 |
13 Sep 07 |
nicklas |
365 |
} |
11 |
13 Sep 07 |
nicklas |
366 |
} |
11 |
13 Sep 07 |
nicklas |
367 |
return null; |
11 |
13 Sep 07 |
nicklas |
368 |
} |
11 |
13 Sep 07 |
nicklas |
369 |
|
11 |
13 Sep 07 |
nicklas |
/** Cell margin */ |
11 |
13 Sep 07 |
nicklas |
371 |
public int getCellMargin() { |
11 |
13 Sep 07 |
nicklas |
372 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
373 |
return gcosFile.getHeader().getMargin(); |
11 |
13 Sep 07 |
nicklas |
374 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
375 |
{ |
11 |
13 Sep 07 |
nicklas |
376 |
ParameterNameValue nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.CELLMARGIN_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
377 |
if (nvt != null) |
11 |
13 Sep 07 |
nicklas |
378 |
{ |
11 |
13 Sep 07 |
nicklas |
379 |
switch(nvt.getParameterType()) |
11 |
13 Sep 07 |
nicklas |
380 |
{ |
11 |
13 Sep 07 |
nicklas |
381 |
case ParameterNameValue.Int32Type: |
11 |
13 Sep 07 |
nicklas |
382 |
return nvt.getValueInt32(); |
11 |
13 Sep 07 |
nicklas |
383 |
case ParameterNameValue.Int16Type: |
11 |
13 Sep 07 |
nicklas |
384 |
return (int)nvt.getValueInt16(); |
11 |
13 Sep 07 |
nicklas |
385 |
case ParameterNameValue.Int8Type: |
11 |
13 Sep 07 |
nicklas |
386 |
return (int)nvt.getValueInt8(); |
11 |
13 Sep 07 |
nicklas |
387 |
case ParameterNameValue.UInt32Type: |
11 |
13 Sep 07 |
nicklas |
388 |
return (int)nvt.getValueUInt32(); |
11 |
13 Sep 07 |
nicklas |
389 |
case ParameterNameValue.UInt16Type: |
11 |
13 Sep 07 |
nicklas |
390 |
return (int)nvt.getValueUInt16(); |
11 |
13 Sep 07 |
nicklas |
391 |
case ParameterNameValue.UInt8Type: |
11 |
13 Sep 07 |
nicklas |
392 |
return (int)nvt.getValueUInt8(); |
11 |
13 Sep 07 |
nicklas |
393 |
case ParameterNameValue.AsciiType: |
11 |
13 Sep 07 |
nicklas |
394 |
return Integer.parseInt(nvt.toString()); |
11 |
13 Sep 07 |
nicklas |
395 |
default: |
11 |
13 Sep 07 |
nicklas |
396 |
return 0; |
11 |
13 Sep 07 |
nicklas |
397 |
} |
11 |
13 Sep 07 |
nicklas |
398 |
} |
11 |
13 Sep 07 |
nicklas |
399 |
} |
11 |
13 Sep 07 |
nicklas |
400 |
return 0; |
11 |
13 Sep 07 |
nicklas |
401 |
} |
11 |
13 Sep 07 |
nicklas |
402 |
|
11 |
13 Sep 07 |
nicklas |
/** Number of outliers */ |
11 |
13 Sep 07 |
nicklas |
404 |
public int getNumOutliers() { |
11 |
13 Sep 07 |
nicklas |
405 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
406 |
return gcosFile.getHeader().getOutliers(); |
11 |
13 Sep 07 |
nicklas |
407 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
408 |
return calvinFile.getNumOutliers(); |
11 |
13 Sep 07 |
nicklas |
409 |
return 0; |
11 |
13 Sep 07 |
nicklas |
410 |
} |
11 |
13 Sep 07 |
nicklas |
411 |
|
11 |
13 Sep 07 |
nicklas |
/** Number of masked cells */ |
11 |
13 Sep 07 |
nicklas |
413 |
public int getNumMasked() { |
11 |
13 Sep 07 |
nicklas |
414 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
415 |
return gcosFile.getHeader().getMasked(); |
11 |
13 Sep 07 |
nicklas |
416 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
417 |
return calvinFile.getNumMasked(); |
11 |
13 Sep 07 |
nicklas |
418 |
return 0; |
11 |
13 Sep 07 |
nicklas |
419 |
} |
11 |
13 Sep 07 |
nicklas |
420 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the grid coordinates. |
11 |
13 Sep 07 |
nicklas |
* @return Returns the grid coordinates. |
11 |
13 Sep 07 |
nicklas |
423 |
*/ |
11 |
13 Sep 07 |
nicklas |
424 |
public FGridCoords getGridCorners() { |
11 |
13 Sep 07 |
nicklas |
425 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
426 |
{ |
11 |
13 Sep 07 |
nicklas |
427 |
GridCoordinates grid = gcosFile.getHeader().getGrid(); |
11 |
13 Sep 07 |
nicklas |
428 |
FGridCoords fgrid = new FGridCoords(); |
11 |
13 Sep 07 |
nicklas |
429 |
FPoint fpt = new FPoint(); |
11 |
13 Sep 07 |
nicklas |
430 |
fpt.setX((float) grid.getUpperLeft().getX()); |
11 |
13 Sep 07 |
nicklas |
431 |
fpt.setY((float) grid.getUpperLeft().getY()); |
11 |
13 Sep 07 |
nicklas |
432 |
fgrid.setUpperLeft(fpt); |
11 |
13 Sep 07 |
nicklas |
433 |
fpt = new FPoint(); |
11 |
13 Sep 07 |
nicklas |
434 |
fpt.setX((float) grid.getUpperRight().getX()); |
11 |
13 Sep 07 |
nicklas |
435 |
fpt.setY((float) grid.getUpperRight().getY()); |
11 |
13 Sep 07 |
nicklas |
436 |
fgrid.setUpperRight(fpt); |
11 |
13 Sep 07 |
nicklas |
437 |
fpt = new FPoint(); |
11 |
13 Sep 07 |
nicklas |
438 |
fpt.setX((float) grid.getLowerRight().getX()); |
11 |
13 Sep 07 |
nicklas |
439 |
fpt.setY((float) grid.getLowerRight().getY()); |
11 |
13 Sep 07 |
nicklas |
440 |
fgrid.setLowerRight(fpt); |
11 |
13 Sep 07 |
nicklas |
441 |
fpt = new FPoint(); |
11 |
13 Sep 07 |
nicklas |
442 |
fpt.setX((float) grid.getLowerLeft().getX()); |
11 |
13 Sep 07 |
nicklas |
443 |
fpt.setY((float) grid.getLowerLeft().getY()); |
11 |
13 Sep 07 |
nicklas |
444 |
fgrid.setLowerLeft(fpt); |
11 |
13 Sep 07 |
nicklas |
445 |
return fgrid; |
11 |
13 Sep 07 |
nicklas |
446 |
} |
11 |
13 Sep 07 |
nicklas |
447 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
448 |
{ |
11 |
13 Sep 07 |
nicklas |
449 |
FGridCoords grid = new FGridCoords(); |
11 |
13 Sep 07 |
nicklas |
450 |
ParameterNameValue nvt; |
11 |
13 Sep 07 |
nicklas |
451 |
|
11 |
13 Sep 07 |
nicklas |
452 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDULX_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
453 |
grid.getUpperLeft().setX(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
454 |
|
11 |
13 Sep 07 |
nicklas |
455 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDULY_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
456 |
grid.getUpperLeft().setY(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
457 |
|
11 |
13 Sep 07 |
nicklas |
458 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDURX_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
459 |
grid.getUpperRight().setX(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
460 |
|
11 |
13 Sep 07 |
nicklas |
461 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDURY_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
462 |
grid.getUpperRight().setY(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
463 |
|
11 |
13 Sep 07 |
nicklas |
464 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDLRX_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
465 |
grid.getLowerRight().setX(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
466 |
|
11 |
13 Sep 07 |
nicklas |
467 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDLRY_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
468 |
grid.getLowerRight().setY(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
469 |
|
11 |
13 Sep 07 |
nicklas |
470 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDLLX_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
471 |
grid.getLowerLeft().setX(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
472 |
|
11 |
13 Sep 07 |
nicklas |
473 |
nvt = calvinFile.findAlgorithmParameter(CELAlgorithmParameterNames.GRIDLLY_PARAM_NAME); |
11 |
13 Sep 07 |
nicklas |
474 |
grid.getLowerLeft().setY(nvt.getValueFloat()); |
11 |
13 Sep 07 |
nicklas |
475 |
|
11 |
13 Sep 07 |
nicklas |
476 |
return grid; |
11 |
13 Sep 07 |
nicklas |
477 |
} |
11 |
13 Sep 07 |
nicklas |
478 |
return null; |
11 |
13 Sep 07 |
nicklas |
479 |
} |
11 |
13 Sep 07 |
nicklas |
480 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the X coordinates from index. |
11 |
13 Sep 07 |
nicklas |
* @param index The 0 based index to the entry array. |
11 |
13 Sep 07 |
nicklas |
* @return X coordinate |
11 |
13 Sep 07 |
nicklas |
484 |
*/ |
11 |
13 Sep 07 |
nicklas |
485 |
public int indexToX(int index) { |
11 |
13 Sep 07 |
nicklas |
486 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
487 |
return gcosFile.indexToX(index); |
11 |
13 Sep 07 |
nicklas |
488 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
489 |
return calvinFile.indexToX(index); |
11 |
13 Sep 07 |
nicklas |
490 |
return 0; |
11 |
13 Sep 07 |
nicklas |
491 |
} |
11 |
13 Sep 07 |
nicklas |
492 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the Y coordinates from index. |
11 |
13 Sep 07 |
nicklas |
* @param index The 0 based index to the entry array. |
11 |
13 Sep 07 |
nicklas |
* @return Y coordinate |
11 |
13 Sep 07 |
nicklas |
496 |
*/ |
11 |
13 Sep 07 |
nicklas |
497 |
public int indexToY(int index) { |
11 |
13 Sep 07 |
nicklas |
498 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
499 |
return gcosFile.indexToY(index); |
11 |
13 Sep 07 |
nicklas |
500 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
501 |
return calvinFile.indexToY(index); |
11 |
13 Sep 07 |
nicklas |
502 |
return 0; |
11 |
13 Sep 07 |
nicklas |
503 |
} |
11 |
13 Sep 07 |
nicklas |
504 |
|
11 |
13 Sep 07 |
nicklas |
/** Maps X/Y coordinates to CEL file index. |
11 |
13 Sep 07 |
nicklas |
* @param x The x coordinate |
11 |
13 Sep 07 |
nicklas |
* @param y The y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @return The index to the entry array. |
11 |
13 Sep 07 |
nicklas |
509 |
*/ |
11 |
13 Sep 07 |
nicklas |
510 |
public int xyToIndex(int x, int y) { |
11 |
13 Sep 07 |
nicklas |
511 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
512 |
return gcosFile.xyToIndex(x, y); |
11 |
13 Sep 07 |
nicklas |
513 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
514 |
return calvinFile.xyToIndex(x, y); |
11 |
13 Sep 07 |
nicklas |
515 |
return 0; |
11 |
13 Sep 07 |
nicklas |
516 |
} |
11 |
13 Sep 07 |
nicklas |
517 |
|
11 |
13 Sep 07 |
nicklas |
/** Maps X/Y coordinates to CEL file index. |
11 |
13 Sep 07 |
nicklas |
* @param x The x coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param r The number of rows. |
11 |
13 Sep 07 |
nicklas |
* @param c The number of columns. |
11 |
13 Sep 07 |
nicklas |
* @return The index to the intensity arrays. |
11 |
13 Sep 07 |
nicklas |
524 |
*/ |
11 |
13 Sep 07 |
nicklas |
525 |
public static int xyToIndex(int x, int y, int r, int c) { |
11 |
13 Sep 07 |
nicklas |
526 |
return CELFileData.xyToIndex(x, y, r, c); |
11 |
13 Sep 07 |
nicklas |
527 |
} |
11 |
13 Sep 07 |
nicklas |
528 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file entry. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the CEL file entries. |
11 |
13 Sep 07 |
nicklas |
* @param entry The CEL file entry. |
11 |
13 Sep 07 |
nicklas |
532 |
*/ |
11 |
13 Sep 07 |
nicklas |
533 |
public void getEntry(int index, FusionCELFileEntryType entry) { |
11 |
13 Sep 07 |
nicklas |
534 |
entry.setIntensity(getIntensity(index)); |
11 |
13 Sep 07 |
nicklas |
535 |
entry.setStdv(getStdv(index)); |
11 |
13 Sep 07 |
nicklas |
536 |
entry.setPixels(getPixels(index)); |
11 |
13 Sep 07 |
nicklas |
537 |
} |
11 |
13 Sep 07 |
nicklas |
538 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file entry. |
11 |
13 Sep 07 |
nicklas |
* @param x The X coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The Y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param entry The CEL file entry. |
11 |
13 Sep 07 |
nicklas |
543 |
*/ |
11 |
13 Sep 07 |
nicklas |
544 |
public void getEntry(int x, int y, FusionCELFileEntryType entry) { getEntry(xyToIndex(x,y),entry); } |
11 |
13 Sep 07 |
nicklas |
545 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file intensity. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the CEL file entries. |
11 |
13 Sep 07 |
nicklas |
* @return The CEL file intensity. |
11 |
13 Sep 07 |
nicklas |
549 |
*/ |
11 |
13 Sep 07 |
nicklas |
550 |
public float getIntensity(int index) { |
11 |
13 Sep 07 |
nicklas |
551 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
552 |
return gcosFile.getIntensity(index); |
11 |
13 Sep 07 |
nicklas |
553 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
554 |
return calvinFile.getIntensity(index); |
11 |
13 Sep 07 |
nicklas |
555 |
return 0.0f; |
11 |
13 Sep 07 |
nicklas |
556 |
} |
11 |
13 Sep 07 |
nicklas |
557 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file intensity. |
11 |
13 Sep 07 |
nicklas |
* @param x The X coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The Y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @return The CEL file intensity. |
11 |
13 Sep 07 |
nicklas |
562 |
*/ |
11 |
13 Sep 07 |
nicklas |
563 |
public float getIntensity(int x, int y) { return getIntensity(xyToIndex(x,y)); } |
11 |
13 Sep 07 |
nicklas |
564 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file stdv value. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the CEL file entries. |
11 |
13 Sep 07 |
nicklas |
* @return The CEL file stdv value. |
11 |
13 Sep 07 |
nicklas |
568 |
*/ |
11 |
13 Sep 07 |
nicklas |
569 |
public float getStdv(int index) { |
11 |
13 Sep 07 |
nicklas |
570 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
571 |
return gcosFile.getStdv(index); |
11 |
13 Sep 07 |
nicklas |
572 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
573 |
return calvinFile.getStdv(index); |
11 |
13 Sep 07 |
nicklas |
574 |
return 0.0f; |
11 |
13 Sep 07 |
nicklas |
575 |
} |
11 |
13 Sep 07 |
nicklas |
576 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file stdv value. |
11 |
13 Sep 07 |
nicklas |
* @param x The X coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The Y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @return The CEL file stdv value. |
11 |
13 Sep 07 |
nicklas |
581 |
*/ |
11 |
13 Sep 07 |
nicklas |
582 |
public float getStdv(int x, int y) { return getStdv(xyToIndex(x,y)); } |
11 |
13 Sep 07 |
nicklas |
583 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file pixel count. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the CEL file entries. |
11 |
13 Sep 07 |
nicklas |
* @return The CEL file pixel count. |
11 |
13 Sep 07 |
nicklas |
587 |
*/ |
11 |
13 Sep 07 |
nicklas |
588 |
public short getPixels(int index) { |
11 |
13 Sep 07 |
nicklas |
589 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
590 |
return gcosFile.getPixels(index); |
11 |
13 Sep 07 |
nicklas |
591 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
592 |
return calvinFile.getPixels(index); |
11 |
13 Sep 07 |
nicklas |
593 |
return 0; |
11 |
13 Sep 07 |
nicklas |
594 |
} |
11 |
13 Sep 07 |
nicklas |
595 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file pixel count. |
11 |
13 Sep 07 |
nicklas |
* @param x The X coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The Y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @return The CEL file pixel count. |
11 |
13 Sep 07 |
nicklas |
600 |
*/ |
11 |
13 Sep 07 |
nicklas |
601 |
public short getPixels(int x, int y) { return getPixels(xyToIndex(x,y)); } |
11 |
13 Sep 07 |
nicklas |
602 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file mask flag. |
11 |
13 Sep 07 |
nicklas |
* @param x The X coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The Y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @return True if the feature is masked. |
11 |
13 Sep 07 |
nicklas |
607 |
*/ |
11 |
13 Sep 07 |
nicklas |
608 |
public boolean isMasked(int x, int y) { return isMasked(xyToIndex(x,y)); } |
11 |
13 Sep 07 |
nicklas |
609 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file mask flag. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the CEL file entries. |
11 |
13 Sep 07 |
nicklas |
* @return True if the feature is masked. |
11 |
13 Sep 07 |
nicklas |
613 |
*/ |
11 |
13 Sep 07 |
nicklas |
614 |
public boolean isMasked(int index) { |
11 |
13 Sep 07 |
nicklas |
615 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
616 |
return gcosFile.isMasked(index); |
11 |
13 Sep 07 |
nicklas |
617 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
618 |
return calvinFile.isMasked(index); |
11 |
13 Sep 07 |
nicklas |
619 |
return false; |
11 |
13 Sep 07 |
nicklas |
620 |
} |
11 |
13 Sep 07 |
nicklas |
621 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file outlier flag. |
11 |
13 Sep 07 |
nicklas |
* @param x The X coordinate. |
11 |
13 Sep 07 |
nicklas |
* @param y The Y coordinate. |
11 |
13 Sep 07 |
nicklas |
* @return True if the feature is an outlier. |
11 |
13 Sep 07 |
nicklas |
626 |
*/ |
11 |
13 Sep 07 |
nicklas |
627 |
public boolean isOutlier(int x, int y) { return isOutlier(xyToIndex(x,y)); } |
11 |
13 Sep 07 |
nicklas |
628 |
|
11 |
13 Sep 07 |
nicklas |
/** Retrieves a CEL file outlier flag. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the CEL file entries. |
11 |
13 Sep 07 |
nicklas |
* @return True if the feature is an outlier. |
11 |
13 Sep 07 |
nicklas |
632 |
*/ |
11 |
13 Sep 07 |
nicklas |
633 |
public boolean isOutlier(int index) { |
11 |
13 Sep 07 |
nicklas |
634 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
635 |
return gcosFile.isOutlier(index); |
11 |
13 Sep 07 |
nicklas |
636 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
637 |
return calvinFile.isOutlier(index); |
11 |
13 Sep 07 |
nicklas |
638 |
return false; |
11 |
13 Sep 07 |
nicklas |
639 |
} |
11 |
13 Sep 07 |
nicklas |
640 |
|
15 |
17 Sep 07 |
nicklas |
641 |
/** |
15 |
17 Sep 07 |
nicklas |
* Checks if the file exists or if an input stream has been specified. |
11 |
13 Sep 07 |
nicklas |
* @return True if the file exists. |
11 |
13 Sep 07 |
nicklas |
644 |
*/ |
15 |
17 Sep 07 |
nicklas |
645 |
public boolean exists() { |
15 |
17 Sep 07 |
nicklas |
646 |
return in != null || new File(fileName).exists(); |
11 |
13 Sep 07 |
nicklas |
647 |
} |
11 |
13 Sep 07 |
nicklas |
648 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates the GCOS or Calvin parser object as needed. */ |
11 |
13 Sep 07 |
nicklas |
650 |
private void createFileParser() { |
15 |
17 Sep 07 |
nicklas |
651 |
if (gcosFile != null || calvinFile != null) return; |
15 |
17 Sep 07 |
nicklas |
652 |
|
15 |
17 Sep 07 |
nicklas |
653 |
gcosFile = new CELFileData(); |
15 |
17 Sep 07 |
nicklas |
654 |
gcosFile.setFileName(fileName); |
15 |
17 Sep 07 |
nicklas |
655 |
gcosFile.setInputStream(in); |
15 |
17 Sep 07 |
nicklas |
656 |
if (gcosFile.isVersion3CompatibleFile() == true || |
15 |
17 Sep 07 |
nicklas |
657 |
gcosFile.isXDACompatibleFile() == true) |
11 |
13 Sep 07 |
nicklas |
658 |
{ |
11 |
13 Sep 07 |
nicklas |
659 |
return; |
11 |
13 Sep 07 |
nicklas |
660 |
} |
11 |
13 Sep 07 |
nicklas |
661 |
|
15 |
17 Sep 07 |
nicklas |
662 |
if (gcosFile.isCalvinCompatibleFile()) |
11 |
13 Sep 07 |
nicklas |
663 |
{ |
15 |
17 Sep 07 |
nicklas |
// Peeking at the InputStream have changed it |
15 |
17 Sep 07 |
nicklas |
665 |
in = gcosFile.getInputStream(); |
15 |
17 Sep 07 |
nicklas |
666 |
gcosFile = null; |
15 |
17 Sep 07 |
nicklas |
667 |
|
15 |
17 Sep 07 |
nicklas |
668 |
if (in != null) |
15 |
17 Sep 07 |
nicklas |
669 |
{ |
15 |
17 Sep 07 |
nicklas |
// We must copy the input stream to a temp file in this case |
15 |
17 Sep 07 |
nicklas |
671 |
try |
15 |
17 Sep 07 |
nicklas |
672 |
{ |
19 |
15 Nov 07 |
nicklas |
673 |
tempFile = File.createTempFile(fileName, null); |
15 |
17 Sep 07 |
nicklas |
674 |
fileName = tempFile.getAbsolutePath(); |
15 |
17 Sep 07 |
nicklas |
675 |
OutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile)); |
15 |
17 Sep 07 |
nicklas |
676 |
FileIO.copy(in, out); |
15 |
17 Sep 07 |
nicklas |
677 |
out.close(); |
15 |
17 Sep 07 |
nicklas |
678 |
tempFile.deleteOnExit(); |
15 |
17 Sep 07 |
nicklas |
679 |
} |
15 |
17 Sep 07 |
nicklas |
680 |
catch (Throwable t) |
15 |
17 Sep 07 |
nicklas |
681 |
{ |
15 |
17 Sep 07 |
nicklas |
682 |
strError = t.getMessage(); |
15 |
17 Sep 07 |
nicklas |
683 |
} |
15 |
17 Sep 07 |
nicklas |
684 |
} |
15 |
17 Sep 07 |
nicklas |
685 |
|
15 |
17 Sep 07 |
nicklas |
686 |
calvinFile = new CELData(); |
15 |
17 Sep 07 |
nicklas |
687 |
CELFileReader reader = new CELFileReader(); |
15 |
17 Sep 07 |
nicklas |
688 |
reader.setFilename(fileName); |
15 |
17 Sep 07 |
nicklas |
689 |
try |
15 |
17 Sep 07 |
nicklas |
690 |
{ |
15 |
17 Sep 07 |
nicklas |
691 |
reader.read(calvinFile); |
15 |
17 Sep 07 |
nicklas |
692 |
} |
15 |
17 Sep 07 |
nicklas |
693 |
catch (Throwable t) |
15 |
17 Sep 07 |
nicklas |
694 |
{ |
15 |
17 Sep 07 |
nicklas |
695 |
strError = t.getClass() + ": " + t.getMessage(); |
15 |
17 Sep 07 |
nicklas |
696 |
calvinFile = null; |
15 |
17 Sep 07 |
nicklas |
697 |
} |
15 |
17 Sep 07 |
nicklas |
698 |
return; |
11 |
13 Sep 07 |
nicklas |
699 |
} |
15 |
17 Sep 07 |
nicklas |
700 |
strError = "Unknown file format: " + fileName; |
11 |
13 Sep 07 |
nicklas |
701 |
} |
11 |
13 Sep 07 |
nicklas |
702 |
|
11 |
13 Sep 07 |
nicklas |
/** Reads the header of the CEL file. |
11 |
13 Sep 07 |
nicklas |
* @return True if successful. |
11 |
13 Sep 07 |
nicklas |
705 |
*/ |
11 |
13 Sep 07 |
nicklas |
706 |
public boolean readHeader() { |
11 |
13 Sep 07 |
nicklas |
707 |
createFileParser(); |
11 |
13 Sep 07 |
nicklas |
708 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
709 |
return gcosFile.readHeader(); |
11 |
13 Sep 07 |
nicklas |
710 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
711 |
return true; |
11 |
13 Sep 07 |
nicklas |
712 |
return false; |
11 |
13 Sep 07 |
nicklas |
713 |
} |
11 |
13 Sep 07 |
nicklas |
714 |
|
11 |
13 Sep 07 |
nicklas |
/** Reads the CEL file. |
11 |
13 Sep 07 |
nicklas |
* @return True if successful. |
11 |
13 Sep 07 |
nicklas |
717 |
*/ |
11 |
13 Sep 07 |
nicklas |
718 |
public boolean read() { |
11 |
13 Sep 07 |
nicklas |
719 |
createFileParser(); |
11 |
13 Sep 07 |
nicklas |
720 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
721 |
return gcosFile.read(); |
11 |
13 Sep 07 |
nicklas |
722 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
723 |
return true; |
11 |
13 Sep 07 |
nicklas |
724 |
return false; |
11 |
13 Sep 07 |
nicklas |
725 |
} |
11 |
13 Sep 07 |
nicklas |
726 |
|
11 |
13 Sep 07 |
nicklas |
/** Reads the CEL file. |
11 |
13 Sep 07 |
nicklas |
* @param bIncludeMaskAndOutliers Flag to indicate if the mask and outlier sections should also be read. |
11 |
13 Sep 07 |
nicklas |
* @return True if successful. |
11 |
13 Sep 07 |
nicklas |
730 |
*/ |
11 |
13 Sep 07 |
nicklas |
731 |
public boolean read(boolean bIncludeMaskAndOutliers) { |
11 |
13 Sep 07 |
nicklas |
732 |
createFileParser(); |
11 |
13 Sep 07 |
nicklas |
733 |
if (gcosFile != null) |
11 |
13 Sep 07 |
nicklas |
734 |
return gcosFile.read(bIncludeMaskAndOutliers); |
11 |
13 Sep 07 |
nicklas |
735 |
else if (calvinFile != null) |
11 |
13 Sep 07 |
nicklas |
736 |
return true; |
11 |
13 Sep 07 |
nicklas |
737 |
return false; |
11 |
13 Sep 07 |
nicklas |
738 |
} |
11 |
13 Sep 07 |
nicklas |
739 |
|
11 |
13 Sep 07 |
nicklas |
/** Clears the members. */ |
11 |
13 Sep 07 |
nicklas |
741 |
public void clear() { |
15 |
17 Sep 07 |
nicklas |
742 |
if (in == null) |
15 |
17 Sep 07 |
nicklas |
743 |
{ |
15 |
17 Sep 07 |
nicklas |
744 |
gcosFile = null; |
15 |
17 Sep 07 |
nicklas |
745 |
calvinFile = null; |
15 |
17 Sep 07 |
nicklas |
746 |
} |
11 |
13 Sep 07 |
nicklas |
747 |
} |
11 |
13 Sep 07 |
nicklas |
748 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a new instance of CELFileData */ |
11 |
13 Sep 07 |
nicklas |
750 |
public FusionCELData() { |
11 |
13 Sep 07 |
nicklas |
751 |
clear(); |
11 |
13 Sep 07 |
nicklas |
752 |
} |
19 |
15 Nov 07 |
nicklas |
753 |
|
19 |
15 Nov 07 |
nicklas |
754 |
@Override |
19 |
15 Nov 07 |
nicklas |
755 |
protected void finalize() |
19 |
15 Nov 07 |
nicklas |
756 |
throws Throwable |
19 |
15 Nov 07 |
nicklas |
757 |
{ |
19 |
15 Nov 07 |
nicklas |
758 |
super.finalize(); |
19 |
15 Nov 07 |
nicklas |
759 |
if (tempFile != null && tempFile.exists()) |
19 |
15 Nov 07 |
nicklas |
760 |
{ |
19 |
15 Nov 07 |
nicklas |
761 |
tempFile.delete(); |
19 |
15 Nov 07 |
nicklas |
762 |
} |
19 |
15 Nov 07 |
nicklas |
763 |
} |
19 |
15 Nov 07 |
nicklas |
764 |
|
11 |
13 Sep 07 |
nicklas |
765 |
} |