142 |
10 Aug 06 |
enell |
1 |
/* |
875 |
05 Dec 08 |
jari |
* $Id$ |
875 |
05 Dec 08 |
jari |
3 |
* |
142 |
10 Aug 06 |
enell |
* Copyright (C) 2006 Johan Enell |
875 |
05 Dec 08 |
jari |
* Copyright (C) 2008 Jari Häkkinen |
875 |
05 Dec 08 |
jari |
6 |
|
875 |
05 Dec 08 |
jari |
* This file is part of the se.lu.onk.Center plug-in for |
875 |
05 Dec 08 |
jari |
* BASE. Available at http://baseplugins.thep.lu.se/ and BASE web site |
875 |
05 Dec 08 |
jari |
* is http://base.thep.lu.se |
875 |
05 Dec 08 |
jari |
10 |
|
875 |
05 Dec 08 |
jari |
* This is free software; you can redistribute it and/or modify it |
875 |
05 Dec 08 |
jari |
* under the terms of the GNU General Public License as published by |
875 |
05 Dec 08 |
jari |
* the Free Software Foundation; either version 3 of the License, or |
875 |
05 Dec 08 |
jari |
* (at your option) any later version. |
875 |
05 Dec 08 |
jari |
15 |
|
875 |
05 Dec 08 |
jari |
* The software is distributed in the hope that it will be useful, but |
875 |
05 Dec 08 |
jari |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
875 |
05 Dec 08 |
jari |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
875 |
05 Dec 08 |
jari |
* General Public License for more details. |
875 |
05 Dec 08 |
jari |
20 |
|
142 |
10 Aug 06 |
enell |
* You should have received a copy of the GNU General Public License |
875 |
05 Dec 08 |
jari |
* along with this software. If not, see <http://www.gnu.org/licenses/>. |
142 |
10 Aug 06 |
enell |
23 |
*/ |
875 |
05 Dec 08 |
jari |
24 |
|
142 |
10 Aug 06 |
enell |
25 |
package center; |
142 |
10 Aug 06 |
enell |
26 |
|
142 |
10 Aug 06 |
enell |
27 |
public class Spot |
142 |
10 Aug 06 |
enell |
28 |
{ |
142 |
10 Aug 06 |
enell |
29 |
|
142 |
10 Aug 06 |
enell |
30 |
private int position; |
142 |
10 Aug 06 |
enell |
31 |
|
142 |
10 Aug 06 |
enell |
32 |
private int reporter; |
142 |
10 Aug 06 |
enell |
33 |
|
142 |
10 Aug 06 |
enell |
34 |
private float[] int2; |
142 |
10 Aug 06 |
enell |
35 |
|
142 |
10 Aug 06 |
enell |
36 |
private float[] int1; |
142 |
10 Aug 06 |
enell |
37 |
|
142 |
10 Aug 06 |
enell |
38 |
public Spot(int position, int reporter, int nbrOfAssays) |
142 |
10 Aug 06 |
enell |
39 |
{ |
142 |
10 Aug 06 |
enell |
40 |
this.position = position; |
142 |
10 Aug 06 |
enell |
41 |
this.reporter = reporter; |
142 |
10 Aug 06 |
enell |
42 |
this.int1 = new float[nbrOfAssays]; |
142 |
10 Aug 06 |
enell |
43 |
this.int2 = new float[nbrOfAssays]; |
142 |
10 Aug 06 |
enell |
44 |
} |
142 |
10 Aug 06 |
enell |
45 |
|
142 |
10 Aug 06 |
enell |
46 |
public void setInt1(float i1, int assay) |
142 |
10 Aug 06 |
enell |
47 |
{ |
142 |
10 Aug 06 |
enell |
48 |
int1[assay] = i1; |
142 |
10 Aug 06 |
enell |
49 |
} |
142 |
10 Aug 06 |
enell |
50 |
|
142 |
10 Aug 06 |
enell |
51 |
public void setInt2(float i2, int assay) |
142 |
10 Aug 06 |
enell |
52 |
{ |
142 |
10 Aug 06 |
enell |
53 |
int2[assay] = assay; |
142 |
10 Aug 06 |
enell |
54 |
} |
142 |
10 Aug 06 |
enell |
55 |
|
142 |
10 Aug 06 |
enell |
56 |
public void setM(float M, int i) |
142 |
10 Aug 06 |
enell |
57 |
{ |
142 |
10 Aug 06 |
enell |
58 |
setRatio((float) Math.pow(2, M), i); |
142 |
10 Aug 06 |
enell |
59 |
} |
142 |
10 Aug 06 |
enell |
60 |
|
142 |
10 Aug 06 |
enell |
61 |
public void setRatio(float ratio, int i) |
142 |
10 Aug 06 |
enell |
62 |
{ |
142 |
10 Aug 06 |
enell |
63 |
float A = getA(i); |
142 |
10 Aug 06 |
enell |
64 |
double ten_pow_2A = Math.pow(10, 2 * A); //10 ^ 2*A |
142 |
10 Aug 06 |
enell |
65 |
|
142 |
10 Aug 06 |
enell |
// sqrt(10^2*A * ratio) |
142 |
10 Aug 06 |
enell |
67 |
setInt1((float) Math.sqrt(ten_pow_2A * ratio), i); |
142 |
10 Aug 06 |
enell |
// sqrt(10^2*A / ratio) |
142 |
10 Aug 06 |
enell |
69 |
setInt2((float) Math.sqrt(ten_pow_2A / ratio), i); |
142 |
10 Aug 06 |
enell |
70 |
} |
142 |
10 Aug 06 |
enell |
71 |
|
142 |
10 Aug 06 |
enell |
72 |
public int getPos() |
142 |
10 Aug 06 |
enell |
73 |
{ |
142 |
10 Aug 06 |
enell |
74 |
return position; |
142 |
10 Aug 06 |
enell |
75 |
} |
142 |
10 Aug 06 |
enell |
76 |
|
142 |
10 Aug 06 |
enell |
77 |
public int getReporter() |
142 |
10 Aug 06 |
enell |
78 |
{ |
142 |
10 Aug 06 |
enell |
79 |
return reporter; |
142 |
10 Aug 06 |
enell |
80 |
} |
142 |
10 Aug 06 |
enell |
81 |
|
142 |
10 Aug 06 |
enell |
82 |
public float getInt1(int j) |
142 |
10 Aug 06 |
enell |
83 |
{ |
142 |
10 Aug 06 |
enell |
84 |
return int1[j]; |
142 |
10 Aug 06 |
enell |
85 |
} |
142 |
10 Aug 06 |
enell |
86 |
|
142 |
10 Aug 06 |
enell |
87 |
public float getInt2(int j) |
142 |
10 Aug 06 |
enell |
88 |
{ |
142 |
10 Aug 06 |
enell |
89 |
return int2[j]; |
142 |
10 Aug 06 |
enell |
90 |
} |
142 |
10 Aug 06 |
enell |
91 |
|
142 |
10 Aug 06 |
enell |
92 |
/** |
142 |
10 Aug 06 |
enell |
* Returns M as log2(intensity1 / intenisity2) |
142 |
10 Aug 06 |
enell |
94 |
* |
142 |
10 Aug 06 |
enell |
* @return |
142 |
10 Aug 06 |
enell |
96 |
*/ |
142 |
10 Aug 06 |
enell |
97 |
public float getM(int i) |
142 |
10 Aug 06 |
enell |
98 |
{ |
142 |
10 Aug 06 |
enell |
99 |
return (float) (Math.log(getRatio(i)) / Math.log(2)); |
142 |
10 Aug 06 |
enell |
100 |
} |
142 |
10 Aug 06 |
enell |
101 |
|
142 |
10 Aug 06 |
enell |
102 |
/** |
142 |
10 Aug 06 |
enell |
* Returns A as log10(sqrt(intensity1 * intensity2)) |
142 |
10 Aug 06 |
enell |
104 |
* |
142 |
10 Aug 06 |
enell |
* @return |
142 |
10 Aug 06 |
enell |
106 |
*/ |
142 |
10 Aug 06 |
enell |
107 |
public float getA(int i) |
142 |
10 Aug 06 |
enell |
108 |
{ |
142 |
10 Aug 06 |
enell |
109 |
return (float) (Math.log(Math.sqrt(getInt1(i) * getInt2(i))) / Math.log(10)); |
142 |
10 Aug 06 |
enell |
110 |
} |
142 |
10 Aug 06 |
enell |
111 |
|
142 |
10 Aug 06 |
enell |
112 |
/** |
142 |
10 Aug 06 |
enell |
* Returns retio as intensity1 / intensity2 |
142 |
10 Aug 06 |
enell |
114 |
* |
142 |
10 Aug 06 |
enell |
* @return |
142 |
10 Aug 06 |
enell |
116 |
*/ |
142 |
10 Aug 06 |
enell |
117 |
public float getRatio(int i) |
142 |
10 Aug 06 |
enell |
118 |
{ |
142 |
10 Aug 06 |
enell |
119 |
return getInt1(i) / getInt2(i); |
142 |
10 Aug 06 |
enell |
120 |
} |
142 |
10 Aug 06 |
enell |
121 |
|
142 |
10 Aug 06 |
enell |
122 |
public boolean isValid(int i) |
142 |
10 Aug 06 |
enell |
123 |
{ |
142 |
10 Aug 06 |
enell |
124 |
return !Float.isNaN(getInt1(i)) && !Float.isNaN(getInt2(i)); |
142 |
10 Aug 06 |
enell |
125 |
} |
142 |
10 Aug 06 |
enell |
126 |
} |