11 |
13 Sep 07 |
nicklas |
1 |
//////////////////////////////////////////////////////////////// |
11 |
13 Sep 07 |
nicklas |
2 |
// |
11 |
13 Sep 07 |
nicklas |
// Copyright (C) 2006 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 |
11 |
13 Sep 07 |
nicklas |
// (version 2.1) as published by the Free Software Foundation. |
11 |
13 Sep 07 |
nicklas |
8 |
// |
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 |
13 |
// |
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 |
17 |
// |
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.chp; |
11 |
13 Sep 07 |
nicklas |
22 |
|
11 |
13 Sep 07 |
nicklas |
23 |
import affymetrix.calvin.data.*; |
11 |
13 Sep 07 |
nicklas |
24 |
import affymetrix.calvin.parsers.*; |
11 |
13 Sep 07 |
nicklas |
25 |
import affymetrix.calvin.utils.*; |
11 |
13 Sep 07 |
nicklas |
26 |
import java.util.*; |
11 |
13 Sep 07 |
nicklas |
27 |
|
11 |
13 Sep 07 |
nicklas |
/** This class provides storage and reading capabilities for multi-data CHP files */ |
11 |
13 Sep 07 |
nicklas |
29 |
public class FusionCHPMultiDataData extends FusionCHPData { |
11 |
13 Sep 07 |
nicklas |
30 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a new instance of FusionCHPMultiDataData */ |
11 |
13 Sep 07 |
nicklas |
32 |
public FusionCHPMultiDataData() { |
11 |
13 Sep 07 |
nicklas |
33 |
chpData = null; |
11 |
13 Sep 07 |
nicklas |
34 |
} |
11 |
13 Sep 07 |
nicklas |
35 |
|
11 |
13 Sep 07 |
nicklas |
/** The chip object. */ |
11 |
13 Sep 07 |
nicklas |
37 |
private CHPMultiDataData chpData; |
11 |
13 Sep 07 |
nicklas |
38 |
|
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 |
41 |
*/ |
11 |
13 Sep 07 |
nicklas |
42 |
public AffymetrixGuidType getFileId() { |
11 |
13 Sep 07 |
nicklas |
43 |
return chpData.getGenericData().getFileIdentifier(); |
11 |
13 Sep 07 |
nicklas |
44 |
} |
11 |
13 Sep 07 |
nicklas |
45 |
|
11 |
13 Sep 07 |
nicklas |
/** Returns the GenericData object associated with a Calvin file, NULL for GCOS files. */ |
11 |
13 Sep 07 |
nicklas |
47 |
public GenericData getGenericData() { return chpData.getGenericData(); } |
11 |
13 Sep 07 |
nicklas |
48 |
|
11 |
13 Sep 07 |
nicklas |
/** The data set information */ |
11 |
13 Sep 07 |
nicklas |
50 |
public HashMap /*MultiDataType, DataSetInfo*/ getDataSetInfo() { return chpData.getDataSetInfo(); } |
11 |
13 Sep 07 |
nicklas |
51 |
|
11 |
13 Sep 07 |
nicklas |
/** The maximum length of a probe set name. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @return The maximum probe set name length |
11 |
13 Sep 07 |
nicklas |
55 |
*/ |
11 |
13 Sep 07 |
nicklas |
56 |
public int getMaxProbeSetName(MultiDataType dataType) { return chpData.getMaxProbesetName(dataType); } |
11 |
13 Sep 07 |
nicklas |
57 |
|
11 |
13 Sep 07 |
nicklas |
/** Clears the members. */ |
11 |
13 Sep 07 |
nicklas |
59 |
public void clear() { chpData.clear(); } |
11 |
13 Sep 07 |
nicklas |
60 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the name of the algorithm. |
11 |
13 Sep 07 |
nicklas |
* @return The algorithm name. |
11 |
13 Sep 07 |
nicklas |
63 |
*/ |
11 |
13 Sep 07 |
nicklas |
64 |
public String getAlgName() { return chpData.getAlgName(); } |
11 |
13 Sep 07 |
nicklas |
65 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the algorithm version. |
11 |
13 Sep 07 |
nicklas |
* @return The version. |
11 |
13 Sep 07 |
nicklas |
68 |
*/ |
11 |
13 Sep 07 |
nicklas |
69 |
public String getAlgVersion() { return chpData.getAlgVersion(); } |
11 |
13 Sep 07 |
nicklas |
70 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the array type */ |
11 |
13 Sep 07 |
nicklas |
72 |
public String getArrayType() { return chpData.getArrayType(); } |
11 |
13 Sep 07 |
nicklas |
73 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the algorithm parameters |
11 |
13 Sep 07 |
nicklas |
* @return The algoirhtm parameters. |
11 |
13 Sep 07 |
nicklas |
76 |
*/ |
11 |
13 Sep 07 |
nicklas |
77 |
public Vector /*ParameterNameValue*/ getAlgParams() { return chpData.getAlgParams(); } |
11 |
13 Sep 07 |
nicklas |
78 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the summary parameters |
11 |
13 Sep 07 |
nicklas |
* @return The summary parameters. |
11 |
13 Sep 07 |
nicklas |
81 |
*/ |
11 |
13 Sep 07 |
nicklas |
82 |
public Vector /*ParameterNameValue*/ getSummaryParams() { return chpData.getSummaryParams(); } |
11 |
13 Sep 07 |
nicklas |
83 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the number of entries (probe sets) |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
86 |
*/ |
11 |
13 Sep 07 |
nicklas |
87 |
public int getEntryCount(MultiDataType dataType) { return chpData.getEntryCount(dataType); } |
11 |
13 Sep 07 |
nicklas |
88 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the data for the given row. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param index The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The entry. |
11 |
13 Sep 07 |
nicklas |
93 |
*/ |
11 |
13 Sep 07 |
nicklas |
94 |
public ProbeSetMultiDataGenotypeData getGenotypeEntry(MultiDataType dataType, int index) { |
11 |
13 Sep 07 |
nicklas |
95 |
return chpData.getGenotypeEntry(dataType, index); |
11 |
13 Sep 07 |
nicklas |
96 |
} |
11 |
13 Sep 07 |
nicklas |
97 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the probe set data. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param index The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The expression results. |
11 |
13 Sep 07 |
nicklas |
102 |
*/ |
11 |
13 Sep 07 |
nicklas |
103 |
public ProbeSetMultiDataExpressionData getExpressionEntry(MultiDataType dataType, int index) { |
11 |
13 Sep 07 |
nicklas |
104 |
return chpData.getExpressionEntry(dataType, index); |
11 |
13 Sep 07 |
nicklas |
105 |
} |
11 |
13 Sep 07 |
nicklas |
106 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the call of the probe set. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param index The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The call. |
11 |
13 Sep 07 |
nicklas |
111 |
*/ |
11 |
13 Sep 07 |
nicklas |
112 |
public byte getGenoCall(MultiDataType dataType, int index) { |
11 |
13 Sep 07 |
nicklas |
113 |
return chpData.getGenoCall(dataType, index); |
11 |
13 Sep 07 |
nicklas |
114 |
} |
11 |
13 Sep 07 |
nicklas |
115 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the confidence in the call of the probe set. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param index The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The confidence. |
11 |
13 Sep 07 |
nicklas |
120 |
*/ |
11 |
13 Sep 07 |
nicklas |
121 |
public float getGenoConfidence(MultiDataType dataType, int index) { |
11 |
13 Sep 07 |
nicklas |
122 |
return chpData.getGenoConfidence(dataType, index); |
11 |
13 Sep 07 |
nicklas |
123 |
} |
11 |
13 Sep 07 |
nicklas |
124 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the quantification of the probe set. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param index The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The quantification. |
11 |
13 Sep 07 |
nicklas |
129 |
*/ |
11 |
13 Sep 07 |
nicklas |
130 |
public float getExpressionQuantification(MultiDataType dataType, int index) { |
11 |
13 Sep 07 |
nicklas |
131 |
return chpData.getExpressionQuantification(dataType, index); |
11 |
13 Sep 07 |
nicklas |
132 |
} |
11 |
13 Sep 07 |
nicklas |
133 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the probe set name. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param index The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The probe set name. |
11 |
13 Sep 07 |
nicklas |
138 |
*/ |
11 |
13 Sep 07 |
nicklas |
139 |
public String getProbeSetName(MultiDataType dataType, int index) { |
11 |
13 Sep 07 |
nicklas |
140 |
return chpData.getProbeSetName(dataType, index); |
11 |
13 Sep 07 |
nicklas |
141 |
} |
11 |
13 Sep 07 |
nicklas |
142 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the length of the metric columns. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param col The column index (of the metric columns) |
11 |
13 Sep 07 |
nicklas |
* @return The length. |
11 |
13 Sep 07 |
nicklas |
147 |
*/ |
11 |
13 Sep 07 |
nicklas |
148 |
public int getMetricColumnLength(MultiDataType dataType, int col) { |
11 |
13 Sep 07 |
nicklas |
149 |
return chpData.getMetricColumnLength(dataType, col); |
11 |
13 Sep 07 |
nicklas |
150 |
} |
11 |
13 Sep 07 |
nicklas |
151 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the length of the metric columns. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @return The number of columns. |
11 |
13 Sep 07 |
nicklas |
155 |
*/ |
11 |
13 Sep 07 |
nicklas |
156 |
public int getNumMetricColumns(MultiDataType dataType) { return chpData.getNumMetricColumns(dataType); } |
11 |
13 Sep 07 |
nicklas |
157 |
|
11 |
13 Sep 07 |
nicklas |
/** Get the metric column name. |
11 |
13 Sep 07 |
nicklas |
* @param dataType The data type |
11 |
13 Sep 07 |
nicklas |
* @param colIndex the metric column index |
11 |
13 Sep 07 |
nicklas |
* @return The column name |
11 |
13 Sep 07 |
nicklas |
162 |
*/ |
11 |
13 Sep 07 |
nicklas |
163 |
public String getMetricColumnName(MultiDataType dataType, int colIndex) { return chpData.getMetricColumnName(dataType, colIndex); } |
11 |
13 Sep 07 |
nicklas |
164 |
|
11 |
13 Sep 07 |
nicklas |
/** Reads the CHP file. |
11 |
13 Sep 07 |
nicklas |
* @return True if successful. |
11 |
13 Sep 07 |
nicklas |
167 |
*/ |
11 |
13 Sep 07 |
nicklas |
168 |
protected boolean read() { |
11 |
13 Sep 07 |
nicklas |
169 |
CHPMultiDataFileReader reader = new CHPMultiDataFileReader(); |
11 |
13 Sep 07 |
nicklas |
170 |
chpData = new CHPMultiDataData(); |
11 |
13 Sep 07 |
nicklas |
171 |
reader.setFilename(filename); |
11 |
13 Sep 07 |
nicklas |
172 |
try |
11 |
13 Sep 07 |
nicklas |
173 |
{ |
11 |
13 Sep 07 |
nicklas |
174 |
reader.read(chpData); |
11 |
13 Sep 07 |
nicklas |
175 |
return true; |
11 |
13 Sep 07 |
nicklas |
176 |
} |
11 |
13 Sep 07 |
nicklas |
177 |
catch(Throwable t) |
11 |
13 Sep 07 |
nicklas |
178 |
{ |
11 |
13 Sep 07 |
nicklas |
179 |
return false; |
11 |
13 Sep 07 |
nicklas |
180 |
} |
11 |
13 Sep 07 |
nicklas |
181 |
} |
11 |
13 Sep 07 |
nicklas |
182 |
|
11 |
13 Sep 07 |
nicklas |
/** Reads the header of the CHP file |
11 |
13 Sep 07 |
nicklas |
* @return True if successful |
11 |
13 Sep 07 |
nicklas |
185 |
*/ |
11 |
13 Sep 07 |
nicklas |
186 |
protected boolean readHeader() { return read(); } |
11 |
13 Sep 07 |
nicklas |
187 |
|
11 |
13 Sep 07 |
nicklas |
/** A class to register the multi-data CHP reader. */ |
11 |
13 Sep 07 |
nicklas |
189 |
private static class Reg extends FusionCHPDataReg |
11 |
13 Sep 07 |
nicklas |
190 |
{ |
11 |
13 Sep 07 |
nicklas |
/** Constructor - register the multi-data file type. */ |
11 |
13 Sep 07 |
nicklas |
192 |
public Reg() { |
11 |
13 Sep 07 |
nicklas |
193 |
super(); |
11 |
13 Sep 07 |
nicklas |
194 |
Vector ids = new Vector(); |
11 |
13 Sep 07 |
nicklas |
195 |
AffymetrixGuidType guid = new AffymetrixGuidType(); |
11 |
13 Sep 07 |
nicklas |
196 |
guid.setGuid(CHPMultiDataData.CHP_MULTI_DATA_TYPE); |
11 |
13 Sep 07 |
nicklas |
197 |
ids.add(guid); |
11 |
13 Sep 07 |
nicklas |
198 |
setFileTypeIds(ids); |
11 |
13 Sep 07 |
nicklas |
199 |
} |
11 |
13 Sep 07 |
nicklas |
200 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a multi-data CHP object. |
11 |
13 Sep 07 |
nicklas |
* @return The multi-data CHP object. |
11 |
13 Sep 07 |
nicklas |
203 |
*/ |
11 |
13 Sep 07 |
nicklas |
204 |
public FusionCHPData makeObject() { return new FusionCHPMultiDataData(); } |
11 |
13 Sep 07 |
nicklas |
205 |
}; |
11 |
13 Sep 07 |
nicklas |
206 |
|
11 |
13 Sep 07 |
nicklas |
/** The one and only registration object. This registers the class as a CHP reader. */ |
11 |
13 Sep 07 |
nicklas |
208 |
private static Reg reg = null; |
11 |
13 Sep 07 |
nicklas |
209 |
|
11 |
13 Sep 07 |
nicklas |
/** Register the reader with the system. */ |
11 |
13 Sep 07 |
nicklas |
211 |
public static void registerReader() { |
11 |
13 Sep 07 |
nicklas |
212 |
if (FusionCHPMultiDataData.reg == null) |
11 |
13 Sep 07 |
nicklas |
213 |
FusionCHPMultiDataData.reg = new Reg(); |
11 |
13 Sep 07 |
nicklas |
214 |
} |
11 |
13 Sep 07 |
nicklas |
215 |
|
11 |
13 Sep 07 |
nicklas |
/** Converts the type to the multi-data CHP type. |
11 |
13 Sep 07 |
nicklas |
* @param chip The pointer to the CHP data object. |
11 |
13 Sep 07 |
nicklas |
* @return The multi-data CHP data type or NULL if not compatible. |
11 |
13 Sep 07 |
nicklas |
219 |
*/ |
11 |
13 Sep 07 |
nicklas |
220 |
public static FusionCHPMultiDataData fromBase(FusionCHPData chip) { |
11 |
13 Sep 07 |
nicklas |
221 |
if (chip == null) |
11 |
13 Sep 07 |
nicklas |
222 |
return null; |
11 |
13 Sep 07 |
nicklas |
223 |
String chipName = chip.getClass().getName(); |
11 |
13 Sep 07 |
nicklas |
224 |
String genName = FusionCHPMultiDataData.class.getName(); |
11 |
13 Sep 07 |
nicklas |
225 |
if (chipName.compareTo(genName) == 0) |
11 |
13 Sep 07 |
nicklas |
226 |
return (FusionCHPMultiDataData) chip; |
11 |
13 Sep 07 |
nicklas |
227 |
return null; |
11 |
13 Sep 07 |
nicklas |
228 |
} |
11 |
13 Sep 07 |
nicklas |
229 |
|
11 |
13 Sep 07 |
nicklas |
230 |
} |