affyfusion-109/src/affymetrix/calvin/data/CHPMultiDataData.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 package affymetrix.calvin.data;
11 13 Sep 07 nicklas 21
11 13 Sep 07 nicklas 22 import java.util.*;
11 13 Sep 07 nicklas 23 import affymetrix.calvin.parameter.*;
11 13 Sep 07 nicklas 24
11 13 Sep 07 nicklas 25 /** Holds data associated with a multi-data CHP files. */
11 13 Sep 07 nicklas 26 public class CHPMultiDataData
11 13 Sep 07 nicklas 27 {
11 13 Sep 07 nicklas 28     /** The identifier to identify a multi-data CHP file. */
11 13 Sep 07 nicklas 29      public static final String CHP_MULTI_DATA_TYPE = "affymetrix-multi-data-type-analysis";
11 13 Sep 07 nicklas 30
11 13 Sep 07 nicklas 31     /** The group and data set to store the generic genotype data. */
11 13 Sep 07 nicklas 32     private static final String MULTI_DATA_NAME = "MultiData";
11 13 Sep 07 nicklas 33
11 13 Sep 07 nicklas 34     /** The column name for the probe set name. */
11 13 Sep 07 nicklas 35     private static final String PROBE_SET_NAME = "ProbeSetName";
11 13 Sep 07 nicklas 36
11 13 Sep 07 nicklas 37     /** The column name for the call. */
11 13 Sep 07 nicklas 38     private static final String GENOTYPE_CALL_NAME = "Call";
11 13 Sep 07 nicklas 39
11 13 Sep 07 nicklas 40     /** The column name for the confidence value. */
11 13 Sep 07 nicklas 41     private static final String GENOTYPE_CONFIDENCE_NAME = "Confidence";
11 13 Sep 07 nicklas 42
11 13 Sep 07 nicklas 43     /** The column name for the quantification value. */
11 13 Sep 07 nicklas 44     private static final String EXPRESSION_QUANTIFICATION_NAME = "Quantification";
11 13 Sep 07 nicklas 45
11 13 Sep 07 nicklas 46     /** Constructor */
11 13 Sep 07 nicklas 47     public CHPMultiDataData() {
11 13 Sep 07 nicklas 48         dataSetInfo = null;
11 13 Sep 07 nicklas 49   clear();
11 13 Sep 07 nicklas 50         genericData = new GenericData();
11 13 Sep 07 nicklas 51         dataSetInfo = new HashMap();
11 13 Sep 07 nicklas 52     }
11 13 Sep 07 nicklas 53
11 13 Sep 07 nicklas 54     /** Constructor with file name.
11 13 Sep 07 nicklas 55      * @param filename The name of the CHP file.
11 13 Sep 07 nicklas 56      */
11 13 Sep 07 nicklas 57     public CHPMultiDataData(String filename) {
11 13 Sep 07 nicklas 58         dataSetInfo = null;
11 13 Sep 07 nicklas 59   clear();
11 13 Sep 07 nicklas 60         genericData = new GenericData();
11 13 Sep 07 nicklas 61         dataSetInfo = new HashMap();
11 13 Sep 07 nicklas 62   setFilename(filename);
11 13 Sep 07 nicklas 63   DataGroupHeader dcHdr = new DataGroupHeader(MULTI_DATA_NAME);
11 13 Sep 07 nicklas 64   genericData.getHeader().addDataGroupHdr(dcHdr);
11 13 Sep 07 nicklas 65   genericData.getHeader().getGenericDataHdr().setFileTypeId(CHP_MULTI_DATA_TYPE);
11 13 Sep 07 nicklas 66     }
11 13 Sep 07 nicklas 67
11 13 Sep 07 nicklas 68     /** The generic data item. */
11 13 Sep 07 nicklas 69     private GenericData genericData;
11 13 Sep 07 nicklas 70     
11 13 Sep 07 nicklas 71     /** a map of chp data sets. */
11 13 Sep 07 nicklas 72     public HashMap/*MultiDataType, DataSetInfo*/ dataSetInfo;
11 13 Sep 07 nicklas 73     
11 13 Sep 07 nicklas 74     /** Get the data set information map */
11 13 Sep 07 nicklas 75     public HashMap getDataSetInfo() { return dataSetInfo; }
11 13 Sep 07 nicklas 76
11 13 Sep 07 nicklas 77     /** The maximum length of a probe set name.
11 13 Sep 07 nicklas 78      * @param dataType The data type
11 13 Sep 07 nicklas 79      */
11 13 Sep 07 nicklas 80     public int getMaxProbesetName(MultiDataType dataType) {
11 13 Sep 07 nicklas 81         DataSetInfo info = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 82         if (info != null)
11 13 Sep 07 nicklas 83             return info.maxProbeSetName;
11 13 Sep 07 nicklas 84   return 0;
11 13 Sep 07 nicklas 85     }
11 13 Sep 07 nicklas 86
11 13 Sep 07 nicklas 87     /** Clears the members. */
11 13 Sep 07 nicklas 88     public void clear() {
11 13 Sep 07 nicklas 89          if (dataSetInfo != null)
11 13 Sep 07 nicklas 90         {
11 13 Sep 07 nicklas 91             Set keys = dataSetInfo.keySet();
11 13 Sep 07 nicklas 92             Iterator it = keys.iterator();
11 13 Sep 07 nicklas 93             while (it.hasNext() == true)
11 13 Sep 07 nicklas 94             {
11 13 Sep 07 nicklas 95                 DataSetInfo info = (DataSetInfo)dataSetInfo.get(it.next());
11 13 Sep 07 nicklas 96                 if (info.entries != null)
11 13 Sep 07 nicklas 97                 {
11 13 Sep 07 nicklas 98                     info.entries.delete();
11 13 Sep 07 nicklas 99                     info.entries = null;
11 13 Sep 07 nicklas 100                     if (info.metricColumns != null)
11 13 Sep 07 nicklas 101                     {
11 13 Sep 07 nicklas 102                         info.metricColumns.clear();
11 13 Sep 07 nicklas 103                         info.metricColumns = null;
11 13 Sep 07 nicklas 104                     }
11 13 Sep 07 nicklas 105                 }
11 13 Sep 07 nicklas 106             }
11 13 Sep 07 nicklas 107             dataSetInfo.clear();
11 13 Sep 07 nicklas 108         }
11 13 Sep 07 nicklas 109   if (genericData != null)
11 13 Sep 07 nicklas 110             genericData.getHeader().clear();
11 13 Sep 07 nicklas 111     }
11 13 Sep 07 nicklas 112
11 13 Sep 07 nicklas 113     /** sets the file name.
11 13 Sep 07 nicklas 114      * @param p The name of the CHP file
11 13 Sep 07 nicklas 115      */
11 13 Sep 07 nicklas 116     public void setFilename(String p) {
11 13 Sep 07 nicklas 117         genericData.getHeader().setFilename(p);
11 13 Sep 07 nicklas 118     }
11 13 Sep 07 nicklas 119
11 13 Sep 07 nicklas 120     /** gets the file name.
11 13 Sep 07 nicklas 121      * @return The file name.
11 13 Sep 07 nicklas 122      */
11 13 Sep 07 nicklas 123     public String getFilename() {
11 13 Sep 07 nicklas 124         return ((GenericData)genericData).getHeader().getFilename();
11 13 Sep 07 nicklas 125     }
11 13 Sep 07 nicklas 126
11 13 Sep 07 nicklas 127     /** sets the array type */
11 13 Sep 07 nicklas 128     public String getArrayType() {
11 13 Sep 07 nicklas 129         return getWStringFromGenericHdr(AffymetrixParameterConsts.ARRAY_TYPE_PARAM_NAME);
11 13 Sep 07 nicklas 130     }
11 13 Sep 07 nicklas 131
11 13 Sep 07 nicklas 132     /** gets the number of entries (probe sets)
11 13 Sep 07 nicklas 133       * @param dataType The data type
11 13 Sep 07 nicklas 134      */
11 13 Sep 07 nicklas 135     public int getEntryCount(MultiDataType dataType) {
11 13 Sep 07 nicklas 136         DataSetHeader h = getDataSetHeader(dataType);
11 13 Sep 07 nicklas 137         return (h == null ? 0 : h.getRowCnt());
11 13 Sep 07 nicklas 138     }
11 13 Sep 07 nicklas 139     
11 13 Sep 07 nicklas 140     private DataSetHeader getDataSetHeader(MultiDataType dataType) {
11 13 Sep 07 nicklas 141         DataGroupHeader dcHdr = genericData.getHeader().getDataGroup(0);
11 13 Sep 07 nicklas 142         int n = dcHdr.getDataSetCnt();
11 13 Sep 07 nicklas 143         for (int i=0; i<n; i++)
11 13 Sep 07 nicklas 144         {
11 13 Sep 07 nicklas 145             DataSetHeader dpHdr = dcHdr.getDataSet(i);
11 13 Sep 07 nicklas 146             if (dpHdr.getName().equals(MultiDataDataSetNames.DataSetNames[dataType.getDataType()]))
11 13 Sep 07 nicklas 147                 return dpHdr;
11 13 Sep 07 nicklas 148         }
11 13 Sep 07 nicklas 149   return null;
11 13 Sep 07 nicklas 150     }
11 13 Sep 07 nicklas 151
11 13 Sep 07 nicklas 152     /** gets the name of the algorithm.
11 13 Sep 07 nicklas 153      * @return The algorithm name.
11 13 Sep 07 nicklas 154      */
11 13 Sep 07 nicklas 155     public String getAlgName() {
11 13 Sep 07 nicklas 156         return getWStringFromGenericHdr(AffymetrixParameterConsts.ALGORITHM_NAME_PARAM_NAME);
11 13 Sep 07 nicklas 157     }
11 13 Sep 07 nicklas 158
11 13 Sep 07 nicklas 159     /** gets the algorithm version.
11 13 Sep 07 nicklas 160      * @return The version.
11 13 Sep 07 nicklas 161      */
11 13 Sep 07 nicklas 162     public String getAlgVersion() {
11 13 Sep 07 nicklas 163         return getWStringFromGenericHdr(AffymetrixParameterConsts.ALG_VERSION_PARAM_NAME);
11 13 Sep 07 nicklas 164     }
11 13 Sep 07 nicklas 165
11 13 Sep 07 nicklas 166     /** gets the algorithm parameters
11 13 Sep 07 nicklas 167      * @return The algoirhtm parameters.
11 13 Sep 07 nicklas 168      */
11 13 Sep 07 nicklas 169     public Vector/*ParameterNameValue*/ getAlgParams() {
11 13 Sep 07 nicklas 170         Vector algParams = new Vector();
11 13 Sep 07 nicklas 171         Vector allParams = genericData.getHeader().getGenericDataHdr().getNameValParams();
11 13 Sep 07 nicklas 172         for (int i=0; i<allParams.size(); i++)
11 13 Sep 07 nicklas 173         {
11 13 Sep 07 nicklas 174             ParameterNameValue param = (ParameterNameValue) allParams.elementAt(i);
11 13 Sep 07 nicklas 175             String name = param.getName();
11 13 Sep 07 nicklas 176             if (name.startsWith(AffymetrixParameterConsts.ALGORITHM_PARAM_NAME_PREFIX) == true)
11 13 Sep 07 nicklas 177             {
11 13 Sep 07 nicklas 178                 ParameterNameValue algParam = new ParameterNameValue(param);
11 13 Sep 07 nicklas 179                 algParam.setName( name.substring(AffymetrixParameterConsts.ALGORITHM_PARAM_NAME_PREFIX.length(), name.length()));
11 13 Sep 07 nicklas 180                 algParams.add(algParam);
11 13 Sep 07 nicklas 181             }
11 13 Sep 07 nicklas 182         }
11 13 Sep 07 nicklas 183         return algParams;
11 13 Sep 07 nicklas 184     }
11 13 Sep 07 nicklas 185
11 13 Sep 07 nicklas 186     /** gets the summary parameters
11 13 Sep 07 nicklas 187      * @return The summary parameters.
11 13 Sep 07 nicklas 188      */
11 13 Sep 07 nicklas 189     public Vector /*ParameterNameValue*/ getSummaryParams() {
11 13 Sep 07 nicklas 190         Vector algParams = new Vector();
11 13 Sep 07 nicklas 191         Vector allParams = genericData.getHeader().getGenericDataHdr().getNameValParams();
11 13 Sep 07 nicklas 192         for (int i=0; i<allParams.size(); i++)
11 13 Sep 07 nicklas 193         {
11 13 Sep 07 nicklas 194             ParameterNameValue param = (ParameterNameValue) allParams.elementAt(i);
11 13 Sep 07 nicklas 195             String name = param.getName();
11 13 Sep 07 nicklas 196             if (name.startsWith(AffymetrixParameterConsts.ALGORITHM_SUMMARY_NAME_PREFIX) == true)
11 13 Sep 07 nicklas 197             {
11 13 Sep 07 nicklas 198                 ParameterNameValue algParam = new ParameterNameValue(param);
11 13 Sep 07 nicklas 199                 algParam.setName( name.substring(AffymetrixParameterConsts.ALGORITHM_SUMMARY_NAME_PREFIX.length(), name.length()));
11 13 Sep 07 nicklas 200                 algParams.add(algParam);
11 13 Sep 07 nicklas 201             }
11 13 Sep 07 nicklas 202         }
11 13 Sep 07 nicklas 203         return algParams;
11 13 Sep 07 nicklas 204     }
11 13 Sep 07 nicklas 205     
11 13 Sep 07 nicklas 206     /** gets the file header.
11 13 Sep 07 nicklas 207      * @return The file header.
11 13 Sep 07 nicklas 208      */
11 13 Sep 07 nicklas 209     public FileHeader getFileHeader() {
11 13 Sep 07 nicklas 210         return genericData.getHeader();
11 13 Sep 07 nicklas 211     }
11 13 Sep 07 nicklas 212
11 13 Sep 07 nicklas 213     /** gets the generic data object.
11 13 Sep 07 nicklas 214      * @return The data object.
11 13 Sep 07 nicklas 215      */
11 13 Sep 07 nicklas 216     public GenericData getGenericData() {
11 13 Sep 07 nicklas 217         return genericData;
11 13 Sep 07 nicklas 218     }
11 13 Sep 07 nicklas 219
11 13 Sep 07 nicklas 220     /** gets the probe set data.
11 13 Sep 07 nicklas 221      * @param dataType The data type
11 13 Sep 07 nicklas 222      * @param index The row index.
11 13 Sep 07 nicklas 223      * @return The genotype results.
11 13 Sep 07 nicklas 224      */
11 13 Sep 07 nicklas 225     public ProbeSetMultiDataGenotypeData getGenotypeEntry(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 226         return getGenericGenotypeEntry(dataType, index);
11 13 Sep 07 nicklas 227     }
11 13 Sep 07 nicklas 228
11 13 Sep 07 nicklas 229     /** gets the probe set data.
11 13 Sep 07 nicklas 230      * @param dataType The data type
11 13 Sep 07 nicklas 231      * @param index The row index.
11 13 Sep 07 nicklas 232      * @return The results.
11 13 Sep 07 nicklas 233      */
11 13 Sep 07 nicklas 234     public ProbeSetMultiDataExpressionData getExpressionEntry(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 235         return getGenericExpressionEntry(dataType, index);
11 13 Sep 07 nicklas 236     }
11 13 Sep 07 nicklas 237
11 13 Sep 07 nicklas 238     /*! Gets the probe set data.
11 13 Sep 07 nicklas 239      * @param dataType The data type
11 13 Sep 07 nicklas 240      * @param index The row index.
11 13 Sep 07 nicklas 241      * @return The genotype results.
11 13 Sep 07 nicklas 242      */
11 13 Sep 07 nicklas 243     private ProbeSetMultiDataGenotypeData getGenericGenotypeEntry(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 244   DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 245         ProbeSetMultiDataGenotypeData entry = null;
11 13 Sep 07 nicklas 246   if (ds != null && ds.entries != null && ds.entries.isOpen() == true)
11 13 Sep 07 nicklas 247   {
11 13 Sep 07 nicklas 248             int colIndex = 0;
11 13 Sep 07 nicklas 249             entry = new ProbeSetMultiDataGenotypeData();
11 13 Sep 07 nicklas 250             entry.setName(ds.entries.getDataString8(index, colIndex++));
11 13 Sep 07 nicklas 251             entry.setCall(ds.entries.getDataByte(index, colIndex++));
11 13 Sep 07 nicklas 252             entry.setConfidence(ds.entries.getDataFloat(index, colIndex++));
11 13 Sep 07 nicklas 253             entry.setMetrics(getExtraMetricEntries(ds, index, colIndex));
11 13 Sep 07 nicklas 254         }
11 13 Sep 07 nicklas 255         return entry;
11 13 Sep 07 nicklas 256     }
11 13 Sep 07 nicklas 257
11 13 Sep 07 nicklas 258     /*! Gets the probe set data.
11 13 Sep 07 nicklas 259      * @param dataType The data type
11 13 Sep 07 nicklas 260      * @param index The row index.
11 13 Sep 07 nicklas 261      * @param entry The expression results.
11 13 Sep 07 nicklas 262      */
11 13 Sep 07 nicklas 263     private ProbeSetMultiDataExpressionData getGenericExpressionEntry(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 264   DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 265         ProbeSetMultiDataExpressionData entry = null;
11 13 Sep 07 nicklas 266   if (ds != null && ds.entries != null && ds.entries.isOpen() == true)
11 13 Sep 07 nicklas 267   {
11 13 Sep 07 nicklas 268             int colIndex = 0;
11 13 Sep 07 nicklas 269             entry = new ProbeSetMultiDataExpressionData();
11 13 Sep 07 nicklas 270             entry.setName(ds.entries.getDataString8(index, colIndex++));
11 13 Sep 07 nicklas 271             entry.setQuantification(ds.entries.getDataFloat(index, colIndex++));
11 13 Sep 07 nicklas 272             entry.setMetrics(getExtraMetricEntries(ds, index, colIndex));
11 13 Sep 07 nicklas 273         }
11 13 Sep 07 nicklas 274         return entry;
11 13 Sep 07 nicklas 275     }
11 13 Sep 07 nicklas 276     
11 13 Sep 07 nicklas 277     /*! Get the extra metric columns.
11 13 Sep 07 nicklas 278      * @param ds The data set info.
11 13 Sep 07 nicklas 279      * @param rowIndex The row index.
11 13 Sep 07 nicklas 280      * @param colIndex The column index
11 13 Sep 07 nicklas 281      * @param metrics The results.
11 13 Sep 07 nicklas 282      */
11 13 Sep 07 nicklas 283     private Vector getExtraMetricEntries(DataSetInfo ds, int rowIndex, int colIndex) {
11 13 Sep 07 nicklas 284         if (ds.metricColumns == null || (ds.metricColumns != null && ds.metricColumns.size() == 0))
11 13 Sep 07 nicklas 285             return null;
11 13 Sep 07 nicklas 286   int ncols = ds.metricColumns.size();
11 13 Sep 07 nicklas 287   Vector metrics = new Vector();
11 13 Sep 07 nicklas 288         for (int icol=0; icol<ncols; icol++)
11 13 Sep 07 nicklas 289   {
11 13 Sep 07 nicklas 290             ParameterNameValue nv = new ParameterNameValue();
11 13 Sep 07 nicklas 291             ColumnInfo cinfo = (ColumnInfo) ds.metricColumns.elementAt(icol);
11 13 Sep 07 nicklas 292             nv.setName(cinfo.getName());
11 13 Sep 07 nicklas 293             switch (cinfo.getColumnType())
11 13 Sep 07 nicklas 294             {
11 13 Sep 07 nicklas 295                 case ColumnInfo.ByteColType:
11 13 Sep 07 nicklas 296                     {
11 13 Sep 07 nicklas 297                         byte val = ds.entries.getDataByte(rowIndex, colIndex++);
11 13 Sep 07 nicklas 298                         nv.setValueInt8(val);
11 13 Sep 07 nicklas 299                     }
11 13 Sep 07 nicklas 300                     break;
11 13 Sep 07 nicklas 301
11 13 Sep 07 nicklas 302                 case ColumnInfo.UByteColType:
11 13 Sep 07 nicklas 303                     {
11 13 Sep 07 nicklas 304                         byte val = ds.entries.getDataByte(rowIndex, colIndex++);;
11 13 Sep 07 nicklas 305                         nv.setValueUInt8(val);
11 13 Sep 07 nicklas 306                     }
11 13 Sep 07 nicklas 307                     break;
11 13 Sep 07 nicklas 308
11 13 Sep 07 nicklas 309                 case ColumnInfo.ShortColType:
11 13 Sep 07 nicklas 310                     {
11 13 Sep 07 nicklas 311                         short val = ds.entries.getDataShort(rowIndex, colIndex++);
11 13 Sep 07 nicklas 312                         nv.setValueInt16(val);
11 13 Sep 07 nicklas 313                     }
11 13 Sep 07 nicklas 314                     break;
11 13 Sep 07 nicklas 315
11 13 Sep 07 nicklas 316                 case ColumnInfo.UShortColType:
11 13 Sep 07 nicklas 317                     {
11 13 Sep 07 nicklas 318                         short val = ds.entries.getDataShort(rowIndex, colIndex++);
11 13 Sep 07 nicklas 319                         nv.setValueUInt16(val);
11 13 Sep 07 nicklas 320                     }
11 13 Sep 07 nicklas 321                     break;
11 13 Sep 07 nicklas 322
11 13 Sep 07 nicklas 323                 case ColumnInfo.IntColType:
11 13 Sep 07 nicklas 324                     {
11 13 Sep 07 nicklas 325                         int val = ds.entries.getDataInt(rowIndex, colIndex++);
11 13 Sep 07 nicklas 326                         nv.setValueInt32(val);
11 13 Sep 07 nicklas 327                     }
11 13 Sep 07 nicklas 328                     break;
11 13 Sep 07 nicklas 329
11 13 Sep 07 nicklas 330                 case ColumnInfo.UIntColType:
11 13 Sep 07 nicklas 331                     {
11 13 Sep 07 nicklas 332                         int val = ds.entries.getDataInt(rowIndex, colIndex++);
11 13 Sep 07 nicklas 333                         nv.setValueUInt32(val);
11 13 Sep 07 nicklas 334                     }
11 13 Sep 07 nicklas 335                     break;
11 13 Sep 07 nicklas 336
11 13 Sep 07 nicklas 337                 case ColumnInfo.FloatColType:
11 13 Sep 07 nicklas 338                     {
11 13 Sep 07 nicklas 339                         float val = ds.entries.getDataFloat(rowIndex, colIndex++);
11 13 Sep 07 nicklas 340                         nv.setValueFloat(val);
11 13 Sep 07 nicklas 341                     }
11 13 Sep 07 nicklas 342                     break;
11 13 Sep 07 nicklas 343
11 13 Sep 07 nicklas 344                 case ColumnInfo.ASCIICharColType:
11 13 Sep 07 nicklas 345                     {
11 13 Sep 07 nicklas 346                         String val = ds.entries.getDataString8(rowIndex, colIndex++);
11 13 Sep 07 nicklas 347                         nv.setValueAscii(val);
11 13 Sep 07 nicklas 348                     }
11 13 Sep 07 nicklas 349                     break;
11 13 Sep 07 nicklas 350
11 13 Sep 07 nicklas 351                 case ColumnInfo.UnicodeCharColType:
11 13 Sep 07 nicklas 352                     {
11 13 Sep 07 nicklas 353                         String val = ds.entries.getDataString16(rowIndex, colIndex++);
11 13 Sep 07 nicklas 354                         nv.setValueText(val);
11 13 Sep 07 nicklas 355                     }
11 13 Sep 07 nicklas 356                 break;
11 13 Sep 07 nicklas 357             }
11 13 Sep 07 nicklas 358             metrics.add(nv);
11 13 Sep 07 nicklas 359         }
11 13 Sep 07 nicklas 360         return metrics;
11 13 Sep 07 nicklas 361     }
11 13 Sep 07 nicklas 362
11 13 Sep 07 nicklas 363     /** gets the call of the probe set.
11 13 Sep 07 nicklas 364      * @param dataType The data type
11 13 Sep 07 nicklas 365      * @param index The row index.
11 13 Sep 07 nicklas 366      * @return The call.
11 13 Sep 07 nicklas 367      */
11 13 Sep 07 nicklas 368     public byte getGenoCall(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 369         byte call = 0;
11 13 Sep 07 nicklas 370   DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 371   if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 372             call = ds.entries.getDataByte(index, 1);
11 13 Sep 07 nicklas 373   return call;
11 13 Sep 07 nicklas 374     }
11 13 Sep 07 nicklas 375
11 13 Sep 07 nicklas 376     /** gets the confidence in the call of the probe set.
11 13 Sep 07 nicklas 377      * @param dataType The data type
11 13 Sep 07 nicklas 378      * @param index The row index.
11 13 Sep 07 nicklas 379      * @return The confidence.
11 13 Sep 07 nicklas 380      */
11 13 Sep 07 nicklas 381     public float getGenoConfidence(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 382   float conf = 0.0f;
11 13 Sep 07 nicklas 383   DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 384   if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 385             conf = ds.entries.getDataFloat(index, 2);
11 13 Sep 07 nicklas 386   return conf; 
11 13 Sep 07 nicklas 387     }
11 13 Sep 07 nicklas 388
11 13 Sep 07 nicklas 389     /*! Gets the quantification of the probe set.
11 13 Sep 07 nicklas 390      * @param dataType The data type
11 13 Sep 07 nicklas 391      * @param index The row index.
11 13 Sep 07 nicklas 392      * @return The quantification.
11 13 Sep 07 nicklas 393      */
11 13 Sep 07 nicklas 394     public float getExpressionQuantification(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 395         float quant = 0.0f;
11 13 Sep 07 nicklas 396   DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 397   if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 398             quant = ds.entries.getDataFloat(index, 1);
11 13 Sep 07 nicklas 399         return quant;
11 13 Sep 07 nicklas 400     }
11 13 Sep 07 nicklas 401
11 13 Sep 07 nicklas 402     /** get the probe set name.
11 13 Sep 07 nicklas 403      * @param dataType The data type
11 13 Sep 07 nicklas 404      * @param index The row index.
11 13 Sep 07 nicklas 405      * @return The probe set name.
11 13 Sep 07 nicklas 406      */
11 13 Sep 07 nicklas 407     public String getProbeSetName(MultiDataType dataType, int index) {
11 13 Sep 07 nicklas 408         String name = null;
11 13 Sep 07 nicklas 409         DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 410   if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 411             name = ds.entries.getDataString8(index, 0);
11 13 Sep 07 nicklas 412   return name;
11 13 Sep 07 nicklas 413     }
11 13 Sep 07 nicklas 414
11 13 Sep 07 nicklas 415     /** Opens a group for reading.
11 13 Sep 07 nicklas 416      * @param dataType The data type
11 13 Sep 07 nicklas 417      */
11 13 Sep 07 nicklas 418     public DataSetInfo openMultiDataDataSet(MultiDataType dataType) {
11 13 Sep 07 nicklas 419         if (dataSetInfo.containsKey(dataType) == true)
11 13 Sep 07 nicklas 420         {
11 13 Sep 07 nicklas 421             return (DataSetInfo)dataSetInfo.get(dataType);
11 13 Sep 07 nicklas 422         }
11 13 Sep 07 nicklas 423         
11 13 Sep 07 nicklas 424         try
11 13 Sep 07 nicklas 425         {
11 13 Sep 07 nicklas 426             DataSetInfo ds = new DataSetInfo();
11 13 Sep 07 nicklas 427             ds.entries = genericData.getDataSet(MULTI_DATA_NAME, MultiDataDataSetNames.DataSetNames[dataType.getDataType()]);
11 13 Sep 07 nicklas 428             if (ds.entries != null)
11 13 Sep 07 nicklas 429             {
11 13 Sep 07 nicklas 430                 ds.entries.open();
11 13 Sep 07 nicklas 431                 int ncols = ds.entries.getHeader().getColumnCnt();
11 13 Sep 07 nicklas 432                 ds.metricColumns = new Vector();
11 13 Sep 07 nicklas 433                 int startCol = (dataType == MultiDataType.Expression || dataType == MultiDataType.ExpressionControl ? 2 : 3);
11 13 Sep 07 nicklas 434                 for (int icol=startCol; icol<ncols; icol++)
11 13 Sep 07 nicklas 435                 {
11 13 Sep 07 nicklas 436                      ds.metricColumns.add(ds.entries.getHeader().getColumnInfo(icol));
11 13 Sep 07 nicklas 437                 }
11 13 Sep 07 nicklas 438                 dataSetInfo.put(dataType, ds);
11 13 Sep 07 nicklas 439                 return ds;
11 13 Sep 07 nicklas 440             }
11 13 Sep 07 nicklas 441         }
11 13 Sep 07 nicklas 442         catch (Throwable t)
11 13 Sep 07 nicklas 443         {
11 13 Sep 07 nicklas 444         }
11 13 Sep 07 nicklas 445         return null;
11 13 Sep 07 nicklas 446     }
11 13 Sep 07 nicklas 447
11 13 Sep 07 nicklas 448     /** get the length of the metric columns.
11 13 Sep 07 nicklas 449     * @param col The column index (of the metric columns)
11 13 Sep 07 nicklas 450     * @return The length.
11 13 Sep 07 nicklas 451     */
11 13 Sep 07 nicklas 452     public int getMetricColumnLength(MultiDataType dataType, int col) {
11 13 Sep 07 nicklas 453         DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 454         if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 455         {
11 13 Sep 07 nicklas 456             ColumnInfo info = (ColumnInfo) ds.metricColumns.elementAt(col);
11 13 Sep 07 nicklas 457             return info.getLength();
11 13 Sep 07 nicklas 458         }
11 13 Sep 07 nicklas 459         return 0;
11 13 Sep 07 nicklas 460     }
11 13 Sep 07 nicklas 461
11 13 Sep 07 nicklas 462     /** Get the length of the metric columns.
11 13 Sep 07 nicklas 463      * @param dataType The data type
11 13 Sep 07 nicklas 464      * @return The number of columns.
11 13 Sep 07 nicklas 465      */
11 13 Sep 07 nicklas 466     public int getNumMetricColumns(MultiDataType dataType) {
11 13 Sep 07 nicklas 467         DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 468         if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 469             return ds.metricColumns.size();
11 13 Sep 07 nicklas 470         return 0;
11 13 Sep 07 nicklas 471     }
11 13 Sep 07 nicklas 472
11 13 Sep 07 nicklas 473     /** Get the metric column name.
11 13 Sep 07 nicklas 474      * @param dataType The data type
11 13 Sep 07 nicklas 475      * @param colIndex the metric column index
11 13 Sep 07 nicklas 476      * @return The column name
11 13 Sep 07 nicklas 477      */
11 13 Sep 07 nicklas 478     public String getMetricColumnName(MultiDataType dataType, int colIndex) {
11 13 Sep 07 nicklas 479         DataSetInfo ds = openMultiDataDataSet(dataType);
11 13 Sep 07 nicklas 480         if (ds != null && ds.entries != null && ds.entries.isOpen())
11 13 Sep 07 nicklas 481         {
11 13 Sep 07 nicklas 482             ColumnInfo col = (ColumnInfo) ds.metricColumns.elementAt(colIndex);
11 13 Sep 07 nicklas 483             return col.getName();
11 13 Sep 07 nicklas 484         }
11 13 Sep 07 nicklas 485         return null;
11 13 Sep 07 nicklas 486     }
11 13 Sep 07 nicklas 487
11 13 Sep 07 nicklas 488     /** gets a parameter value as a string.
11 13 Sep 07 nicklas 489      * @param name The name of the parameter.
11 13 Sep 07 nicklas 490      * @return The string representation.
11 13 Sep 07 nicklas 491      */
11 13 Sep 07 nicklas 492     private String getWStringFromGenericHdr(String name) {
11 13 Sep 07 nicklas 493         GenericDataHeader hdr = genericData.getHeader().getGenericDataHdr();
11 13 Sep 07 nicklas 494         if (hdr == null)
11 13 Sep 07 nicklas 495             return null;
11 13 Sep 07 nicklas 496   ParameterNameValue paramType = hdr.findNameValParam(name);
11 13 Sep 07 nicklas 497         if (paramType != null)
11 13 Sep 07 nicklas 498             return paramType.getValueText();
11 13 Sep 07 nicklas 499   return null;
11 13 Sep 07 nicklas 500     }
11 13 Sep 07 nicklas 501 };