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 |
|
11 |
13 Sep 07 |
nicklas |
22 |
package affymetrix.gcos.cdf; |
11 |
13 Sep 07 |
nicklas |
23 |
|
11 |
13 Sep 07 |
nicklas |
24 |
import affymetrix.gcos.*; |
11 |
13 Sep 07 |
nicklas |
25 |
import affymetrix.portability.*; |
11 |
13 Sep 07 |
nicklas |
26 |
import java.util.*; |
11 |
13 Sep 07 |
nicklas |
27 |
import java.io.*; |
11 |
13 Sep 07 |
nicklas |
28 |
import java.nio.channels.*; |
11 |
13 Sep 07 |
nicklas |
29 |
import java.nio.channels.FileChannel.*; |
11 |
13 Sep 07 |
nicklas |
30 |
import java.nio.*; |
11 |
13 Sep 07 |
nicklas |
31 |
|
11 |
13 Sep 07 |
nicklas |
/** This class provides storage for a group of probes, also known as a block. */ |
11 |
13 Sep 07 |
nicklas |
33 |
public class CDFProbeGroupInformation { |
11 |
13 Sep 07 |
nicklas |
34 |
|
11 |
13 Sep 07 |
nicklas |
/** This is the size of the object in a binary CDF file. */ |
11 |
13 Sep 07 |
nicklas |
36 |
public static final int PROBE_GROUP_SIZE = (CDFProbeSetNames.MAX_PROBE_SET_NAME_LENGTH+4+4+4+4+1+1); |
11 |
13 Sep 07 |
nicklas |
37 |
|
11 |
13 Sep 07 |
nicklas |
/** The number of probe pairs or probe quartets in the group. */ |
11 |
13 Sep 07 |
nicklas |
39 |
private int numLists; |
11 |
13 Sep 07 |
nicklas |
40 |
|
11 |
13 Sep 07 |
nicklas |
41 |
public int getNumLists() { return numLists; } |
11 |
13 Sep 07 |
nicklas |
42 |
public void setNumLists(int value) { numLists = value; } |
11 |
13 Sep 07 |
nicklas |
43 |
|
11 |
13 Sep 07 |
nicklas |
/** The number of probes in the group. */ |
11 |
13 Sep 07 |
nicklas |
45 |
private int numCells; |
11 |
13 Sep 07 |
nicklas |
46 |
|
11 |
13 Sep 07 |
nicklas |
47 |
public int getNumCells() { return numCells; } |
11 |
13 Sep 07 |
nicklas |
48 |
public void setNumCells(int value) { numCells = value; } |
11 |
13 Sep 07 |
nicklas |
49 |
|
11 |
13 Sep 07 |
nicklas |
/** The first probes list index value. */ |
11 |
13 Sep 07 |
nicklas |
51 |
private int start; |
11 |
13 Sep 07 |
nicklas |
52 |
|
11 |
13 Sep 07 |
nicklas |
53 |
public int getStart() { return start; } |
11 |
13 Sep 07 |
nicklas |
54 |
public void setStart(int value) { start = value; } |
11 |
13 Sep 07 |
nicklas |
55 |
|
11 |
13 Sep 07 |
nicklas |
/** The last probes list index value. */ |
11 |
13 Sep 07 |
nicklas |
57 |
private int stop; |
11 |
13 Sep 07 |
nicklas |
58 |
|
11 |
13 Sep 07 |
nicklas |
59 |
public int getStop() { return stop; } |
11 |
13 Sep 07 |
nicklas |
60 |
public void setStop(int value) { stop = value; } |
11 |
13 Sep 07 |
nicklas |
61 |
|
11 |
13 Sep 07 |
nicklas |
/** The probe set index associated with the group. */ |
11 |
13 Sep 07 |
nicklas |
63 |
private int probeSetIndex; |
11 |
13 Sep 07 |
nicklas |
64 |
|
11 |
13 Sep 07 |
nicklas |
65 |
public int getProbeSetIndex() { return probeSetIndex; } |
11 |
13 Sep 07 |
nicklas |
66 |
public void setProbeSetIndex(int value) { probeSetIndex = value; } |
11 |
13 Sep 07 |
nicklas |
67 |
|
11 |
13 Sep 07 |
nicklas |
/** The group index. */ |
11 |
13 Sep 07 |
nicklas |
69 |
private int groupIndex; |
11 |
13 Sep 07 |
nicklas |
70 |
|
11 |
13 Sep 07 |
nicklas |
71 |
public int getGroupIndex() { return groupIndex; } |
11 |
13 Sep 07 |
nicklas |
72 |
public void setGroupIndex(int value) { groupIndex = value; } |
11 |
13 Sep 07 |
nicklas |
73 |
|
11 |
13 Sep 07 |
nicklas |
/** The name of the group. */ |
11 |
13 Sep 07 |
nicklas |
75 |
private String name; |
11 |
13 Sep 07 |
nicklas |
76 |
|
11 |
13 Sep 07 |
nicklas |
77 |
public String getName() { return name; } |
11 |
13 Sep 07 |
nicklas |
78 |
public void setName(String value) { name = value; } |
11 |
13 Sep 07 |
nicklas |
79 |
|
11 |
13 Sep 07 |
nicklas |
/** The number of cells per list (2 for expression and genotyping, 4 for resquencing). */ |
11 |
13 Sep 07 |
nicklas |
81 |
private byte numCellsPerList; |
11 |
13 Sep 07 |
nicklas |
82 |
|
11 |
13 Sep 07 |
nicklas |
83 |
public byte getNumCellsPerList() { return numCellsPerList; } |
11 |
13 Sep 07 |
nicklas |
84 |
public void setNumCellsPerList(byte value) { numCellsPerList = value; } |
11 |
13 Sep 07 |
nicklas |
85 |
|
11 |
13 Sep 07 |
nicklas |
/** The direction of the target that the probes are interrogating. */ |
11 |
13 Sep 07 |
nicklas |
87 |
private byte direction; |
11 |
13 Sep 07 |
nicklas |
88 |
|
11 |
13 Sep 07 |
nicklas |
89 |
public byte getDirection() { return direction; } |
11 |
13 Sep 07 |
nicklas |
90 |
public void setDirection(byte value) { direction = value; } |
11 |
13 Sep 07 |
nicklas |
91 |
|
11 |
13 Sep 07 |
nicklas |
/** The probes in the group */ |
13 |
14 Sep 07 |
nicklas |
93 |
private List<CDFProbeInformation> cells; |
11 |
13 Sep 07 |
nicklas |
94 |
|
11 |
13 Sep 07 |
nicklas |
/** A mapped byte buffer for XDA files. */ |
11 |
13 Sep 07 |
nicklas |
96 |
private MappedByteBuffer xdaBuffer; |
11 |
13 Sep 07 |
nicklas |
97 |
|
11 |
13 Sep 07 |
nicklas |
/** The offset from the map buffer to the probe set information. */ |
11 |
13 Sep 07 |
nicklas |
99 |
private int offset; |
11 |
13 Sep 07 |
nicklas |
100 |
|
11 |
13 Sep 07 |
nicklas |
/** Sets the map and offset for memory mapping. |
11 |
13 Sep 07 |
nicklas |
* @param buf The buffer. |
11 |
13 Sep 07 |
nicklas |
* @param o The offset to the probe set names. |
11 |
13 Sep 07 |
nicklas |
104 |
*/ |
11 |
13 Sep 07 |
nicklas |
105 |
public void setMap(MappedByteBuffer buf, long o, int setIndex, int index) |
11 |
13 Sep 07 |
nicklas |
106 |
{ |
11 |
13 Sep 07 |
nicklas |
107 |
xdaBuffer = buf; |
11 |
13 Sep 07 |
nicklas |
108 |
offset = (int)o; |
11 |
13 Sep 07 |
nicklas |
109 |
|
11 |
13 Sep 07 |
nicklas |
110 |
int groupOffset = offset; |
11 |
13 Sep 07 |
nicklas |
111 |
|
11 |
13 Sep 07 |
nicklas |
112 |
probeSetIndex = setIndex; |
11 |
13 Sep 07 |
nicklas |
113 |
groupIndex = index; |
11 |
13 Sep 07 |
nicklas |
114 |
|
11 |
13 Sep 07 |
nicklas |
115 |
numLists = FileIO.MmGetInt32_I(xdaBuffer, groupOffset); |
11 |
13 Sep 07 |
nicklas |
116 |
groupOffset += DataSizes.INT_SIZE; |
11 |
13 Sep 07 |
nicklas |
117 |
|
11 |
13 Sep 07 |
nicklas |
118 |
numCells = FileIO.MmGetInt32_I(xdaBuffer, groupOffset); |
11 |
13 Sep 07 |
nicklas |
119 |
groupOffset += DataSizes.INT_SIZE; |
11 |
13 Sep 07 |
nicklas |
120 |
|
11 |
13 Sep 07 |
nicklas |
121 |
numCellsPerList = FileIO.MmGetUInt8(xdaBuffer, groupOffset); |
11 |
13 Sep 07 |
nicklas |
122 |
groupOffset += DataSizes.CHAR_SIZE; |
11 |
13 Sep 07 |
nicklas |
123 |
|
11 |
13 Sep 07 |
nicklas |
124 |
direction = FileIO.MmGetUInt8(xdaBuffer, groupOffset); |
11 |
13 Sep 07 |
nicklas |
125 |
groupOffset += DataSizes.CHAR_SIZE; |
11 |
13 Sep 07 |
nicklas |
126 |
|
11 |
13 Sep 07 |
nicklas |
127 |
start = FileIO.MmGetInt32_I(xdaBuffer, groupOffset); |
11 |
13 Sep 07 |
nicklas |
128 |
groupOffset += DataSizes.INT_SIZE; |
11 |
13 Sep 07 |
nicklas |
129 |
|
11 |
13 Sep 07 |
nicklas |
130 |
stop = FileIO.MmGetInt32_I(xdaBuffer, groupOffset); |
11 |
13 Sep 07 |
nicklas |
131 |
groupOffset += DataSizes.INT_SIZE; |
11 |
13 Sep 07 |
nicklas |
132 |
|
11 |
13 Sep 07 |
nicklas |
133 |
name = FileIO.MmGetFixedString_I(xdaBuffer, groupOffset, CDFProbeSetNames.MAX_PROBE_SET_NAME_LENGTH); |
11 |
13 Sep 07 |
nicklas |
134 |
|
11 |
13 Sep 07 |
nicklas |
// Reset the start/stop |
11 |
13 Sep 07 |
nicklas |
136 |
CDFProbeInformation probeInfo; |
11 |
13 Sep 07 |
nicklas |
137 |
probeInfo = getCell(0); |
11 |
13 Sep 07 |
nicklas |
138 |
start = probeInfo.getListIndex(); |
11 |
13 Sep 07 |
nicklas |
139 |
probeInfo = getCell(numCells-1); |
11 |
13 Sep 07 |
nicklas |
140 |
stop = probeInfo.getListIndex(); |
11 |
13 Sep 07 |
nicklas |
141 |
} |
11 |
13 Sep 07 |
nicklas |
142 |
|
11 |
13 Sep 07 |
nicklas |
/** Gets the cell information for the given cell index. |
11 |
13 Sep 07 |
nicklas |
* @param index The zero based index to the cell array. |
11 |
13 Sep 07 |
nicklas |
* @return The cell or probe information. |
11 |
13 Sep 07 |
nicklas |
146 |
*/ |
11 |
13 Sep 07 |
nicklas |
147 |
public CDFProbeInformation getCell(int index) { |
11 |
13 Sep 07 |
nicklas |
148 |
if (cells != null) |
13 |
14 Sep 07 |
nicklas |
149 |
return cells.get(index); |
11 |
13 Sep 07 |
nicklas |
150 |
else if (xdaBuffer != null) |
11 |
13 Sep 07 |
nicklas |
151 |
{ |
11 |
13 Sep 07 |
nicklas |
152 |
CDFProbeInformation info = new CDFProbeInformation(); |
11 |
13 Sep 07 |
nicklas |
153 |
int cellOffset = offset + PROBE_GROUP_SIZE + (index * CDFProbeInformation.PROBE_SIZE); |
11 |
13 Sep 07 |
nicklas |
154 |
|
11 |
13 Sep 07 |
nicklas |
155 |
info.setListIndex(FileIO.MmGetInt32_I(xdaBuffer, cellOffset)); |
11 |
13 Sep 07 |
nicklas |
156 |
cellOffset += DataSizes.INT_SIZE; |
11 |
13 Sep 07 |
nicklas |
157 |
|
11 |
13 Sep 07 |
nicklas |
158 |
info.setX(FileIO.MmGetUInt16_I(xdaBuffer, cellOffset)); |
11 |
13 Sep 07 |
nicklas |
159 |
cellOffset += DataSizes.SHORT_SIZE; |
11 |
13 Sep 07 |
nicklas |
160 |
|
11 |
13 Sep 07 |
nicklas |
161 |
info.setY(FileIO.MmGetUInt16_I(xdaBuffer, cellOffset)); |
11 |
13 Sep 07 |
nicklas |
162 |
cellOffset += DataSizes.SHORT_SIZE; |
11 |
13 Sep 07 |
nicklas |
163 |
|
11 |
13 Sep 07 |
nicklas |
164 |
info.setExpos(FileIO.MmGetInt32_I(xdaBuffer, cellOffset)); |
11 |
13 Sep 07 |
nicklas |
165 |
cellOffset += DataSizes.INT_SIZE; |
11 |
13 Sep 07 |
nicklas |
166 |
|
11 |
13 Sep 07 |
nicklas |
167 |
info.setPBase((char)FileIO.MmGetInt8(xdaBuffer, cellOffset)); |
11 |
13 Sep 07 |
nicklas |
168 |
cellOffset += DataSizes.CHAR_SIZE; |
11 |
13 Sep 07 |
nicklas |
169 |
|
11 |
13 Sep 07 |
nicklas |
170 |
info.setTBase((char)FileIO.MmGetInt8(xdaBuffer, cellOffset)); |
11 |
13 Sep 07 |
nicklas |
171 |
|
11 |
13 Sep 07 |
nicklas |
172 |
return info; |
11 |
13 Sep 07 |
nicklas |
173 |
} |
11 |
13 Sep 07 |
nicklas |
174 |
return null; |
11 |
13 Sep 07 |
nicklas |
175 |
} |
13 |
14 Sep 07 |
nicklas |
176 |
public void setCells(List<CDFProbeInformation> value) { cells = value; } |
11 |
13 Sep 07 |
nicklas |
177 |
|
11 |
13 Sep 07 |
nicklas |
/** Creates a new instance of CDFProbeGroupInformation */ |
11 |
13 Sep 07 |
nicklas |
179 |
public CDFProbeGroupInformation() { |
11 |
13 Sep 07 |
nicklas |
180 |
cells = null; |
11 |
13 Sep 07 |
nicklas |
181 |
numLists = 0; |
11 |
13 Sep 07 |
nicklas |
182 |
numCells = 0; |
11 |
13 Sep 07 |
nicklas |
183 |
start = 0; |
11 |
13 Sep 07 |
nicklas |
184 |
stop = 0; |
11 |
13 Sep 07 |
nicklas |
185 |
probeSetIndex = 0; |
11 |
13 Sep 07 |
nicklas |
186 |
groupIndex = 0; |
11 |
13 Sep 07 |
nicklas |
187 |
name = ""; |
11 |
13 Sep 07 |
nicklas |
188 |
numCellsPerList = 0; |
11 |
13 Sep 07 |
nicklas |
189 |
direction = DirectionType.NoDirection; |
11 |
13 Sep 07 |
nicklas |
190 |
xdaBuffer = null; |
11 |
13 Sep 07 |
nicklas |
191 |
offset = 0; |
11 |
13 Sep 07 |
nicklas |
192 |
} |
11 |
13 Sep 07 |
nicklas |
193 |
|
11 |
13 Sep 07 |
nicklas |
194 |
} |