139 |
10 Aug 06 |
enell |
1 |
/* |
139 |
10 Aug 06 |
enell |
$Id$ |
139 |
10 Aug 06 |
enell |
3 |
|
139 |
10 Aug 06 |
enell |
Copyright (C) 2006 Johan Enell |
139 |
10 Aug 06 |
enell |
5 |
|
139 |
10 Aug 06 |
enell |
This file is part of BASE - BioArray Software Environment. |
139 |
10 Aug 06 |
enell |
Available at http://base.thep.lu.se/ |
139 |
10 Aug 06 |
enell |
8 |
|
139 |
10 Aug 06 |
enell |
BASE is free software; you can redistribute it and/or modify it |
139 |
10 Aug 06 |
enell |
under the terms of the GNU General Public License as published by |
139 |
10 Aug 06 |
enell |
the Free Software Foundation; either version 2 of the License, or |
139 |
10 Aug 06 |
enell |
(at your option) any later version. |
139 |
10 Aug 06 |
enell |
13 |
|
139 |
10 Aug 06 |
enell |
BASE is distributed in the hope that it will be useful, but |
139 |
10 Aug 06 |
enell |
WITHOUT ANY WARRANTY; without even the implied warranty of |
139 |
10 Aug 06 |
enell |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
139 |
10 Aug 06 |
enell |
General Public License for more details. |
139 |
10 Aug 06 |
enell |
18 |
|
139 |
10 Aug 06 |
enell |
You should have received a copy of the GNU General Public License |
139 |
10 Aug 06 |
enell |
along with this program; if not, write to the Free Software |
139 |
10 Aug 06 |
enell |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
139 |
10 Aug 06 |
enell |
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 |
* The Reporter for the Smooth plug-in. It contains the position, reporter, |
139 |
10 Aug 06 |
enell |
* chromosome, basepair position and a link to its {@link Spot spot} data. |
139 |
10 Aug 06 |
enell |
31 |
* |
139 |
10 Aug 06 |
enell |
* @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 |
* Constructs a new Reporter. Chromosome X and Y are translated to 23 resp |
139 |
10 Aug 06 |
enell |
* 24. The start and end are used to calculate the chromosome position, (end - |
139 |
10 Aug 06 |
enell |
* start) / 2. |
139 |
10 Aug 06 |
enell |
50 |
* |
139 |
10 Aug 06 |
enell |
* @param position |
139 |
10 Aug 06 |
enell |
* the position on the assay |
139 |
10 Aug 06 |
enell |
* @param reporter |
139 |
10 Aug 06 |
enell |
* the id of the reporter |
139 |
10 Aug 06 |
enell |
* @param chromosome |
139 |
10 Aug 06 |
enell |
* the chromosome number |
139 |
10 Aug 06 |
enell |
* @param start |
139 |
10 Aug 06 |
enell |
* the basepair start position on its chromoeome |
139 |
10 Aug 06 |
enell |
* @param end |
139 |
10 Aug 06 |
enell |
* the basepair end position on its chromoeome |
139 |
10 Aug 06 |
enell |
* @param spot |
139 |
10 Aug 06 |
enell |
* the spotdata for this reporter |
139 |
10 Aug 06 |
enell |
* @throws BASEFileException |
139 |
10 Aug 06 |
enell |
* if any parameter cant be parsed as an integer or if chromosome |
139 |
10 Aug 06 |
enell |
* 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 |
* Gets the chromosome of this reporter. X is 23 and Y is 24 |
139 |
10 Aug 06 |
enell |
94 |
* |
139 |
10 Aug 06 |
enell |
* @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 |
* Gets the assay position of this reporter. |
139 |
10 Aug 06 |
enell |
104 |
* |
139 |
10 Aug 06 |
enell |
* @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 |
* Gets the reporter id of this reporter. |
139 |
10 Aug 06 |
enell |
114 |
* |
139 |
10 Aug 06 |
enell |
* @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 |
* Gets the basepair position on the chromosome of this reporter. |
139 |
10 Aug 06 |
enell |
124 |
* |
139 |
10 Aug 06 |
enell |
* @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 |
* Gets the spot data for this reporter. |
139 |
10 Aug 06 |
enell |
134 |
* |
139 |
10 Aug 06 |
enell |
* @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 |
} |