affyfusion-109/src/affymetrix/gcos/chp/CHPFileHeader.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.chp;
11 13 Sep 07 nicklas 22 import affymetrix.gcos.*;
11 13 Sep 07 nicklas 23
11 13 Sep 07 nicklas 24 import java.util.*;
11 13 Sep 07 nicklas 25
11 13 Sep 07 nicklas 26 /** Stores the contents of the header of a CHP file. */
11 13 Sep 07 nicklas 27 public class CHPFileHeader {
11 13 Sep 07 nicklas 28     
11 13 Sep 07 nicklas 29     /** Expression assay type. */
11 13 Sep 07 nicklas 30     public static final int EXPRESSION_ASSAY = 0;
11 13 Sep 07 nicklas 31     
11 13 Sep 07 nicklas 32     /** Genotyping assay type. */
11 13 Sep 07 nicklas 33     public static final int GENOTYPING_ASSAY = 1;
11 13 Sep 07 nicklas 34     
11 13 Sep 07 nicklas 35     /** Resequencing assay type. */
11 13 Sep 07 nicklas 36     public static final int RESEQUENCING_ASSAY = 2;
11 13 Sep 07 nicklas 37     
11 13 Sep 07 nicklas 38     /** Universal assay type. */
11 13 Sep 07 nicklas 39     public static final int UNIVERSAL_ASSAY = 3;
11 13 Sep 07 nicklas 40     
11 13 Sep 07 nicklas 41     /** Unknown assay type. */
11 13 Sep 07 nicklas 42     public static final int UNKNOWN_ASSAY = 4;
11 13 Sep 07 nicklas 43
11 13 Sep 07 nicklas 44     /** The magic number in the file */
11 13 Sep 07 nicklas 45     private int magic;
11 13 Sep 07 nicklas 46
11 13 Sep 07 nicklas 47     /** Gets the magic number in the file.
11 13 Sep 07 nicklas 48      * @return The magic number of the file.
11 13 Sep 07 nicklas 49      */
11 13 Sep 07 nicklas 50     public int getMagic() { return magic; }
11 13 Sep 07 nicklas 51     
11 13 Sep 07 nicklas 52     /** Sets the magic number in the file.
11 13 Sep 07 nicklas 53      * @param m The magic number of the file.
11 13 Sep 07 nicklas 54      */
11 13 Sep 07 nicklas 55     public void setMagic(int m) { magic = m; }
11 13 Sep 07 nicklas 56     
11 13 Sep 07 nicklas 57     /** The version number in the file */
11 13 Sep 07 nicklas 58     private int version;
11 13 Sep 07 nicklas 59
11 13 Sep 07 nicklas 60     /** Gets the version number in the file.
11 13 Sep 07 nicklas 61      * @return The version number of the file.
11 13 Sep 07 nicklas 62      */
11 13 Sep 07 nicklas 63     public int getVersion() { return version; }
11 13 Sep 07 nicklas 64     
11 13 Sep 07 nicklas 65     /** Sets the version number in the file.
11 13 Sep 07 nicklas 66      * @param v The version number of the file.
11 13 Sep 07 nicklas 67      */
11 13 Sep 07 nicklas 68     public void setVersion(int v) { version = v; }
11 13 Sep 07 nicklas 69     
11 13 Sep 07 nicklas 70     /** The number of feature columns in the array */
11 13 Sep 07 nicklas 71     private int cols;
11 13 Sep 07 nicklas 72
11 13 Sep 07 nicklas 73     /** Gets the number of columns of features.
11 13 Sep 07 nicklas 74      * @return The number of columns of features.
11 13 Sep 07 nicklas 75      */
11 13 Sep 07 nicklas 76     public int getCols() { return cols; }
11 13 Sep 07 nicklas 77     
11 13 Sep 07 nicklas 78     /** Sets the number of columns of features.
11 13 Sep 07 nicklas 79      * @param c The number of columns of features.
11 13 Sep 07 nicklas 80      */
11 13 Sep 07 nicklas 81     public void setCols(int c) { cols = c; }
11 13 Sep 07 nicklas 82     
11 13 Sep 07 nicklas 83     /** The number of feature rows in the array */
11 13 Sep 07 nicklas 84     private int rows;
11 13 Sep 07 nicklas 85
11 13 Sep 07 nicklas 86     /** Gets the number of rows of features.
11 13 Sep 07 nicklas 87      * @return The number of rows of features.
11 13 Sep 07 nicklas 88      */
11 13 Sep 07 nicklas 89     public int getRows() { return rows; }
11 13 Sep 07 nicklas 90     
11 13 Sep 07 nicklas 91     /** Sets the number of rows of features.
11 13 Sep 07 nicklas 92      * @param r The number of rows of features.
11 13 Sep 07 nicklas 93      */
11 13 Sep 07 nicklas 94     public void setRows(int r) { rows = r; }
11 13 Sep 07 nicklas 95
11 13 Sep 07 nicklas 96     /** The number of probe set results */
11 13 Sep 07 nicklas 97     private int numProbeSets;
11 13 Sep 07 nicklas 98
11 13 Sep 07 nicklas 99     /** Gets the number of probe sets.
11 13 Sep 07 nicklas 100      * @return The number of probe sets.
11 13 Sep 07 nicklas 101      */
11 13 Sep 07 nicklas 102     public int getNumProbeSets() { return numProbeSets; }
11 13 Sep 07 nicklas 103     
11 13 Sep 07 nicklas 104     /** Sets the number of probe sets.
11 13 Sep 07 nicklas 105      * @param n The number of probe sets.
11 13 Sep 07 nicklas 106      */
11 13 Sep 07 nicklas 107     public void setNumProbeSets(int n) { numProbeSets = n; }
11 13 Sep 07 nicklas 108
11 13 Sep 07 nicklas 109     /** The type of results stored in the CHP file */
11 13 Sep 07 nicklas 110     private int assayType;
11 13 Sep 07 nicklas 111
11 13 Sep 07 nicklas 112     /** Gets the assay type.
11 13 Sep 07 nicklas 113      * @return The assay type.
11 13 Sep 07 nicklas 114      */
11 13 Sep 07 nicklas 115     public int getAssayType() { return assayType; }
11 13 Sep 07 nicklas 116     
11 13 Sep 07 nicklas 117     /** Sets the assay type.
11 13 Sep 07 nicklas 118      * @param t The assay type.
11 13 Sep 07 nicklas 119      */
11 13 Sep 07 nicklas 120     public void setAssayType(int t) { assayType = t; }
11 13 Sep 07 nicklas 121
11 13 Sep 07 nicklas 122     /** The chip type or probe array type of the CHP file */
11 13 Sep 07 nicklas 123     private String chipType;
11 13 Sep 07 nicklas 124
11 13 Sep 07 nicklas 125     /** Gets the chip type.
11 13 Sep 07 nicklas 126      * @return The chip type.
11 13 Sep 07 nicklas 127      */
11 13 Sep 07 nicklas 128     public String getChipType() { return chipType; }
11 13 Sep 07 nicklas 129     
11 13 Sep 07 nicklas 130     /** Sets the chip type.
11 13 Sep 07 nicklas 131      * @param str The chip type.
11 13 Sep 07 nicklas 132      */
11 13 Sep 07 nicklas 133     public void setChipType(String str) { chipType = str; }
11 13 Sep 07 nicklas 134
11 13 Sep 07 nicklas 135     /** The name of the algorithm used to create the CHP file */
11 13 Sep 07 nicklas 136     private String algorithmName;
11 13 Sep 07 nicklas 137
11 13 Sep 07 nicklas 138     /** Gets the algorithm name.
11 13 Sep 07 nicklas 139      * @return The algorithm name.
11 13 Sep 07 nicklas 140      */
11 13 Sep 07 nicklas 141     public String getAlgName() { return algorithmName; }
11 13 Sep 07 nicklas 142     
11 13 Sep 07 nicklas 143     /** Sets the algorithm name.
11 13 Sep 07 nicklas 144      * @param str The algorithm name.
11 13 Sep 07 nicklas 145      */
11 13 Sep 07 nicklas 146     public void setAlgName(String str) { algorithmName = str; }
11 13 Sep 07 nicklas 147
11 13 Sep 07 nicklas 148     /** The version number of the algorithm used to create the CHP file */
11 13 Sep 07 nicklas 149     private String algorithmVersion;
11 13 Sep 07 nicklas 150
11 13 Sep 07 nicklas 151     /** Gets the algorithm version.
11 13 Sep 07 nicklas 152      * @return The algorithm version.
11 13 Sep 07 nicklas 153      */
11 13 Sep 07 nicklas 154     public String getAlgVersion() { return algorithmVersion; }
11 13 Sep 07 nicklas 155     
11 13 Sep 07 nicklas 156     /** Sets the algorithm version.
11 13 Sep 07 nicklas 157      * @param str The algorithm version.
11 13 Sep 07 nicklas 158      */
11 13 Sep 07 nicklas 159     public void setAlgVersion(String str) { algorithmVersion = str; }
11 13 Sep 07 nicklas 160
11 13 Sep 07 nicklas 161     /** The name of the CEL file used in the creation of the CHP file */
11 13 Sep 07 nicklas 162     private String parentCellFile;
11 13 Sep 07 nicklas 163
11 13 Sep 07 nicklas 164     /** Gets the name of the CEL file used to create the CHP file.
11 13 Sep 07 nicklas 165      * @return The CEL file name.
11 13 Sep 07 nicklas 166      */
11 13 Sep 07 nicklas 167     public String getParentCellFile() { return parentCellFile; }
11 13 Sep 07 nicklas 168     
11 13 Sep 07 nicklas 169     /** Sets the name of the CEL file used to create the CHP file.
11 13 Sep 07 nicklas 170      * @param str The CEL file name.
11 13 Sep 07 nicklas 171      */
11 13 Sep 07 nicklas 172     public void setParentCellFile(String str) { parentCellFile = str; }
11 13 Sep 07 nicklas 173
11 13 Sep 07 nicklas 174     /** The programmatic identifier of the algorithm used to create the CHP file */
11 13 Sep 07 nicklas 175     private String progID;
11 13 Sep 07 nicklas 176
11 13 Sep 07 nicklas 177     /** Gets the algorithm prog ID (COM components only).
11 13 Sep 07 nicklas 178      * @return The id.
11 13 Sep 07 nicklas 179      */
11 13 Sep 07 nicklas 180     public String getProgID() { return progID; }
11 13 Sep 07 nicklas 181     
11 13 Sep 07 nicklas 182     /** Sets the prog ID.
11 13 Sep 07 nicklas 183      * @param str The prog ID.
11 13 Sep 07 nicklas 184      */
11 13 Sep 07 nicklas 185     public void setProgID(String str) { progID = str; }
11 13 Sep 07 nicklas 186
11 13 Sep 07 nicklas 187     /** The vector of algorithm parameters */
11 13 Sep 07 nicklas 188     private Vector /*TagValuePairType*/ algorithmParameters;
11 13 Sep 07 nicklas 189
11 13 Sep 07 nicklas 190     /** Gets the algorithm parameters.
11 13 Sep 07 nicklas 191      * @return The parameters.
11 13 Sep 07 nicklas 192      */
11 13 Sep 07 nicklas 193     public Vector getAlgorithmParameters() { return algorithmParameters; }
11 13 Sep 07 nicklas 194     
11 13 Sep 07 nicklas 195     /** Sets the algorithm parameters.
11 13 Sep 07 nicklas 196      * @param params The parameters.
11 13 Sep 07 nicklas 197      */
11 13 Sep 07 nicklas 198     public void setAlgorithmParameters(Vector params)
11 13 Sep 07 nicklas 199     {
11 13 Sep 07 nicklas 200         algorithmParameters = params;
11 13 Sep 07 nicklas 201     }
11 13 Sep 07 nicklas 202
11 13 Sep 07 nicklas 203     /** A vector of summary parameters generated by the CHP file generating algorithm */
11 13 Sep 07 nicklas 204     private Vector /*TagValuePairType*/ summaryParameters;
11 13 Sep 07 nicklas 205
11 13 Sep 07 nicklas 206     /** Gets the summary parameters.
11 13 Sep 07 nicklas 207      * @return The parameters.
11 13 Sep 07 nicklas 208      */
11 13 Sep 07 nicklas 209     public Vector getSummaryParameters() { return summaryParameters; }
11 13 Sep 07 nicklas 210     
11 13 Sep 07 nicklas 211     /** Sets the summary parameters.
11 13 Sep 07 nicklas 212      * @param params The parameters.
11 13 Sep 07 nicklas 213      */
11 13 Sep 07 nicklas 214     public void setSummaryParameters(Vector params)
11 13 Sep 07 nicklas 215     {
11 13 Sep 07 nicklas 216         summaryParameters = params;
11 13 Sep 07 nicklas 217     }
11 13 Sep 07 nicklas 218
11 13 Sep 07 nicklas 219     /** The background's for each of the zones (calculated by the expression algorithm) */
11 13 Sep 07 nicklas 220     private BackgroundZoneInfo backgroundZoneInfo;
11 13 Sep 07 nicklas 221
11 13 Sep 07 nicklas 222     /** Gets the background zone information.
11 13 Sep 07 nicklas 223      * @return The background information.
11 13 Sep 07 nicklas 224      */
11 13 Sep 07 nicklas 225     public BackgroundZoneInfo getBackgroundZoneInfo() { return backgroundZoneInfo; }
11 13 Sep 07 nicklas 226     
11 13 Sep 07 nicklas 227     /** Sets the background zone information.
11 13 Sep 07 nicklas 228      * @param zones The background information.
11 13 Sep 07 nicklas 229      */
11 13 Sep 07 nicklas 230     public void setBackgroundZoneInfo(BackgroundZoneInfo zones)
11 13 Sep 07 nicklas 231     {
11 13 Sep 07 nicklas 232         backgroundZoneInfo = zones;
11 13 Sep 07 nicklas 233     }
11 13 Sep 07 nicklas 234
11 13 Sep 07 nicklas 235     /** Gets a specific algorithm parameter given a name/tag
11 13 Sep 07 nicklas 236      * @return The specific algorithm parameter given a name/tag
11 13 Sep 07 nicklas 237      */
11 13 Sep 07 nicklas 238     public String getAlgorithmParameter(String tag) {
11 13 Sep 07 nicklas 239         if (algorithmParameters == null)
11 13 Sep 07 nicklas 240             return null;
11 13 Sep 07 nicklas 241         int n = algorithmParameters.size();
11 13 Sep 07 nicklas 242         for (int i=0; i<n; i++)
11 13 Sep 07 nicklas 243         {
11 13 Sep 07 nicklas 244             TagValuePair param = (TagValuePair) algorithmParameters.elementAt(i);
11 13 Sep 07 nicklas 245             if (param.getTag().compareTo(tag) == 0)
11 13 Sep 07 nicklas 246                 return param.getValue();
11 13 Sep 07 nicklas 247         }
11 13 Sep 07 nicklas 248         return null;
11 13 Sep 07 nicklas 249     }
11 13 Sep 07 nicklas 250
11 13 Sep 07 nicklas 251     /** Gets a specific summary parameter given a name/tag
11 13 Sep 07 nicklas 252      * @return The specific summary parameter given a name/tag
11 13 Sep 07 nicklas 253      */
11 13 Sep 07 nicklas 254     public String getSummaryParameter(String tag) {
11 13 Sep 07 nicklas 255         if (summaryParameters == null)
11 13 Sep 07 nicklas 256             return null;
11 13 Sep 07 nicklas 257         int n = summaryParameters.size();
11 13 Sep 07 nicklas 258         for (int i=0; i<n; i++)
11 13 Sep 07 nicklas 259         {
11 13 Sep 07 nicklas 260             TagValuePair param = (TagValuePair) summaryParameters.elementAt(i);
11 13 Sep 07 nicklas 261             if (param.getTag().compareTo(tag) == 0)
11 13 Sep 07 nicklas 262                 return param.getValue();
11 13 Sep 07 nicklas 263         }
11 13 Sep 07 nicklas 264         return null;
11 13 Sep 07 nicklas 265     }
11 13 Sep 07 nicklas 266
11 13 Sep 07 nicklas 267     /** Gets the background value for a given center coordinate
11 13 Sep 07 nicklas 268      * @return The background value for a given center coordinate
11 13 Sep 07 nicklas 269      */
11 13 Sep 07 nicklas 270     public BackgroundZoneType getBackgroundZone(int x, int y) {
11 13 Sep 07 nicklas 271         int n = backgroundZoneInfo.getNumberZones();
11 13 Sep 07 nicklas 272         for (int i=0; i<n; i++)
11 13 Sep 07 nicklas 273         {
11 13 Sep 07 nicklas 274             BackgroundZoneType zone = backgroundZoneInfo.getZone(i);
11 13 Sep 07 nicklas 275             if ((int)zone.getCenterX() == x && (int)zone.getCenterY() == y)
11 13 Sep 07 nicklas 276                 return zone;
11 13 Sep 07 nicklas 277         }
11 13 Sep 07 nicklas 278         return null;
11 13 Sep 07 nicklas 279     }
11 13 Sep 07 nicklas 280  
11 13 Sep 07 nicklas 281     /** Creates a new instance of CHPFileHeader */
11 13 Sep 07 nicklas 282     public CHPFileHeader() {
11 13 Sep 07 nicklas 283         magic=0;
11 13 Sep 07 nicklas 284         version=0;
11 13 Sep 07 nicklas 285         cols=0;
11 13 Sep 07 nicklas 286         rows=0;
11 13 Sep 07 nicklas 287         numProbeSets=0;
11 13 Sep 07 nicklas 288         assayType=UNKNOWN_ASSAY;
11 13 Sep 07 nicklas 289         chipType="";
11 13 Sep 07 nicklas 290         algorithmName="";
11 13 Sep 07 nicklas 291         algorithmVersion="";
11 13 Sep 07 nicklas 292         parentCellFile="";
11 13 Sep 07 nicklas 293         progID="";
11 13 Sep 07 nicklas 294         algorithmParameters = null;
11 13 Sep 07 nicklas 295         summaryParameters = null;
11 13 Sep 07 nicklas 296         backgroundZoneInfo = null;
11 13 Sep 07 nicklas 297     }    
11 13 Sep 07 nicklas 298 }