affyfusion-109/src/affymetrix/gcos/cdf/CDFQCProbeSetInformation.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.portability.*;
11 13 Sep 07 nicklas 24 import affymetrix.gcos.*;
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 the probes in a QC probe set. */
11 13 Sep 07 nicklas 32 public class CDFQCProbeSetInformation {
11 13 Sep 07 nicklas 33
11 13 Sep 07 nicklas 34     /** This is the size of the QC probe set object in a binary CDF file. */
11 13 Sep 07 nicklas 35     public static final int QC_PROBE_SET_SIZE = (4+2);
11 13 Sep 07 nicklas 36
11 13 Sep 07 nicklas 37     /** The number of probes in the set. */
11 13 Sep 07 nicklas 38     private int numCells;
11 13 Sep 07 nicklas 39     
11 13 Sep 07 nicklas 40     public int getNumCells() { return numCells; }
11 13 Sep 07 nicklas 41     public void setNumCells(int value) { numCells = value; }
11 13 Sep 07 nicklas 42
11 13 Sep 07 nicklas 43     /** The type of QC probes. */
11 13 Sep 07 nicklas 44     private short qcProbeSetType;
11 13 Sep 07 nicklas 45
11 13 Sep 07 nicklas 46     public short getQCProbeSetType() { return qcProbeSetType; }
11 13 Sep 07 nicklas 47     public void setQCProbeSetType(short value) { qcProbeSetType = value; }
11 13 Sep 07 nicklas 48
11 13 Sep 07 nicklas 49     /** The array of probes. */
13 14 Sep 07 nicklas 50     private List<CDFQCProbeInformation> cells;
11 13 Sep 07 nicklas 51     
11 13 Sep 07 nicklas 52     public CDFQCProbeInformation getCell(int index) {
11 13 Sep 07 nicklas 53         if (cells != null)
11 13 Sep 07 nicklas 54         {
13 14 Sep 07 nicklas 55             return cells.get(index);
11 13 Sep 07 nicklas 56         }
11 13 Sep 07 nicklas 57         else if (xdaBuffer != null)
11 13 Sep 07 nicklas 58         {
11 13 Sep 07 nicklas 59             CDFQCProbeInformation info = new CDFQCProbeInformation();
11 13 Sep 07 nicklas 60             int cellOffset = offset + QC_PROBE_SET_SIZE + (index * CDFQCProbeInformation.QC_PROBE_SIZE);
11 13 Sep 07 nicklas 61
11 13 Sep 07 nicklas 62             info.setX(FileIO.MmGetUInt16_I(xdaBuffer, cellOffset));
11 13 Sep 07 nicklas 63             cellOffset += DataSizes.SHORT_SIZE;
11 13 Sep 07 nicklas 64
11 13 Sep 07 nicklas 65             info.setY(FileIO.MmGetUInt16_I(xdaBuffer, cellOffset));
11 13 Sep 07 nicklas 66             cellOffset += DataSizes.SHORT_SIZE;
11 13 Sep 07 nicklas 67
11 13 Sep 07 nicklas 68             info.setProbeLength(FileIO.MmGetUInt8(xdaBuffer, cellOffset));
11 13 Sep 07 nicklas 69             cellOffset += DataSizes.CHAR_SIZE;
11 13 Sep 07 nicklas 70
11 13 Sep 07 nicklas 71             info.setPMProbe(FileIO.MmGetUInt8(xdaBuffer, cellOffset) == 1 ? true : false);
11 13 Sep 07 nicklas 72             cellOffset += DataSizes.CHAR_SIZE;
11 13 Sep 07 nicklas 73
11 13 Sep 07 nicklas 74             info.setBackground(FileIO.MmGetUInt8(xdaBuffer, cellOffset) == 1 ? true : false);
11 13 Sep 07 nicklas 75             return info;
11 13 Sep 07 nicklas 76         }
11 13 Sep 07 nicklas 77         return null;
11 13 Sep 07 nicklas 78     }
13 14 Sep 07 nicklas 79     public void setCells(List<CDFQCProbeInformation> value) { cells = value; }
11 13 Sep 07 nicklas 80
11 13 Sep 07 nicklas 81     /** A mapped byte buffer for XDA files. */
11 13 Sep 07 nicklas 82     private MappedByteBuffer xdaBuffer;
11 13 Sep 07 nicklas 83     
11 13 Sep 07 nicklas 84     /** The offset from the map buffer to the probe set information. */
11 13 Sep 07 nicklas 85     private int offset;
11 13 Sep 07 nicklas 86     
11 13 Sep 07 nicklas 87     /** Sets the map and offset for memory mapping.
11 13 Sep 07 nicklas 88      * @param buf The buffer.
11 13 Sep 07 nicklas 89      * @param o The offset to the probe set names.
11 13 Sep 07 nicklas 90      */
11 13 Sep 07 nicklas 91     public void setMap(MappedByteBuffer buf, long o)
11 13 Sep 07 nicklas 92     {
11 13 Sep 07 nicklas 93         xdaBuffer = buf;
11 13 Sep 07 nicklas 94         offset = (int) o;
11 13 Sep 07 nicklas 95         qcProbeSetType = FileIO.MmGetUInt16_I(xdaBuffer, offset);
11 13 Sep 07 nicklas 96   numCells = FileIO.MmGetInt32_I(xdaBuffer, offset + DataSizes.SHORT_SIZE);                
11 13 Sep 07 nicklas 97     }
11 13 Sep 07 nicklas 98
11 13 Sep 07 nicklas 99     /** Creates a new instance of CDFQCProbeSetInformation */
11 13 Sep 07 nicklas 100     public CDFQCProbeSetInformation() {
11 13 Sep 07 nicklas 101         cells = null;
11 13 Sep 07 nicklas 102         xdaBuffer = null;
11 13 Sep 07 nicklas 103         offset = 0;
11 13 Sep 07 nicklas 104         numCells = 0;
11 13 Sep 07 nicklas 105         qcProbeSetType = GeneChipQCProbeSetType.UnknownQCProbeSetType;
11 13 Sep 07 nicklas 106     }
11 13 Sep 07 nicklas 107     
11 13 Sep 07 nicklas 108 }