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 Spot for the smooth plugin. It contains intensity1, intensity2, M and the |
139 |
10 Aug 06 |
enell |
* new M. |
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 Spot |
139 |
10 Aug 06 |
enell |
35 |
{ |
139 |
10 Aug 06 |
enell |
36 |
private final float int1; |
139 |
10 Aug 06 |
enell |
37 |
|
139 |
10 Aug 06 |
enell |
38 |
private final float int2; |
139 |
10 Aug 06 |
enell |
39 |
|
139 |
10 Aug 06 |
enell |
40 |
private final float m; |
139 |
10 Aug 06 |
enell |
41 |
|
139 |
10 Aug 06 |
enell |
42 |
private float mPrim; |
139 |
10 Aug 06 |
enell |
43 |
|
139 |
10 Aug 06 |
enell |
44 |
/** |
139 |
10 Aug 06 |
enell |
* Constructs a spot from intensity1 and intensity2. It calculates the M |
139 |
10 Aug 06 |
enell |
* value. |
139 |
10 Aug 06 |
enell |
47 |
* |
139 |
10 Aug 06 |
enell |
* @param int1 |
139 |
10 Aug 06 |
enell |
* intensity for channel 1 |
139 |
10 Aug 06 |
enell |
* @param int2 |
139 |
10 Aug 06 |
enell |
* intensity for channel 2 |
139 |
10 Aug 06 |
enell |
* @throws BASEFileException |
139 |
10 Aug 06 |
enell |
* if the string cant be parsed as floats |
139 |
10 Aug 06 |
enell |
54 |
*/ |
139 |
10 Aug 06 |
enell |
55 |
public Spot(String int1, String int2) |
139 |
10 Aug 06 |
enell |
56 |
throws BASEFileException |
139 |
10 Aug 06 |
enell |
57 |
{ |
139 |
10 Aug 06 |
enell |
58 |
try |
139 |
10 Aug 06 |
enell |
59 |
{ |
139 |
10 Aug 06 |
enell |
60 |
this.int1 = Float.parseFloat(int1); |
139 |
10 Aug 06 |
enell |
61 |
this.int2 = Float.parseFloat(int2); |
139 |
10 Aug 06 |
enell |
62 |
this.m = (float) (Math.log(this.int1 / this.int2) / Math.log(2)); |
139 |
10 Aug 06 |
enell |
63 |
} |
139 |
10 Aug 06 |
enell |
64 |
catch (NumberFormatException e) |
139 |
10 Aug 06 |
enell |
65 |
{ |
139 |
10 Aug 06 |
enell |
66 |
throw new BASEFileException(e.getMessage()); |
139 |
10 Aug 06 |
enell |
67 |
} |
139 |
10 Aug 06 |
enell |
68 |
} |
139 |
10 Aug 06 |
enell |
69 |
|
139 |
10 Aug 06 |
enell |
70 |
/** |
139 |
10 Aug 06 |
enell |
* Gets the intensity for channel 1. |
139 |
10 Aug 06 |
enell |
72 |
* |
139 |
10 Aug 06 |
enell |
* @return intensity for channel 1 |
139 |
10 Aug 06 |
enell |
74 |
*/ |
139 |
10 Aug 06 |
enell |
75 |
public final float getInt1() |
139 |
10 Aug 06 |
enell |
76 |
{ |
139 |
10 Aug 06 |
enell |
77 |
return int1; |
139 |
10 Aug 06 |
enell |
78 |
} |
139 |
10 Aug 06 |
enell |
79 |
|
139 |
10 Aug 06 |
enell |
80 |
/** |
139 |
10 Aug 06 |
enell |
* Gets the intensity for channel 2. |
139 |
10 Aug 06 |
enell |
82 |
* |
139 |
10 Aug 06 |
enell |
* @return intensity for channel 2 |
139 |
10 Aug 06 |
enell |
84 |
*/ |
139 |
10 Aug 06 |
enell |
85 |
public final float getInt2() |
139 |
10 Aug 06 |
enell |
86 |
{ |
139 |
10 Aug 06 |
enell |
87 |
return int2; |
139 |
10 Aug 06 |
enell |
88 |
} |
139 |
10 Aug 06 |
enell |
89 |
|
139 |
10 Aug 06 |
enell |
90 |
/** |
139 |
10 Aug 06 |
enell |
* Gets the M value calculated from the intensity values. log2(int1 / int2) |
139 |
10 Aug 06 |
enell |
92 |
* |
139 |
10 Aug 06 |
enell |
* @return the M value |
139 |
10 Aug 06 |
enell |
94 |
*/ |
139 |
10 Aug 06 |
enell |
95 |
public float getM() |
139 |
10 Aug 06 |
enell |
96 |
{ |
139 |
10 Aug 06 |
enell |
97 |
return m; |
139 |
10 Aug 06 |
enell |
98 |
} |
139 |
10 Aug 06 |
enell |
99 |
|
139 |
10 Aug 06 |
enell |
100 |
/** |
139 |
10 Aug 06 |
enell |
* Gets the new M value. |
139 |
10 Aug 06 |
enell |
102 |
* |
139 |
10 Aug 06 |
enell |
* @return the new M |
139 |
10 Aug 06 |
enell |
104 |
*/ |
139 |
10 Aug 06 |
enell |
105 |
public float getMprim() |
139 |
10 Aug 06 |
enell |
106 |
{ |
139 |
10 Aug 06 |
enell |
107 |
return mPrim; |
139 |
10 Aug 06 |
enell |
108 |
} |
139 |
10 Aug 06 |
enell |
109 |
|
139 |
10 Aug 06 |
enell |
110 |
/** |
139 |
10 Aug 06 |
enell |
* Gets the A value calculated from the intensity values. A=log10(sqrt(int1 * |
139 |
10 Aug 06 |
enell |
* int2)). |
139 |
10 Aug 06 |
enell |
113 |
* |
139 |
10 Aug 06 |
enell |
* @return the A value |
139 |
10 Aug 06 |
enell |
115 |
*/ |
139 |
10 Aug 06 |
enell |
116 |
public float getA() |
139 |
10 Aug 06 |
enell |
117 |
{ |
139 |
10 Aug 06 |
enell |
118 |
return (float) Math.log10(Math.sqrt(int1 * int2)); |
139 |
10 Aug 06 |
enell |
119 |
} |
139 |
10 Aug 06 |
enell |
120 |
|
139 |
10 Aug 06 |
enell |
121 |
/** |
139 |
10 Aug 06 |
enell |
* Sets the new M value. |
139 |
10 Aug 06 |
enell |
123 |
* |
139 |
10 Aug 06 |
enell |
* @param m |
139 |
10 Aug 06 |
enell |
* the new M value |
139 |
10 Aug 06 |
enell |
126 |
*/ |
139 |
10 Aug 06 |
enell |
127 |
public void setMprim(float m) |
139 |
10 Aug 06 |
enell |
128 |
{ |
139 |
10 Aug 06 |
enell |
129 |
this.mPrim = m; |
139 |
10 Aug 06 |
enell |
130 |
} |
139 |
10 Aug 06 |
enell |
131 |
|
139 |
10 Aug 06 |
enell |
132 |
@Override |
139 |
10 Aug 06 |
enell |
133 |
public String toString() |
139 |
10 Aug 06 |
enell |
134 |
{ |
139 |
10 Aug 06 |
enell |
135 |
return getMprim() + "\t" + getA() + "\t" + (getMprim() - getM()); |
139 |
10 Aug 06 |
enell |
136 |
} |
139 |
10 Aug 06 |
enell |
137 |
} |