affyfusion-109/src/affymetrix/fusion/chp/FusionCHPTilingData.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 tiling CHP files */
11 13 Sep 07 nicklas 29 public class FusionCHPTilingData extends FusionCHPData {
11 13 Sep 07 nicklas 30     
11 13 Sep 07 nicklas 31     /** Creates a new instance of FusionCHPTilingData */
11 13 Sep 07 nicklas 32     private FusionCHPTilingData() {
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 CHPTilingData chpData;
11 13 Sep 07 nicklas 38
11 13 Sep 07 nicklas 39     /** Gets the number of sequence stored in the file.
11 13 Sep 07 nicklas 40      * @return The number of sequence stored in the file.
11 13 Sep 07 nicklas 41      */
11 13 Sep 07 nicklas 42     public int getNumberSequences() { return chpData.getNumberSequences(); }
11 13 Sep 07 nicklas 43
11 13 Sep 07 nicklas 44     /** Gets the name of the algorithm.
11 13 Sep 07 nicklas 45      * @return The algorithm name.
11 13 Sep 07 nicklas 46      */
11 13 Sep 07 nicklas 47     public String getAlgName() { return chpData.getAlgName(); }
11 13 Sep 07 nicklas 48
11 13 Sep 07 nicklas 49     /** Gets the algorithm version.
11 13 Sep 07 nicklas 50      * @return The version.
11 13 Sep 07 nicklas 51      */
11 13 Sep 07 nicklas 52     public String getAlgVersion() { return chpData.getAlgVersion(); }
11 13 Sep 07 nicklas 53
11 13 Sep 07 nicklas 54     /** Gets the algorithm parameters
11 13 Sep 07 nicklas 55      * @return The algoirhtm parameters.
11 13 Sep 07 nicklas 56      */
11 13 Sep 07 nicklas 57     public Vector /*ParameterNameValue*/ getAlgParams() { return chpData.getAlgParams(); }
11 13 Sep 07 nicklas 58
11 13 Sep 07 nicklas 59     /** Gets the sequence data.
11 13 Sep 07 nicklas 60      * @return The data associated with the sequence.
11 13 Sep 07 nicklas 61      */
11 13 Sep 07 nicklas 62     public TilingSequenceData getTilingSequenceData() { return chpData.getTilingSequenceData(); }
11 13 Sep 07 nicklas 63
11 13 Sep 07 nicklas 64     /** Gets the number of entries in a tiling sequence.
11 13 Sep 07 nicklas 65      * @param index The sequence index.
11 13 Sep 07 nicklas 66      * @return The number of entries in the sequence.
11 13 Sep 07 nicklas 67      */
11 13 Sep 07 nicklas 68     public int getTilingSequenceEntryCount(int index) { return chpData.getTilingSequenceEntryCount(index); }
11 13 Sep 07 nicklas 69
11 13 Sep 07 nicklas 70     /** Opens a group for reading.
11 13 Sep 07 nicklas 71      * @param index The index to the sequence.
11 13 Sep 07 nicklas 72      */
11 13 Sep 07 nicklas 73     public void openTilingSequenceDataSet(int index) { chpData.openTilingSequenceDataSet(index); }
11 13 Sep 07 nicklas 74
11 13 Sep 07 nicklas 75     /** Returns the entry for the given row. The data set must be open.
11 13 Sep 07 nicklas 76      * @param row 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 CHPTilingEntry getTilingSequenceEntry(int row) { return chpData.getTilingSequenceEntry(row); }
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       CHPTilingFileReader reader = new CHPTilingFileReader();
11 13 Sep 07 nicklas 86         chpData = new CHPTilingData();
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     /** Get the id of the file (only valid for Command Console "calvin" files)
11 13 Sep 07 nicklas 105      * @return The unique file id.
11 13 Sep 07 nicklas 106      */
11 13 Sep 07 nicklas 107     public AffymetrixGuidType getFileId() {
11 13 Sep 07 nicklas 108         return chpData.getGenericData().getFileIdentifier();
11 13 Sep 07 nicklas 109     }
11 13 Sep 07 nicklas 110     
11 13 Sep 07 nicklas 111     /** A class to register the tiling CHP reader. */
11 13 Sep 07 nicklas 112     private static class Reg extends FusionCHPDataReg
11 13 Sep 07 nicklas 113     {
11 13 Sep 07 nicklas 114         /** Constructor - register the tiling file type. */
11 13 Sep 07 nicklas 115         public Reg() {
11 13 Sep 07 nicklas 116             super();
11 13 Sep 07 nicklas 117             Vector ids = new Vector();
11 13 Sep 07 nicklas 118             AffymetrixGuidType guid = new AffymetrixGuidType();
11 13 Sep 07 nicklas 119             guid.setGuid(CHPTilingData.CHP_TILING_TYPE);
11 13 Sep 07 nicklas 120             ids.add(guid);
11 13 Sep 07 nicklas 121             setFileTypeIds(ids);
11 13 Sep 07 nicklas 122         }
11 13 Sep 07 nicklas 123
11 13 Sep 07 nicklas 124         /** Creates a tiling CHP object.
11 13 Sep 07 nicklas 125          * @return The tiling CHP object.
11 13 Sep 07 nicklas 126          */
11 13 Sep 07 nicklas 127         public FusionCHPData makeObject() { return new FusionCHPTilingData(); }
11 13 Sep 07 nicklas 128     };
11 13 Sep 07 nicklas 129
11 13 Sep 07 nicklas 130     /** The one and only registration object. This registers the class as a CHP reader. */
11 13 Sep 07 nicklas 131     private static Reg reg = null;
11 13 Sep 07 nicklas 132     
11 13 Sep 07 nicklas 133     /** Register the reader with the system. */
11 13 Sep 07 nicklas 134     public static void registerReader() {
11 13 Sep 07 nicklas 135         if (FusionCHPTilingData.reg == null)
11 13 Sep 07 nicklas 136             FusionCHPTilingData.reg = new Reg();
11 13 Sep 07 nicklas 137     }
11 13 Sep 07 nicklas 138
11 13 Sep 07 nicklas 139     /** Converts the type to the tiling CHP type.
11 13 Sep 07 nicklas 140      * @param chip The pointer to the CHP data object.
11 13 Sep 07 nicklas 141      * @return The tiling CHP data type or NULL if not compatible.
11 13 Sep 07 nicklas 142      */
11 13 Sep 07 nicklas 143     public static FusionCHPTilingData fromBase(FusionCHPData chip) {
11 13 Sep 07 nicklas 144         if (chip == null)
11 13 Sep 07 nicklas 145             return null;
11 13 Sep 07 nicklas 146         String chipName = chip.getClass().getName();
11 13 Sep 07 nicklas 147         String genName = FusionCHPTilingData.class.getName();
11 13 Sep 07 nicklas 148         if (chipName.compareTo(genName) == 0)
11 13 Sep 07 nicklas 149             return (FusionCHPTilingData) chip;
11 13 Sep 07 nicklas 150         return null;
11 13 Sep 07 nicklas 151     }
11 13 Sep 07 nicklas 152 }