plugins/base1/se.lu.onk/trunk/Smooth/src/smooth/Reporter.java

Code
Comments
Other
Rev Date Author Line
139 10 Aug 06 enell 1 /*
139 10 Aug 06 enell 2  $Id$
139 10 Aug 06 enell 3
139 10 Aug 06 enell 4  Copyright (C) 2006 Johan Enell
139 10 Aug 06 enell 5
139 10 Aug 06 enell 6  This file is part of BASE - BioArray Software Environment.
139 10 Aug 06 enell 7  Available at http://base.thep.lu.se/
139 10 Aug 06 enell 8
139 10 Aug 06 enell 9  BASE is free software; you can redistribute it and/or modify it
139 10 Aug 06 enell 10  under the terms of the GNU General Public License as published by
139 10 Aug 06 enell 11  the Free Software Foundation; either version 2 of the License, or
139 10 Aug 06 enell 12  (at your option) any later version.
139 10 Aug 06 enell 13
139 10 Aug 06 enell 14  BASE is distributed in the hope that it will be useful, but
139 10 Aug 06 enell 15  WITHOUT ANY WARRANTY; without even the implied warranty of
139 10 Aug 06 enell 16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
139 10 Aug 06 enell 17  General Public License for more details.
139 10 Aug 06 enell 18
139 10 Aug 06 enell 19  You should have received a copy of the GNU General Public License
139 10 Aug 06 enell 20  along with this program; if not, write to the Free Software
139 10 Aug 06 enell 21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
139 10 Aug 06 enell 22  02111-1307, USA.
139 10 Aug 06 enell 23  */
139 10 Aug 06 enell 24 package smooth;
139 10 Aug 06 enell 25
139 10 Aug 06 enell 26 import basefile.BASEFileException;
139 10 Aug 06 enell 27
139 10 Aug 06 enell 28 /**
139 10 Aug 06 enell 29  * The Reporter for the Smooth plug-in. It contains the position, reporter,
139 10 Aug 06 enell 30  * chromosome, basepair position and a link to its {@link Spot spot} data.
139 10 Aug 06 enell 31  * 
139 10 Aug 06 enell 32  * @author Johan Enell, johan.enell@med.lu.se, Dept Oncology, Lund University
139 10 Aug 06 enell 33  */
139 10 Aug 06 enell 34 public class Reporter
139 10 Aug 06 enell 35 {
139 10 Aug 06 enell 36   private final int position;
139 10 Aug 06 enell 37
139 10 Aug 06 enell 38   private final int reporter;
139 10 Aug 06 enell 39
139 10 Aug 06 enell 40   private final int chromosome;
139 10 Aug 06 enell 41
139 10 Aug 06 enell 42   private final int chrPosition;
139 10 Aug 06 enell 43
139 10 Aug 06 enell 44   private final Spot spot;
139 10 Aug 06 enell 45
139 10 Aug 06 enell 46   /**
139 10 Aug 06 enell 47    * Constructs a new Reporter. Chromosome X and Y are translated to 23 resp
139 10 Aug 06 enell 48    * 24. The start and end are used to calculate the chromosome position, (end -
139 10 Aug 06 enell 49    * start) / 2.
139 10 Aug 06 enell 50    * 
139 10 Aug 06 enell 51    * @param position
139 10 Aug 06 enell 52    *        the position on the assay
139 10 Aug 06 enell 53    * @param reporter
139 10 Aug 06 enell 54    *        the id of the reporter
139 10 Aug 06 enell 55    * @param chromosome
139 10 Aug 06 enell 56    *        the chromosome number
139 10 Aug 06 enell 57    * @param start
139 10 Aug 06 enell 58    *        the basepair start position on its chromoeome
139 10 Aug 06 enell 59    * @param end
139 10 Aug 06 enell 60    *        the basepair end position on its chromoeome
139 10 Aug 06 enell 61    * @param spot
139 10 Aug 06 enell 62    *        the spotdata for this reporter
139 10 Aug 06 enell 63    * @throws BASEFileException
139 10 Aug 06 enell 64    *         if any parameter cant be parsed as an integer or if chromosome
139 10 Aug 06 enell 65    *         position is less then 1
139 10 Aug 06 enell 66    */
139 10 Aug 06 enell 67   public Reporter(String position, String reporter, String chromosome, String start, String end, Spot spot)
139 10 Aug 06 enell 68     throws BASEFileException
139 10 Aug 06 enell 69   {
139 10 Aug 06 enell 70     try
139 10 Aug 06 enell 71     {
139 10 Aug 06 enell 72       this.spot = spot;
139 10 Aug 06 enell 73       this.position = Integer.parseInt(position);
139 10 Aug 06 enell 74       this.reporter = Integer.parseInt(reporter);
139 10 Aug 06 enell 75
139 10 Aug 06 enell 76       int s = Integer.parseInt(start);
139 10 Aug 06 enell 77       int e = Integer.parseInt(end);
139 10 Aug 06 enell 78       this.chrPosition = (e - s) / 2 + s;
184 12 Oct 06 enell 79       if (chrPosition < 1) throw new BASEFileException("Error on reporter "+reporter+": Chromosome position must be greater then 0");
139 10 Aug 06 enell 80
139 10 Aug 06 enell 81       if (chromosome.equalsIgnoreCase("X")) this.chromosome = 23;
139 10 Aug 06 enell 82       else if (chromosome.equalsIgnoreCase("Y")) this.chromosome = 24;
139 10 Aug 06 enell 83       else this.chromosome = Integer.parseInt(chromosome);
139 10 Aug 06 enell 84     }
139 10 Aug 06 enell 85     catch (NumberFormatException e)
139 10 Aug 06 enell 86     {
139 10 Aug 06 enell 87       throw new BASEFileException(e.getMessage());
139 10 Aug 06 enell 88     }
139 10 Aug 06 enell 89
139 10 Aug 06 enell 90   }
139 10 Aug 06 enell 91
139 10 Aug 06 enell 92   /**
139 10 Aug 06 enell 93    * Gets the chromosome of this reporter. X is 23 and Y is 24
139 10 Aug 06 enell 94    * 
139 10 Aug 06 enell 95    * @return the chromosome
139 10 Aug 06 enell 96    */
139 10 Aug 06 enell 97   public final int getChromosome()
139 10 Aug 06 enell 98   {
139 10 Aug 06 enell 99     return chromosome;
139 10 Aug 06 enell 100   }
139 10 Aug 06 enell 101
139 10 Aug 06 enell 102   /**
139 10 Aug 06 enell 103    * Gets the assay position of this reporter.
139 10 Aug 06 enell 104    * 
139 10 Aug 06 enell 105    * @return the position
139 10 Aug 06 enell 106    */
139 10 Aug 06 enell 107   public final int getPosition()
139 10 Aug 06 enell 108   {
139 10 Aug 06 enell 109     return position;
139 10 Aug 06 enell 110   }
139 10 Aug 06 enell 111
139 10 Aug 06 enell 112   /**
139 10 Aug 06 enell 113    * Gets the reporter id of this reporter.
139 10 Aug 06 enell 114    * 
139 10 Aug 06 enell 115    * @return the reporter id
139 10 Aug 06 enell 116    */
139 10 Aug 06 enell 117   public final int getReporter()
139 10 Aug 06 enell 118   {
139 10 Aug 06 enell 119     return reporter;
139 10 Aug 06 enell 120   }
139 10 Aug 06 enell 121
139 10 Aug 06 enell 122   /**
139 10 Aug 06 enell 123    * Gets the basepair position on the chromosome of this reporter.
139 10 Aug 06 enell 124    * 
139 10 Aug 06 enell 125    * @return the chromosome position
139 10 Aug 06 enell 126    */
139 10 Aug 06 enell 127   public final int getChrPosition()
139 10 Aug 06 enell 128   {
139 10 Aug 06 enell 129     return chrPosition;
139 10 Aug 06 enell 130   }
139 10 Aug 06 enell 131
139 10 Aug 06 enell 132   /**
139 10 Aug 06 enell 133    * Gets the spot data for this reporter.
139 10 Aug 06 enell 134    * 
139 10 Aug 06 enell 135    * @return the spot
139 10 Aug 06 enell 136    */
139 10 Aug 06 enell 137   public final Spot getSpot()
139 10 Aug 06 enell 138   {
139 10 Aug 06 enell 139     return spot;
139 10 Aug 06 enell 140   }
139 10 Aug 06 enell 141
139 10 Aug 06 enell 142   @Override
139 10 Aug 06 enell 143   public String toString()
139 10 Aug 06 enell 144   {
139 10 Aug 06 enell 145     return position + "\t" + reporter;
139 10 Aug 06 enell 146   }
139 10 Aug 06 enell 147
139 10 Aug 06 enell 148 }