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.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 tiling CHP files */ |
11 |
13 Sep 07 |
nicklas |
29 |
public class FusionCHPTilingData extends FusionCHPData { |
11 |
13 Sep 07 |
nicklas |
30 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a new instance of FusionCHPTilingData */ |
11 |
13 Sep 07 |
nicklas |
32 |
private FusionCHPTilingData() { |
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 CHP object. */ |
11 |
13 Sep 07 |
nicklas |
37 |
private CHPTilingData chpData; |
11 |
13 Sep 07 |
nicklas |
38 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the number of sequence stored in the file. |
11 |
13 Sep 07 |
nicklas |
* @return The number of sequence stored in the file. |
11 |
13 Sep 07 |
nicklas |
41 |
*/ |
11 |
13 Sep 07 |
nicklas |
42 |
public int getNumberSequences() { return chpData.getNumberSequences(); } |
11 |
13 Sep 07 |
nicklas |
43 |
|
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 |
46 |
*/ |
11 |
13 Sep 07 |
nicklas |
47 |
public String getAlgName() { return chpData.getAlgName(); } |
11 |
13 Sep 07 |
nicklas |
48 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the algorithm version. |
11 |
13 Sep 07 |
nicklas |
* @return The version. |
11 |
13 Sep 07 |
nicklas |
51 |
*/ |
11 |
13 Sep 07 |
nicklas |
52 |
public String getAlgVersion() { return chpData.getAlgVersion(); } |
11 |
13 Sep 07 |
nicklas |
53 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the algorithm parameters |
11 |
13 Sep 07 |
nicklas |
* @return The algoirhtm parameters. |
11 |
13 Sep 07 |
nicklas |
56 |
*/ |
11 |
13 Sep 07 |
nicklas |
57 |
public Vector /*ParameterNameValue*/ getAlgParams() { return chpData.getAlgParams(); } |
11 |
13 Sep 07 |
nicklas |
58 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the sequence data. |
11 |
13 Sep 07 |
nicklas |
* @return The data associated with the sequence. |
11 |
13 Sep 07 |
nicklas |
61 |
*/ |
11 |
13 Sep 07 |
nicklas |
62 |
public TilingSequenceData getTilingSequenceData() { return chpData.getTilingSequenceData(); } |
11 |
13 Sep 07 |
nicklas |
63 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the number of entries in a tiling sequence. |
11 |
13 Sep 07 |
nicklas |
* @param index The sequence index. |
11 |
13 Sep 07 |
nicklas |
* @return The number of entries in the sequence. |
11 |
13 Sep 07 |
nicklas |
67 |
*/ |
11 |
13 Sep 07 |
nicklas |
68 |
public int getTilingSequenceEntryCount(int index) { return chpData.getTilingSequenceEntryCount(index); } |
11 |
13 Sep 07 |
nicklas |
69 |
|
11 |
13 Sep 07 |
nicklas |
/** Opens a group for reading. |
11 |
13 Sep 07 |
nicklas |
* @param index The index to the sequence. |
11 |
13 Sep 07 |
nicklas |
72 |
*/ |
11 |
13 Sep 07 |
nicklas |
73 |
public void openTilingSequenceDataSet(int index) { chpData.openTilingSequenceDataSet(index); } |
11 |
13 Sep 07 |
nicklas |
74 |
|
11 |
13 Sep 07 |
nicklas |
/** Returns the entry for the given row. The data set must be open. |
11 |
13 Sep 07 |
nicklas |
* @param row The row index. |
11 |
13 Sep 07 |
nicklas |
* @return The entry. |
11 |
13 Sep 07 |
nicklas |
78 |
*/ |
11 |
13 Sep 07 |
nicklas |
79 |
public CHPTilingEntry getTilingSequenceEntry(int row) { return chpData.getTilingSequenceEntry(row); } |
11 |
13 Sep 07 |
nicklas |
80 |
|
11 |
13 Sep 07 |
nicklas |
/** Reads the CHP file. |
11 |
13 Sep 07 |
nicklas |
* @return True if successful. |
11 |
13 Sep 07 |
nicklas |
83 |
*/ |
11 |
13 Sep 07 |
nicklas |
84 |
protected boolean read() { |
11 |
13 Sep 07 |
nicklas |
85 |
CHPTilingFileReader reader = new CHPTilingFileReader(); |
11 |
13 Sep 07 |
nicklas |
86 |
chpData = new CHPTilingData(); |
11 |
13 Sep 07 |
nicklas |
87 |
reader.setFilename(filename); |
11 |
13 Sep 07 |
nicklas |
88 |
try |
11 |
13 Sep 07 |
nicklas |
89 |
{ |
11 |
13 Sep 07 |
nicklas |
90 |
reader.read(chpData); |
11 |
13 Sep 07 |
nicklas |
91 |
return true; |
11 |
13 Sep 07 |
nicklas |
92 |
} |
11 |
13 Sep 07 |
nicklas |
93 |
catch(Throwable t) |
11 |
13 Sep 07 |
nicklas |
94 |
{ |
11 |
13 Sep 07 |
nicklas |
95 |
return false; |
11 |
13 Sep 07 |
nicklas |
96 |
} |
11 |
13 Sep 07 |
nicklas |
97 |
} |
11 |
13 Sep 07 |
nicklas |
98 |
|
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 |
101 |
*/ |
11 |
13 Sep 07 |
nicklas |
102 |
protected boolean readHeader() { return read(); } |
11 |
13 Sep 07 |
nicklas |
103 |
|
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 |
106 |
*/ |
11 |
13 Sep 07 |
nicklas |
107 |
public AffymetrixGuidType getFileId() { |
11 |
13 Sep 07 |
nicklas |
108 |
return chpData.getGenericData().getFileIdentifier(); |
11 |
13 Sep 07 |
nicklas |
109 |
} |
11 |
13 Sep 07 |
nicklas |
110 |
|
11 |
13 Sep 07 |
nicklas |
/** A class to register the tiling CHP reader. */ |
11 |
13 Sep 07 |
nicklas |
112 |
private static class Reg extends FusionCHPDataReg |
11 |
13 Sep 07 |
nicklas |
113 |
{ |
11 |
13 Sep 07 |
nicklas |
/** Constructor - register the tiling file type. */ |
11 |
13 Sep 07 |
nicklas |
115 |
public Reg() { |
11 |
13 Sep 07 |
nicklas |
116 |
super(); |
11 |
13 Sep 07 |
nicklas |
117 |
Vector ids = new Vector(); |
11 |
13 Sep 07 |
nicklas |
118 |
AffymetrixGuidType guid = new AffymetrixGuidType(); |
11 |
13 Sep 07 |
nicklas |
119 |
guid.setGuid(CHPTilingData.CHP_TILING_TYPE); |
11 |
13 Sep 07 |
nicklas |
120 |
ids.add(guid); |
11 |
13 Sep 07 |
nicklas |
121 |
setFileTypeIds(ids); |
11 |
13 Sep 07 |
nicklas |
122 |
} |
11 |
13 Sep 07 |
nicklas |
123 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a tiling CHP object. |
11 |
13 Sep 07 |
nicklas |
* @return The tiling CHP object. |
11 |
13 Sep 07 |
nicklas |
126 |
*/ |
11 |
13 Sep 07 |
nicklas |
127 |
public FusionCHPData makeObject() { return new FusionCHPTilingData(); } |
11 |
13 Sep 07 |
nicklas |
128 |
}; |
11 |
13 Sep 07 |
nicklas |
129 |
|
11 |
13 Sep 07 |
nicklas |
/** The one and only registration object. This registers the class as a CHP reader. */ |
11 |
13 Sep 07 |
nicklas |
131 |
private static Reg reg = null; |
11 |
13 Sep 07 |
nicklas |
132 |
|
11 |
13 Sep 07 |
nicklas |
/** Register the reader with the system. */ |
11 |
13 Sep 07 |
nicklas |
134 |
public static void registerReader() { |
11 |
13 Sep 07 |
nicklas |
135 |
if (FusionCHPTilingData.reg == null) |
11 |
13 Sep 07 |
nicklas |
136 |
FusionCHPTilingData.reg = new Reg(); |
11 |
13 Sep 07 |
nicklas |
137 |
} |
11 |
13 Sep 07 |
nicklas |
138 |
|
11 |
13 Sep 07 |
nicklas |
/** Converts the type to the tiling CHP type. |
11 |
13 Sep 07 |
nicklas |
* @param chip The pointer to the CHP data object. |
11 |
13 Sep 07 |
nicklas |
* @return The tiling CHP data type or NULL if not compatible. |
11 |
13 Sep 07 |
nicklas |
142 |
*/ |
11 |
13 Sep 07 |
nicklas |
143 |
public static FusionCHPTilingData fromBase(FusionCHPData chip) { |
11 |
13 Sep 07 |
nicklas |
144 |
if (chip == null) |
11 |
13 Sep 07 |
nicklas |
145 |
return null; |
11 |
13 Sep 07 |
nicklas |
146 |
String chipName = chip.getClass().getName(); |
11 |
13 Sep 07 |
nicklas |
147 |
String genName = FusionCHPTilingData.class.getName(); |
11 |
13 Sep 07 |
nicklas |
148 |
if (chipName.compareTo(genName) == 0) |
11 |
13 Sep 07 |
nicklas |
149 |
return (FusionCHPTilingData) chip; |
11 |
13 Sep 07 |
nicklas |
150 |
return null; |
11 |
13 Sep 07 |
nicklas |
151 |
} |
11 |
13 Sep 07 |
nicklas |
152 |
} |