affyfusion-109/src/affymetrix/fusion/chp/FusionCHPMultiDataData.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) 2006 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 
11 13 Sep 07 nicklas 7 // (version 2.1) as published by the Free Software Foundation.
11 13 Sep 07 nicklas 8 // 
11 13 Sep 07 nicklas 9 // This library is distributed in the hope that it will be useful, but
11 13 Sep 07 nicklas 10 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 13 Sep 07 nicklas 11 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 13 Sep 07 nicklas 12 // for more details.
11 13 Sep 07 nicklas 13 // 
11 13 Sep 07 nicklas 14 // You should have received a copy of the GNU Lesser General Public License
11 13 Sep 07 nicklas 15 // along with this library; if not, write to the Free Software Foundation, Inc.,
11 13 Sep 07 nicklas 16 // 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 28 /** 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 31     /** 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 36     /** The chip object. */
11 13 Sep 07 nicklas 37     private CHPMultiDataData chpData;
11 13 Sep 07 nicklas 38     
11 13 Sep 07 nicklas 39     /** Get the id of the file (only valid for Command Console "calvin" files)
11 13 Sep 07 nicklas 40      * @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 46     /** 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 49     /** 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 52     /** The maximum length of a probe set name.
11 13 Sep 07 nicklas 53      * @param dataType The data type
11 13 Sep 07 nicklas 54      * @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 58     /** 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 61     /** Gets the name of the algorithm.
11 13 Sep 07 nicklas 62      * @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 66     /** Gets the algorithm version.
11 13 Sep 07 nicklas 67      * @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 71     /** 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 74     /** Gets the algorithm parameters
11 13 Sep 07 nicklas 75      * @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 79     /** Gets the summary parameters
11 13 Sep 07 nicklas 80      * @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 84     /** Gets the number of entries (probe sets)
11 13 Sep 07 nicklas 85      * @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 89     /** Gets the data for the given row.
11 13 Sep 07 nicklas 90      * @param dataType The data type
11 13 Sep 07 nicklas 91      * @param index The row index.
11 13 Sep 07 nicklas 92      * @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 98     /** Gets the probe set data.
11 13 Sep 07 nicklas 99      * @param dataType The data type
11 13 Sep 07 nicklas 100      * @param index The row index.
11 13 Sep 07 nicklas 101      * @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 107     /** Gets the call of the probe set.
11 13 Sep 07 nicklas 108      * @param dataType The data type
11 13 Sep 07 nicklas 109      * @param index The row index.
11 13 Sep 07 nicklas 110      * @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 116     /** Gets the confidence in the call of the probe set.
11 13 Sep 07 nicklas 117      * @param dataType The data type
11 13 Sep 07 nicklas 118      * @param index The row index.
11 13 Sep 07 nicklas 119      * @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 125     /** Gets the quantification of the probe set.
11 13 Sep 07 nicklas 126      * @param dataType The data type
11 13 Sep 07 nicklas 127      * @param index The row index.
11 13 Sep 07 nicklas 128      * @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 134     /** Get the probe set name.
11 13 Sep 07 nicklas 135      * @param dataType The data type
11 13 Sep 07 nicklas 136      * @param index The row index.
11 13 Sep 07 nicklas 137      * @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 143     /** Get the length of the metric columns.
11 13 Sep 07 nicklas 144      * @param dataType The data type
11 13 Sep 07 nicklas 145      * @param col The column index (of the metric columns)
11 13 Sep 07 nicklas 146      * @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 152     /** Get the length of the metric columns.
11 13 Sep 07 nicklas 153      * @param dataType The data type
11 13 Sep 07 nicklas 154      * @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 158     /** Get the metric column name.
11 13 Sep 07 nicklas 159      * @param dataType The data type
11 13 Sep 07 nicklas 160      * @param colIndex the metric column index
11 13 Sep 07 nicklas 161      * @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 165     /** Reads the CHP file.
11 13 Sep 07 nicklas 166      * @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 183     /** Reads the header of the CHP file
11 13 Sep 07 nicklas 184      * @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 188     /** 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 191         /** 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 201         /** Creates a multi-data CHP object.
11 13 Sep 07 nicklas 202          * @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 207     /** 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 210     /** 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 216     /** Converts the type to the multi-data CHP type.
11 13 Sep 07 nicklas 217      * @param chip The pointer to the CHP data object.
11 13 Sep 07 nicklas 218      * @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 }