affyfusion-109/src/affymetrix/gcos/cel/CELFileHeaderData.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
11 13 Sep 07 nicklas 22 package affymetrix.gcos.cel;
11 13 Sep 07 nicklas 23
11 13 Sep 07 nicklas 24 import affymetrix.gcos.*;
11 13 Sep 07 nicklas 25 import java.util.*;
11 13 Sep 07 nicklas 26
11 13 Sep 07 nicklas 27 /** Stores information in the header of a GCOS CEL file. */
11 13 Sep 07 nicklas 28 public class CELFileHeaderData {
11 13 Sep 07 nicklas 29     
11 13 Sep 07 nicklas 30     /**  Magic number for identifying XDA format */
11 13 Sep 07 nicklas 31     private int magic;
11 13 Sep 07 nicklas 32     
11 13 Sep 07 nicklas 33     public int getMagic() { return magic; }
11 13 Sep 07 nicklas 34     public void setMagic(int value) { magic = value; }
11 13 Sep 07 nicklas 35
11 13 Sep 07 nicklas 36     /**  CEL file format version number */
11 13 Sep 07 nicklas 37     private int version;
11 13 Sep 07 nicklas 38
11 13 Sep 07 nicklas 39     public int getVersion() { return version; }
11 13 Sep 07 nicklas 40     public void setVersion(int value) { version = value; }
11 13 Sep 07 nicklas 41     
11 13 Sep 07 nicklas 42     /**  Number of columns in array */
11 13 Sep 07 nicklas 43     private int nCols;
11 13 Sep 07 nicklas 44     
11 13 Sep 07 nicklas 45     public int getCols() { return nCols; }
11 13 Sep 07 nicklas 46     public void setCols(int value) { nCols = value; }
11 13 Sep 07 nicklas 47     
11 13 Sep 07 nicklas 48     /**  Number of rows in array */
11 13 Sep 07 nicklas 49     private int nRows;
11 13 Sep 07 nicklas 50     
11 13 Sep 07 nicklas 51     public int getRows() { return nRows; }
11 13 Sep 07 nicklas 52     public void setRows(int value) { nRows = value; }
11 13 Sep 07 nicklas 53
11 13 Sep 07 nicklas 54     /**  Number of cells in array */
11 13 Sep 07 nicklas 55     private int nCells;
11 13 Sep 07 nicklas 56     
11 13 Sep 07 nicklas 57     public int getCells() { return nCells; }
11 13 Sep 07 nicklas 58     public void setCells(int value) { nCells = value; }
11 13 Sep 07 nicklas 59
11 13 Sep 07 nicklas 60     /**  Header information concatenated in a string */
11 13 Sep 07 nicklas 61     private String header;
11 13 Sep 07 nicklas 62
11 13 Sep 07 nicklas 63     public String getHeader() { return header; }
11 13 Sep 07 nicklas 64     public void setHeader(String value) { header = value; }
11 13 Sep 07 nicklas 65     
11 13 Sep 07 nicklas 66     /**  Algorithm name */
11 13 Sep 07 nicklas 67     private String alg;
11 13 Sep 07 nicklas 68
11 13 Sep 07 nicklas 69     public String getAlg() { return alg; }
11 13 Sep 07 nicklas 70     public void setAlg(String value) { alg = value; }
11 13 Sep 07 nicklas 71     
11 13 Sep 07 nicklas 72     /**  Chip type of array */
11 13 Sep 07 nicklas 73     private String chipType;
11 13 Sep 07 nicklas 74
11 13 Sep 07 nicklas 75     public String getChipType() { return chipType; }
11 13 Sep 07 nicklas 76     public void setChipType(String value) { chipType = value; }
11 13 Sep 07 nicklas 77     
11 13 Sep 07 nicklas 78     /**  DAT header string */
11 13 Sep 07 nicklas 79     private String datHeader;
11 13 Sep 07 nicklas 80
11 13 Sep 07 nicklas 81     public String getDatHeader() { return datHeader; }
11 13 Sep 07 nicklas 82     public void setDatHeader(String value) { datHeader = value; }
11 13 Sep 07 nicklas 83     
11 13 Sep 07 nicklas 84     /**  Cell margin */
11 13 Sep 07 nicklas 85     private int margin;
11 13 Sep 07 nicklas 86     
11 13 Sep 07 nicklas 87     public int getMargin() { return margin; }
11 13 Sep 07 nicklas 88     public void setMargin(int value) { margin = value; }
11 13 Sep 07 nicklas 89
11 13 Sep 07 nicklas 90     /**  Number of outliers */
11 13 Sep 07 nicklas 91     private int nOutliers;
11 13 Sep 07 nicklas 92
11 13 Sep 07 nicklas 93     public int getOutliers() { return nOutliers; }
11 13 Sep 07 nicklas 94     public void setOutliers(int value) { nOutliers = value; }
11 13 Sep 07 nicklas 95
11 13 Sep 07 nicklas 96     /**  Number of masked cells */
11 13 Sep 07 nicklas 97     private int nMasked;
11 13 Sep 07 nicklas 98
11 13 Sep 07 nicklas 99     public int getMasked() { return nMasked; }
11 13 Sep 07 nicklas 100     public void setMasked(int value) { nMasked = value; }
11 13 Sep 07 nicklas 101
11 13 Sep 07 nicklas 102     /**  Grid coordinates of array */
11 13 Sep 07 nicklas 103     private GridCoordinates cellGrid;
11 13 Sep 07 nicklas 104
11 13 Sep 07 nicklas 105     public GridCoordinates getGrid() { return cellGrid; }
11 13 Sep 07 nicklas 106     public void setGrid(GridCoordinates value) { cellGrid = new GridCoordinates(value); }
11 13 Sep 07 nicklas 107     
11 13 Sep 07 nicklas 108     /**  Algorithm parameters */
11 13 Sep 07 nicklas 109     private Vector /*TagValuePair*/ parameters;
11 13 Sep 07 nicklas 110     
11 13 Sep 07 nicklas 111     public Vector getParameters() { return parameters; }
11 13 Sep 07 nicklas 112     public void setParameters(Vector value) {
11 13 Sep 07 nicklas 113         parameters = new Vector();
11 13 Sep 07 nicklas 114         for (int i=0; i<value.size(); i++)
11 13 Sep 07 nicklas 115         {
11 13 Sep 07 nicklas 116             TagValuePair param = new TagValuePair((TagValuePair)value.elementAt(i));
11 13 Sep 07 nicklas 117             parameters.add(param);
11 13 Sep 07 nicklas 118         }
11 13 Sep 07 nicklas 119     }
11 13 Sep 07 nicklas 120     
11 13 Sep 07 nicklas 121     /** Parses the parameters from the input string.
11 13 Sep 07 nicklas 122      * @param params The parameters in the format of tag=value or tag:value
11 13 Sep 07 nicklas 123      */
11 13 Sep 07 nicklas 124     public void setParameters(String params) {
11 13 Sep 07 nicklas 125         parameters = new Vector();
11 13 Sep 07 nicklas 126         String p1 = params.replace(';', ' ');
11 13 Sep 07 nicklas 127         p1 = p1.replace(':' , '=');
11 13 Sep 07 nicklas 128         String s[] = p1.split(" ");
11 13 Sep 07 nicklas 129         for (int i=0; i<s.length; i++)
11 13 Sep 07 nicklas 130         {
11 13 Sep 07 nicklas 131             String[] tagvalue = s[i].split("=");
11 13 Sep 07 nicklas 132             TagValuePair p = new TagValuePair();
11 13 Sep 07 nicklas 133             p.setTag(tagvalue[0]);
11 13 Sep 07 nicklas 134             p.setValue(tagvalue[1]);
11 13 Sep 07 nicklas 135             parameters.add(p);
11 13 Sep 07 nicklas 136         }
11 13 Sep 07 nicklas 137     }
11 13 Sep 07 nicklas 138
11 13 Sep 07 nicklas 139     /** Parses the chip type from the header. */
11 13 Sep 07 nicklas 140     public void parseChipType() {
11 13 Sep 07 nicklas 141         int index = header.indexOf(".1sq");
11 13 Sep 07 nicklas 142         if (index == -1)
11 13 Sep 07 nicklas 143             return;
11 13 Sep 07 nicklas 144         int first = header.lastIndexOf(' ', index);
11 13 Sep 07 nicklas 145         chipType = header.substring(first+1, index);
11 13 Sep 07 nicklas 146     }
11 13 Sep 07 nicklas 147     
11 13 Sep 07 nicklas 148     /** Parses the cell margin from the header. */
11 13 Sep 07 nicklas 149     public void parseMargin() {
11 13 Sep 07 nicklas 150         int index = header.indexOf("CellMargin");
11 13 Sep 07 nicklas 151         if (index == -1)
11 13 Sep 07 nicklas 152             return;
11 13 Sep 07 nicklas 153         int len = "CellMargin".length();
11 13 Sep 07 nicklas 154         margin = Integer.parseInt(header.substring(index+len+1,index+len+2).trim());        
11 13 Sep 07 nicklas 155     }
11 13 Sep 07 nicklas 156     
11 13 Sep 07 nicklas 157     private CoordinatePoint parseCoordinate(String startString, String endString) {
11 13 Sep 07 nicklas 158         int start = header.indexOf(startString) + startString.length();
11 13 Sep 07 nicklas 159         int end = header.indexOf(endString, start);
11 13 Sep 07 nicklas 160         String[] scoord = header.substring(start, end).trim().split(" ");       
11 13 Sep 07 nicklas 161         CoordinatePoint coord = new CoordinatePoint();
11 13 Sep 07 nicklas 162         coord.setX(Integer.parseInt(scoord[0].trim()));
11 13 Sep 07 nicklas 163         coord.setY(Integer.parseInt(scoord[1].trim()));
11 13 Sep 07 nicklas 164         return coord;
11 13 Sep 07 nicklas 165     }
11 13 Sep 07 nicklas 166     
11 13 Sep 07 nicklas 167     /** Parses the grid from the header. */
11 13 Sep 07 nicklas 168     public void parseGrid() {
11 13 Sep 07 nicklas 169         cellGrid = new GridCoordinates();
11 13 Sep 07 nicklas 170         cellGrid.setUpperLeft(parseCoordinate("GridCornerUL=", "GridCornerUR="));
11 13 Sep 07 nicklas 171         cellGrid.setUpperRight(parseCoordinate("GridCornerUR=", "GridCornerLR="));
11 13 Sep 07 nicklas 172         cellGrid.setLowerRight(parseCoordinate("GridCornerLR=", "GridCornerLL="));
11 13 Sep 07 nicklas 173         cellGrid.setLowerLeft(parseCoordinate("GridCornerLL=", "Axis"));
11 13 Sep 07 nicklas 174     }
11 13 Sep 07 nicklas 175     
11 13 Sep 07 nicklas 176     /** Parses the DatHeader part from the header.*/
11 13 Sep 07 nicklas 177     public void parseDatHeader() {
11 13 Sep 07 nicklas 178         int index = header.indexOf("DatHeader=");
11 13 Sep 07 nicklas 179         if (index == -1)
11 13 Sep 07 nicklas 180             return;
11 13 Sep 07 nicklas 181         int last = header.indexOf("Algorithm=", index);
11 13 Sep 07 nicklas 182         String str = header.substring(index+10, last-1);
11 13 Sep 07 nicklas 183         datHeader = new String(str);
11 13 Sep 07 nicklas 184         
11 13 Sep 07 nicklas 185     }
11 13 Sep 07 nicklas 186     
11 13 Sep 07 nicklas 187     /** Creates a new instance of CELFileHeaderData */
11 13 Sep 07 nicklas 188     public CELFileHeaderData() {
11 13 Sep 07 nicklas 189         clear();
11 13 Sep 07 nicklas 190     }
11 13 Sep 07 nicklas 191     
11 13 Sep 07 nicklas 192     /** Clears the members. */
11 13 Sep 07 nicklas 193     public void clear() {
11 13 Sep 07 nicklas 194         magic=0;
11 13 Sep 07 nicklas 195         version=0;
11 13 Sep 07 nicklas 196         nCols=0;
11 13 Sep 07 nicklas 197         nRows=0;
11 13 Sep 07 nicklas 198         nCells=0;
11 13 Sep 07 nicklas 199         header="";
11 13 Sep 07 nicklas 200         alg="";
11 13 Sep 07 nicklas 201         chipType="";
11 13 Sep 07 nicklas 202         datHeader="";
11 13 Sep 07 nicklas 203         margin=0;
11 13 Sep 07 nicklas 204         nOutliers=0;
11 13 Sep 07 nicklas 205         nMasked=0;
11 13 Sep 07 nicklas 206         cellGrid=null;
11 13 Sep 07 nicklas 207         parameters=null;
11 13 Sep 07 nicklas 208     }
11 13 Sep 07 nicklas 209     
11 13 Sep 07 nicklas 210 }