affyfusion-109/src/affymetrix/fusion/chp/FusionCHPQuantificationData.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.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 Quantification CHP files */
11 13 Sep 07 nicklas 29 public class FusionCHPQuantificationData extends FusionCHPData
11 13 Sep 07 nicklas 30 {
11 13 Sep 07 nicklas 31     /** Constructor */
11 13 Sep 07 nicklas 32     private FusionCHPQuantificationData() {
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 CHP object. */
11 13 Sep 07 nicklas 37     private CHPQuantificationData 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     /** Gets the name of the algorithm.
11 13 Sep 07 nicklas 50      * @return The algorithm name.
11 13 Sep 07 nicklas 51      */
11 13 Sep 07 nicklas 52     public String getAlgName() { return chpData.getAlgName(); }
11 13 Sep 07 nicklas 53
11 13 Sep 07 nicklas 54     /** Gets the algorithm version.
11 13 Sep 07 nicklas 55      * @return The version.
11 13 Sep 07 nicklas 56      */
11 13 Sep 07 nicklas 57     public String getAlgVersion() { return chpData.getAlgVersion(); }
11 13 Sep 07 nicklas 58
11 13 Sep 07 nicklas 59     /** Sets the array type */
11 13 Sep 07 nicklas 60     public String getArrayType() { return chpData.getArrayType(); }
11 13 Sep 07 nicklas 61
11 13 Sep 07 nicklas 62     /** Gets the algorithm parameters
11 13 Sep 07 nicklas 63      * @return The algoirhtm parameters.
11 13 Sep 07 nicklas 64      */
11 13 Sep 07 nicklas 65     public Vector /*ParameterNameValueType*/ getAlgParams() { return chpData.getAlgParams(); }
11 13 Sep 07 nicklas 66
11 13 Sep 07 nicklas 67     /** Gets the summary parameters
11 13 Sep 07 nicklas 68      * @return The summary parameters.
11 13 Sep 07 nicklas 69      */
11 13 Sep 07 nicklas 70     public Vector /*ParameterNameValueType*/ getSummaryParams() { return chpData.getSummaryParams(); }
11 13 Sep 07 nicklas 71
11 13 Sep 07 nicklas 72     /** Gets the number of entries (probe sets) */
11 13 Sep 07 nicklas 73     public int getEntryCount() { return chpData.getEntryCount(); }
11 13 Sep 07 nicklas 74
11 13 Sep 07 nicklas 75     /** Gets the Quantification/probe set name data for the given row.
11 13 Sep 07 nicklas 76      * @param index The row index.
11 13 Sep 07 nicklas 77      * @return The entry.
11 13 Sep 07 nicklas 78      */
11 13 Sep 07 nicklas 79     public ProbeSetQuantificationData getQuantificationEntry(int index) { return chpData.getQuantificationEntry(index); }
11 13 Sep 07 nicklas 80
11 13 Sep 07 nicklas 81     /** Reads the CHP file.
11 13 Sep 07 nicklas 82      * @return True if successful.
11 13 Sep 07 nicklas 83      */
11 13 Sep 07 nicklas 84     protected boolean read() {
11 13 Sep 07 nicklas 85         CHPQuantificationFileReader reader = new CHPQuantificationFileReader();
11 13 Sep 07 nicklas 86         chpData = new CHPQuantificationData();
11 13 Sep 07 nicklas 87   reader.setFilename(filename);
11 13 Sep 07 nicklas 88   try
11 13 Sep 07 nicklas 89   {
11 13 Sep 07 nicklas 90             reader.read(chpData);
11 13 Sep 07 nicklas 91             return true;
11 13 Sep 07 nicklas 92   }
11 13 Sep 07 nicklas 93   catch(Throwable t)
11 13 Sep 07 nicklas 94   {
11 13 Sep 07 nicklas 95             return false;
11 13 Sep 07 nicklas 96   }
11 13 Sep 07 nicklas 97     }
11 13 Sep 07 nicklas 98
11 13 Sep 07 nicklas 99     /** Reads the header of the CHP file
11 13 Sep 07 nicklas 100      * @return True if successful
11 13 Sep 07 nicklas 101      */
11 13 Sep 07 nicklas 102     protected boolean readHeader() { return read(); }
11 13 Sep 07 nicklas 103
11 13 Sep 07 nicklas 104     /** A class to register the Quantification CHP reader. */
11 13 Sep 07 nicklas 105     private static class Reg extends FusionCHPDataReg
11 13 Sep 07 nicklas 106     {
11 13 Sep 07 nicklas 107         /** Constructor - register the Quantification file type. */
11 13 Sep 07 nicklas 108         public Reg() {
11 13 Sep 07 nicklas 109             super();
11 13 Sep 07 nicklas 110             Vector ids = new Vector();
11 13 Sep 07 nicklas 111             AffymetrixGuidType guid = new AffymetrixGuidType();
11 13 Sep 07 nicklas 112             guid.setGuid(CHPQuantificationData.CHP_QUANTIFICATION_TYPE);
11 13 Sep 07 nicklas 113             ids.add(guid);
11 13 Sep 07 nicklas 114             setFileTypeIds(ids);
11 13 Sep 07 nicklas 115         }
11 13 Sep 07 nicklas 116
11 13 Sep 07 nicklas 117         /** Creates a Quantification CHP object.
11 13 Sep 07 nicklas 118          * @return The Quantification CHP object.
11 13 Sep 07 nicklas 119          */
11 13 Sep 07 nicklas 120         public FusionCHPData makeObject() { return new FusionCHPQuantificationData(); }
11 13 Sep 07 nicklas 121     };
11 13 Sep 07 nicklas 122
11 13 Sep 07 nicklas 123     /** The one and only registration object. This registers the class as a CHP reader. */
11 13 Sep 07 nicklas 124     private static Reg reg = null;
11 13 Sep 07 nicklas 125     
11 13 Sep 07 nicklas 126     /** Register the reader with the system. */
11 13 Sep 07 nicklas 127     public static void registerReader() {
11 13 Sep 07 nicklas 128         if (FusionCHPQuantificationData.reg == null)
11 13 Sep 07 nicklas 129             FusionCHPQuantificationData.reg = new Reg();
11 13 Sep 07 nicklas 130     }
11 13 Sep 07 nicklas 131
11 13 Sep 07 nicklas 132     /** Converts the type to the Quantification CHP type.
11 13 Sep 07 nicklas 133      * @param chip The pointer to the CHP data object.
11 13 Sep 07 nicklas 134      * @return The Quantification CHP data type or NULL if not compatible.
11 13 Sep 07 nicklas 135      */
11 13 Sep 07 nicklas 136     public static FusionCHPQuantificationData fromBase(FusionCHPData chip) {
11 13 Sep 07 nicklas 137         if (chip == null)
11 13 Sep 07 nicklas 138             return null;
11 13 Sep 07 nicklas 139         String chipName = chip.getClass().getName();
11 13 Sep 07 nicklas 140         String genName = FusionCHPQuantificationData.class.getName();
11 13 Sep 07 nicklas 141         if (chipName.compareTo(genName) == 0)
11 13 Sep 07 nicklas 142             return (FusionCHPQuantificationData) chip;
11 13 Sep 07 nicklas 143         return null;
11 13 Sep 07 nicklas 144     }
11 13 Sep 07 nicklas 145 };