affyfusion-109/src/affymetrix/gcos/cdf/CDFProbeSetInformation.java

Code
Comments
Other
Rev Date Author Line
11 13 Sep 07 nicklas 1 /////////////////////////////////////////////////////////////////
11 13 Sep 07 nicklas 2 //
11 13 Sep 07 nicklas 3 // Copyright (C) 2005 Affymetrix, Inc.
11 13 Sep 07 nicklas 4 //
11 13 Sep 07 nicklas 5 // This library is free software; you can redistribute it and/or modify
11 13 Sep 07 nicklas 6 // it under the terms of the GNU Lesser General Public License as published
11 13 Sep 07 nicklas 7 // by the Free Software Foundation; either version 2.1 of the License,
11 13 Sep 07 nicklas 8 // or (at your option) any later version.
11 13 Sep 07 nicklas 9 //
11 13 Sep 07 nicklas 10 // This library is distributed in the hope that it will be useful, but
11 13 Sep 07 nicklas 11 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 13 Sep 07 nicklas 12 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 13 Sep 07 nicklas 13 // for more details.
11 13 Sep 07 nicklas 14 //
11 13 Sep 07 nicklas 15 // You should have received a copy of the GNU Lesser General Public License
11 13 Sep 07 nicklas 16 // along with this library; if not, write to the Free Software Foundation, Inc.,
11 13 Sep 07 nicklas 17 // 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.gcos.cdf;
11 13 Sep 07 nicklas 22
11 13 Sep 07 nicklas 23 import affymetrix.gcos.*;
11 13 Sep 07 nicklas 24 import affymetrix.portability.*;
11 13 Sep 07 nicklas 25 import java.util.*;
11 13 Sep 07 nicklas 26 import java.io.*;
11 13 Sep 07 nicklas 27 import java.nio.channels.*;
11 13 Sep 07 nicklas 28 import java.nio.channels.FileChannel.*;
11 13 Sep 07 nicklas 29 import java.nio.*;
11 13 Sep 07 nicklas 30
11 13 Sep 07 nicklas 31 /** This class provides storage for probe set information from a CDF file. */
11 13 Sep 07 nicklas 32 public class CDFProbeSetInformation {
11 13 Sep 07 nicklas 33
11 13 Sep 07 nicklas 34     /** The size of the probe set object in a XDA file. */
11 13 Sep 07 nicklas 35     public static final int PROBE_SET_SIZE = (4+4+4+4+2+1+1);
11 13 Sep 07 nicklas 36     
11 13 Sep 07 nicklas 37     /** The number of lists (atoms) in the probe set. */
11 13 Sep 07 nicklas 38     private int numLists;
11 13 Sep 07 nicklas 39
11 13 Sep 07 nicklas 40     public int getNumLists() { return numLists; }
11 13 Sep 07 nicklas 41     public void setNumLists(int value) { numLists = value; }
11 13 Sep 07 nicklas 42
11 13 Sep 07 nicklas 43     /** The number of groups (blocks) in the probe set. */
11 13 Sep 07 nicklas 44     private int numGroups;
11 13 Sep 07 nicklas 45
11 13 Sep 07 nicklas 46     public int getNumGroups() { return numGroups; }
11 13 Sep 07 nicklas 47     public void setNumGroups(int value) { numGroups = value; }
11 13 Sep 07 nicklas 48
11 13 Sep 07 nicklas 49     /** The number of probes in the set. */
11 13 Sep 07 nicklas 50     private int numCells;
11 13 Sep 07 nicklas 51
11 13 Sep 07 nicklas 52     public int getNumCells() { return numCells; }
11 13 Sep 07 nicklas 53     public void setNumCells(int value) { numCells = value; }
11 13 Sep 07 nicklas 54
11 13 Sep 07 nicklas 55     /** An index for the probe set.*/
11 13 Sep 07 nicklas 56     private int setIndex;
11 13 Sep 07 nicklas 57
11 13 Sep 07 nicklas 58     public int getIndex() { return setIndex; }
11 13 Sep 07 nicklas 59     public void setIndex(int value) { setIndex = value; }
11 13 Sep 07 nicklas 60
11 13 Sep 07 nicklas 61     /** An arbitrary number assigned to the probe set. */
11 13 Sep 07 nicklas 62     private int probeSetNumber;
11 13 Sep 07 nicklas 63
11 13 Sep 07 nicklas 64     public int getProbeSetNumber() { return probeSetNumber; }
11 13 Sep 07 nicklas 65     public void setProbeSetNumber(int value) { probeSetNumber = value; }
11 13 Sep 07 nicklas 66
11 13 Sep 07 nicklas 67     /** The type of probe set. */
11 13 Sep 07 nicklas 68     private short probeSetType;
11 13 Sep 07 nicklas 69
11 13 Sep 07 nicklas 70     public int getProbeSetType() { return (int)probeSetType; }
11 13 Sep 07 nicklas 71     public void setProbeSetType(int value) { probeSetType = (short)value; }
11 13 Sep 07 nicklas 72
11 13 Sep 07 nicklas 73     /** The direction of the target that the probes are interrogating. */
11 13 Sep 07 nicklas 74     private byte direction;
11 13 Sep 07 nicklas 75
11 13 Sep 07 nicklas 76     public byte getDirection() { return direction; }
11 13 Sep 07 nicklas 77     public void setDirection(byte value) { direction = value; }
11 13 Sep 07 nicklas 78
11 13 Sep 07 nicklas 79     /** The number of probes per list. */
11 13 Sep 07 nicklas 80     private byte numCellsPerList;
11 13 Sep 07 nicklas 81
11 13 Sep 07 nicklas 82     public byte getNumCellsPerList() { return numCellsPerList; }
11 13 Sep 07 nicklas 83     public void setNumCellsPerList(byte value) { numCellsPerList = value; }
11 13 Sep 07 nicklas 84
11 13 Sep 07 nicklas 85     /** The groups in the set. */
13 14 Sep 07 nicklas 86     private List /*CDFProbeGroupInformation*/ groups;
11 13 Sep 07 nicklas 87
11 13 Sep 07 nicklas 88     /** A mapped byte buffer for XDA files. */
11 13 Sep 07 nicklas 89     private MappedByteBuffer xdaBuffer;
11 13 Sep 07 nicklas 90     
11 13 Sep 07 nicklas 91     /** The offset from the map buffer to the probe set information. */
11 13 Sep 07 nicklas 92     private int offset;
11 13 Sep 07 nicklas 93     
11 13 Sep 07 nicklas 94     /** Gets the group at the given index.
11 13 Sep 07 nicklas 95      * @param index The zero based index to the group array.
11 13 Sep 07 nicklas 96      * @return The group information.
11 13 Sep 07 nicklas 97      */
11 13 Sep 07 nicklas 98     public CDFProbeGroupInformation getGroup(int index) {
11 13 Sep 07 nicklas 99         if (groups != null)
11 13 Sep 07 nicklas 100         {
13 14 Sep 07 nicklas 101             return (CDFProbeGroupInformation)groups.get(index);
11 13 Sep 07 nicklas 102         }
11 13 Sep 07 nicklas 103         else if (xdaBuffer != null)
11 13 Sep 07 nicklas 104         {
11 13 Sep 07 nicklas 105             CDFProbeGroupInformation group = new CDFProbeGroupInformation();
11 13 Sep 07 nicklas 106             int groupOffset = offset + CDFProbeSetInformation.PROBE_SET_SIZE;
11 13 Sep 07 nicklas 107             for (int i=0; i<index; i++)
11 13 Sep 07 nicklas 108             {
11 13 Sep 07 nicklas 109                 int cells = FileIO.MmGetInt32_I(xdaBuffer, groupOffset + DataSizes.INT_SIZE);
11 13 Sep 07 nicklas 110                 groupOffset += CDFProbeGroupInformation.PROBE_GROUP_SIZE;
11 13 Sep 07 nicklas 111                 groupOffset += (cells * CDFProbeInformation.PROBE_SIZE);
11 13 Sep 07 nicklas 112             }
11 13 Sep 07 nicklas 113             group.setMap(xdaBuffer, groupOffset, setIndex, index);                
11 13 Sep 07 nicklas 114             return group;
11 13 Sep 07 nicklas 115         }
11 13 Sep 07 nicklas 116         return null;
11 13 Sep 07 nicklas 117     }
13 14 Sep 07 nicklas 118     public void setGroups(List value) { groups = value; }
11 13 Sep 07 nicklas 119
11 13 Sep 07 nicklas 120     /** Sets the map and offset for memory mapping.
11 13 Sep 07 nicklas 121      * @param buf The buffer.
11 13 Sep 07 nicklas 122      * @param o The offset to the probe set names.
11 13 Sep 07 nicklas 123      */
11 13 Sep 07 nicklas 124     public void setMap(MappedByteBuffer buf, long o, int index)
11 13 Sep 07 nicklas 125     {
11 13 Sep 07 nicklas 126         xdaBuffer = buf;
11 13 Sep 07 nicklas 127         offset = (int)o;
11 13 Sep 07 nicklas 128         
11 13 Sep 07 nicklas 129         int setOffset = offset;
11 13 Sep 07 nicklas 130         
11 13 Sep 07 nicklas 131         setIndex = index;
11 13 Sep 07 nicklas 132         
11 13 Sep 07 nicklas 133         probeSetType = FileIO.MmGetUInt16_I(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 134         setOffset += DataSizes.SHORT_SIZE;
11 13 Sep 07 nicklas 135
11 13 Sep 07 nicklas 136         direction = FileIO.MmGetUInt8(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 137         setOffset += DataSizes.CHAR_SIZE;
11 13 Sep 07 nicklas 138
11 13 Sep 07 nicklas 139         numLists = FileIO.MmGetInt32_I(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 140         setOffset += DataSizes.INT_SIZE;
11 13 Sep 07 nicklas 141
11 13 Sep 07 nicklas 142         numGroups = FileIO.MmGetInt32_I(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 143         setOffset += DataSizes.INT_SIZE;
11 13 Sep 07 nicklas 144
11 13 Sep 07 nicklas 145         numCells = FileIO.MmGetInt32_I(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 146         setOffset += DataSizes.INT_SIZE;
11 13 Sep 07 nicklas 147
11 13 Sep 07 nicklas 148         probeSetNumber = FileIO.MmGetInt32_I(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 149         setOffset += DataSizes.INT_SIZE;
11 13 Sep 07 nicklas 150
11 13 Sep 07 nicklas 151         numCellsPerList = FileIO.MmGetUInt8(xdaBuffer, setOffset);
11 13 Sep 07 nicklas 152
11 13 Sep 07 nicklas 153     }
11 13 Sep 07 nicklas 154     
11 13 Sep 07 nicklas 155     /** Creates a new instance of CDFProbeSetInformation */
11 13 Sep 07 nicklas 156     public CDFProbeSetInformation() {
11 13 Sep 07 nicklas 157         groups = null;
11 13 Sep 07 nicklas 158         numLists = 0;
11 13 Sep 07 nicklas 159         numGroups = 0;
11 13 Sep 07 nicklas 160         numCells = 0;
11 13 Sep 07 nicklas 161         setIndex = 0;
11 13 Sep 07 nicklas 162         probeSetNumber = 0;
11 13 Sep 07 nicklas 163         probeSetType = GeneChipProbeSetType.UnknownProbeSetType;
11 13 Sep 07 nicklas 164         direction = DirectionType.NoDirection;
11 13 Sep 07 nicklas 165         xdaBuffer = null;
11 13 Sep 07 nicklas 166         offset = 0;
11 13 Sep 07 nicklas 167     }
11 13 Sep 07 nicklas 168     
11 13 Sep 07 nicklas 169 }