2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SlideDataElement.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.10 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/04/10 18:41:36 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
15 |
|
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
public class SlideDataElement extends ArrayElement implements ISlideDataElement { |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
protected String UID; |
2 |
26 Feb 07 |
jari |
20 |
protected int[] rows; |
2 |
26 Feb 07 |
jari |
21 |
protected int[] columns; |
2 |
26 Feb 07 |
jari |
22 |
protected float[] currentIntensity, trueIntensity; |
2 |
26 Feb 07 |
jari |
23 |
protected String[] extraFields; |
2 |
26 Feb 07 |
jari |
24 |
protected boolean isNull = false; |
2 |
26 Feb 07 |
jari |
25 |
protected boolean isNonZero = true; |
2 |
26 Feb 07 |
jari |
26 |
protected float pvalue=0; |
2 |
26 Feb 07 |
jari |
27 |
protected int flags=0; |
2 |
26 Feb 07 |
jari |
28 |
|
2 |
26 Feb 07 |
jari |
29 |
/** |
2 |
26 Feb 07 |
jari |
30 |
* |
2 |
26 Feb 07 |
jari |
* @param rows |
2 |
26 Feb 07 |
jari |
* @param cols |
2 |
26 Feb 07 |
jari |
* @param extraFields |
2 |
26 Feb 07 |
jari |
* @param uid |
2 |
26 Feb 07 |
jari |
35 |
*/ |
2 |
26 Feb 07 |
jari |
36 |
private SlideDataElement(int[] rows, int[] cols, String[] extraFields, String uid){ |
2 |
26 Feb 07 |
jari |
37 |
this.rows = rows; |
2 |
26 Feb 07 |
jari |
38 |
this.columns = cols; |
2 |
26 Feb 07 |
jari |
39 |
this.extraFields = extraFields; |
2 |
26 Feb 07 |
jari |
40 |
this.UID = uid; |
2 |
26 Feb 07 |
jari |
41 |
this.currentIntensity = new float[2]; |
2 |
26 Feb 07 |
jari |
42 |
this.trueIntensity = new float[2]; |
2 |
26 Feb 07 |
jari |
43 |
} |
2 |
26 Feb 07 |
jari |
44 |
public SlideDataElement(int[] rows, int[] cols, String[] extraFields, String uid, boolean isNull, boolean isNonZero){ |
2 |
26 Feb 07 |
jari |
45 |
this(rows, cols, extraFields, uid); |
2 |
26 Feb 07 |
jari |
46 |
this.isNull = isNull; |
2 |
26 Feb 07 |
jari |
47 |
this.isNonZero = isNonZero; |
2 |
26 Feb 07 |
jari |
48 |
} |
2 |
26 Feb 07 |
jari |
49 |
public SlideDataElement(int[] rows, int[] columns, float[] currentIntensities, float[] trueIntensities, String[] values) { |
2 |
26 Feb 07 |
jari |
50 |
this.rows = copyArray(rows); |
2 |
26 Feb 07 |
jari |
51 |
this.columns = copyArray(columns); |
2 |
26 Feb 07 |
jari |
52 |
this.currentIntensity = copyArray(currentIntensities); |
2 |
26 Feb 07 |
jari |
53 |
this.trueIntensity = copyArray(trueIntensities); |
2 |
26 Feb 07 |
jari |
54 |
this.extraFields = copyArray(values); |
2 |
26 Feb 07 |
jari |
55 |
} |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
public SlideDataElement() { |
2 |
26 Feb 07 |
jari |
58 |
this.currentIntensity = new float[2]; |
2 |
26 Feb 07 |
jari |
59 |
this.trueIntensity = new float[2]; |
2 |
26 Feb 07 |
jari |
60 |
} |
2 |
26 Feb 07 |
jari |
61 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SlideDataElement</code> with specified meta rows, |
2 |
26 Feb 07 |
jari |
* meta columns, intensities and descriptions. |
2 |
26 Feb 07 |
jari |
64 |
*/ |
2 |
26 Feb 07 |
jari |
65 |
public SlideDataElement(String UID, int[] rows, int[] columns, float[] intensities, String[] values) { |
2 |
26 Feb 07 |
jari |
66 |
this.UID = UID; |
2 |
26 Feb 07 |
jari |
67 |
this.rows = copyArray(rows); |
2 |
26 Feb 07 |
jari |
68 |
this.columns = copyArray(columns); |
2 |
26 Feb 07 |
jari |
69 |
this.currentIntensity = copyArray(intensities); |
2 |
26 Feb 07 |
jari |
70 |
this.trueIntensity = copyArray(intensities); |
2 |
26 Feb 07 |
jari |
71 |
this.extraFields = copyArray(values); |
2 |
26 Feb 07 |
jari |
72 |
} |
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
74 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SlideDataElement</code> with specified meta rows, |
2 |
26 Feb 07 |
jari |
* meta columns, intensities and descriptions. |
2 |
26 Feb 07 |
jari |
77 |
*/ |
2 |
26 Feb 07 |
jari |
78 |
public SlideDataElement(int[] rows, int[] columns, float[] intensities, String[] values) { |
2 |
26 Feb 07 |
jari |
79 |
this("", rows, columns, intensities, values); |
2 |
26 Feb 07 |
jari |
80 |
} |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
82 |
/** |
2 |
26 Feb 07 |
jari |
* Copy constructor. |
2 |
26 Feb 07 |
jari |
84 |
*/ |
2 |
26 Feb 07 |
jari |
85 |
public SlideDataElement(ISlideDataElement sde) { |
2 |
26 Feb 07 |
jari |
86 |
this.UID = sde.getUID(); |
2 |
26 Feb 07 |
jari |
87 |
this.rows = sde.getRows(); |
2 |
26 Feb 07 |
jari |
88 |
this.columns = sde.getColumns(); |
2 |
26 Feb 07 |
jari |
89 |
this.currentIntensity = copyArray(sde.getCurrentIntensity()); |
2 |
26 Feb 07 |
jari |
90 |
this.trueIntensity = copyArray(sde.getTrueIntensity()); |
2 |
26 Feb 07 |
jari |
91 |
this.extraFields = sde.getExtraFields(); |
2 |
26 Feb 07 |
jari |
92 |
} |
2 |
26 Feb 07 |
jari |
93 |
|
2 |
26 Feb 07 |
jari |
94 |
public void setRows(int[] r){this.rows = copyArray(r);} |
2 |
26 Feb 07 |
jari |
95 |
public void setColumns(int[] c){this.columns = copyArray(c);} |
2 |
26 Feb 07 |
jari |
96 |
public String[] getValues() {return extraFields;} |
2 |
26 Feb 07 |
jari |
97 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the extra fields (annotation) |
2 |
26 Feb 07 |
jari |
99 |
*/ |
2 |
26 Feb 07 |
jari |
100 |
public void setExtraFields(String [] values){ |
2 |
26 Feb 07 |
jari |
101 |
if(values == null) return; |
2 |
26 Feb 07 |
jari |
102 |
if(this.extraFields == null) |
2 |
26 Feb 07 |
jari |
103 |
this.extraFields = values; |
2 |
26 Feb 07 |
jari |
104 |
else{ |
2 |
26 Feb 07 |
jari |
105 |
String [] newFields = new String[this.extraFields.length+values.length]; |
2 |
26 Feb 07 |
jari |
106 |
for(int i = 0; i < this.extraFields.length; i++) |
2 |
26 Feb 07 |
jari |
107 |
newFields[i] = this.extraFields[i]; |
2 |
26 Feb 07 |
jari |
108 |
for(int i = 0; i < values.length; i++) |
2 |
26 Feb 07 |
jari |
109 |
newFields[i+this.extraFields.length] = values[i]; |
2 |
26 Feb 07 |
jari |
110 |
this.extraFields = newFields; |
2 |
26 Feb 07 |
jari |
111 |
} |
2 |
26 Feb 07 |
jari |
112 |
} |
2 |
26 Feb 07 |
jari |
113 |
|
2 |
26 Feb 07 |
jari |
114 |
/** |
2 |
26 Feb 07 |
jari |
* Creates clone of a string array. |
2 |
26 Feb 07 |
jari |
116 |
*/ |
2 |
26 Feb 07 |
jari |
117 |
private String[] copyArray(String[] array) { |
2 |
26 Feb 07 |
jari |
118 |
if (array == null) { |
2 |
26 Feb 07 |
jari |
119 |
return null; |
2 |
26 Feb 07 |
jari |
120 |
} |
2 |
26 Feb 07 |
jari |
121 |
String[] result = new String[array.length]; |
2 |
26 Feb 07 |
jari |
122 |
System.arraycopy(array, 0, result, 0, array.length); |
2 |
26 Feb 07 |
jari |
123 |
return result; |
2 |
26 Feb 07 |
jari |
124 |
} |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
126 |
/** |
2 |
26 Feb 07 |
jari |
* Creates clone of an int array. |
2 |
26 Feb 07 |
jari |
128 |
*/ |
2 |
26 Feb 07 |
jari |
129 |
private int[] copyArray(int[] array) { |
2 |
26 Feb 07 |
jari |
130 |
if (array == null) { |
2 |
26 Feb 07 |
jari |
131 |
return null; |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
int[] result = new int[array.length]; |
2 |
26 Feb 07 |
jari |
134 |
System.arraycopy(array, 0, result, 0, array.length); |
2 |
26 Feb 07 |
jari |
135 |
return result; |
2 |
26 Feb 07 |
jari |
136 |
} |
2 |
26 Feb 07 |
jari |
137 |
|
2 |
26 Feb 07 |
jari |
138 |
/** |
2 |
26 Feb 07 |
jari |
* Creates clone of a float array. |
2 |
26 Feb 07 |
jari |
140 |
*/ |
2 |
26 Feb 07 |
jari |
141 |
private float[] copyArray(float[] array) { |
2 |
26 Feb 07 |
jari |
142 |
if (array == null) { |
2 |
26 Feb 07 |
jari |
143 |
return null; |
2 |
26 Feb 07 |
jari |
144 |
} |
2 |
26 Feb 07 |
jari |
145 |
float[] result = new float[array.length]; |
2 |
26 Feb 07 |
jari |
146 |
System.arraycopy(array, 0, result, 0, array.length); |
2 |
26 Feb 07 |
jari |
147 |
return result; |
2 |
26 Feb 07 |
jari |
148 |
} |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
150 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of spot meta rows. |
2 |
26 Feb 07 |
jari |
152 |
*/ |
2 |
26 Feb 07 |
jari |
153 |
public int[] getRows() { |
2 |
26 Feb 07 |
jari |
154 |
return rows; |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of spot meta column. |
2 |
26 Feb 07 |
jari |
159 |
*/ |
2 |
26 Feb 07 |
jari |
160 |
public int[] getColumns() { |
2 |
26 Feb 07 |
jari |
161 |
return columns; |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of spot descriptions. |
2 |
26 Feb 07 |
jari |
166 |
*/ |
2 |
26 Feb 07 |
jari |
167 |
public String[] getExtraFields() { |
2 |
26 Feb 07 |
jari |
168 |
if(extraFields == null) |
2 |
26 Feb 07 |
jari |
169 |
return new String[0]; |
2 |
26 Feb 07 |
jari |
170 |
return extraFields; |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of current intensities. |
2 |
26 Feb 07 |
jari |
175 |
*/ |
2 |
26 Feb 07 |
jari |
176 |
public float[] getCurrentIntensity() { |
2 |
26 Feb 07 |
jari |
177 |
return currentIntensity; |
2 |
26 Feb 07 |
jari |
178 |
} |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of true intensities. |
2 |
26 Feb 07 |
jari |
182 |
*/ |
2 |
26 Feb 07 |
jari |
183 |
public float[] getTrueIntensity() { |
2 |
26 Feb 07 |
jari |
184 |
return trueIntensity; |
2 |
26 Feb 07 |
jari |
185 |
} |
2 |
26 Feb 07 |
jari |
186 |
|
2 |
26 Feb 07 |
jari |
187 |
/** |
2 |
26 Feb 07 |
jari |
* Sets value for specified row type. |
2 |
26 Feb 07 |
jari |
189 |
*/ |
2 |
26 Feb 07 |
jari |
190 |
public void setRow(int rowType, int value) { |
2 |
26 Feb 07 |
jari |
191 |
switch (rowType) { |
2 |
26 Feb 07 |
jari |
192 |
case BASE: rows[0] = value; break; |
2 |
26 Feb 07 |
jari |
193 |
case META: rows[1] = value; break; |
2 |
26 Feb 07 |
jari |
194 |
case SUB : rows[2] = value; break; |
2 |
26 Feb 07 |
jari |
195 |
} |
2 |
26 Feb 07 |
jari |
196 |
} |
2 |
26 Feb 07 |
jari |
197 |
|
2 |
26 Feb 07 |
jari |
198 |
/** |
2 |
26 Feb 07 |
jari |
* Sets value for specified column type. |
2 |
26 Feb 07 |
jari |
200 |
*/ |
2 |
26 Feb 07 |
jari |
201 |
public void setColumn(int columnType, int value) { |
2 |
26 Feb 07 |
jari |
202 |
switch (columnType) { |
2 |
26 Feb 07 |
jari |
203 |
case BASE: columns[0] = value; break; |
2 |
26 Feb 07 |
jari |
204 |
case META: columns[1] = value; break; |
2 |
26 Feb 07 |
jari |
205 |
case SUB: columns[2] = value; break; |
2 |
26 Feb 07 |
jari |
206 |
} |
2 |
26 Feb 07 |
jari |
207 |
} |
2 |
26 Feb 07 |
jari |
208 |
|
2 |
26 Feb 07 |
jari |
//Replaces getRow, getMetaRow, getSubRow |
2 |
26 Feb 07 |
jari |
210 |
public int getRow(int rowType) { |
2 |
26 Feb 07 |
jari |
211 |
int targetRow = -1; |
2 |
26 Feb 07 |
jari |
212 |
switch (rowType) { |
2 |
26 Feb 07 |
jari |
213 |
case BASE: targetRow = rows[0]; break; |
2 |
26 Feb 07 |
jari |
214 |
case META: targetRow = rows[1]; break; |
2 |
26 Feb 07 |
jari |
215 |
case SUB: targetRow = rows[2]; break; |
2 |
26 Feb 07 |
jari |
216 |
} |
2 |
26 Feb 07 |
jari |
217 |
return targetRow; |
2 |
26 Feb 07 |
jari |
218 |
} |
2 |
26 Feb 07 |
jari |
219 |
|
2 |
26 Feb 07 |
jari |
220 |
/** |
2 |
26 Feb 07 |
jari |
* Returns index of specified column type. |
2 |
26 Feb 07 |
jari |
222 |
*/ |
2 |
26 Feb 07 |
jari |
223 |
public int getColumn(int columnType) { |
2 |
26 Feb 07 |
jari |
224 |
int targetColumn = -1; |
2 |
26 Feb 07 |
jari |
225 |
switch (columnType) { |
2 |
26 Feb 07 |
jari |
226 |
case BASE: targetColumn = columns[0]; break; |
2 |
26 Feb 07 |
jari |
227 |
case META: targetColumn = columns[1]; break; |
2 |
26 Feb 07 |
jari |
228 |
case SUB: targetColumn = columns[2]; break; |
2 |
26 Feb 07 |
jari |
229 |
} |
2 |
26 Feb 07 |
jari |
230 |
return targetColumn; |
2 |
26 Feb 07 |
jari |
231 |
} |
2 |
26 Feb 07 |
jari |
232 |
|
2 |
26 Feb 07 |
jari |
233 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a spot location. |
2 |
26 Feb 07 |
jari |
235 |
*/ |
2 |
26 Feb 07 |
jari |
236 |
public int getLocation(int positionType, int features) { |
2 |
26 Feb 07 |
jari |
237 |
int location = -1; |
2 |
26 Feb 07 |
jari |
238 |
switch (positionType) { |
2 |
26 Feb 07 |
jari |
239 |
case BASE: location = columns[0] + (rows[0] - 1) * features; break; |
2 |
26 Feb 07 |
jari |
240 |
case META: location = columns[1] + (rows[1] - 1) * features; break; |
2 |
26 Feb 07 |
jari |
241 |
case SUB : location = columns[2] + (rows[2] - 1) * features; break; |
2 |
26 Feb 07 |
jari |
242 |
} |
2 |
26 Feb 07 |
jari |
243 |
return location; |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
|
2 |
26 Feb 07 |
jari |
246 |
/** |
2 |
26 Feb 07 |
jari |
* Returns intensity value by its specified type. |
2 |
26 Feb 07 |
jari |
248 |
*/ |
2 |
26 Feb 07 |
jari |
249 |
public float getIntensity(int intensityType) { |
2 |
26 Feb 07 |
jari |
250 |
float targetIntensity = -1; |
2 |
26 Feb 07 |
jari |
251 |
switch (intensityType) { |
2 |
26 Feb 07 |
jari |
252 |
case CY3: |
2 |
26 Feb 07 |
jari |
253 |
targetIntensity = currentIntensity[0]; |
2 |
26 Feb 07 |
jari |
254 |
break; |
2 |
26 Feb 07 |
jari |
255 |
case CY5: |
2 |
26 Feb 07 |
jari |
256 |
targetIntensity = currentIntensity[1]; |
2 |
26 Feb 07 |
jari |
257 |
break; |
2 |
26 Feb 07 |
jari |
258 |
} |
2 |
26 Feb 07 |
jari |
259 |
return (float)targetIntensity; |
2 |
26 Feb 07 |
jari |
260 |
} |
2 |
26 Feb 07 |
jari |
261 |
|
2 |
26 Feb 07 |
jari |
262 |
/** |
2 |
26 Feb 07 |
jari |
* Sets an intensity value. |
2 |
26 Feb 07 |
jari |
264 |
*/ |
2 |
26 Feb 07 |
jari |
265 |
public void setIntensity(int intensityType, float value) { |
2 |
26 Feb 07 |
jari |
266 |
switch (intensityType) { |
2 |
26 Feb 07 |
jari |
267 |
case CY3:{ |
2 |
26 Feb 07 |
jari |
268 |
currentIntensity[0] = value; |
2 |
26 Feb 07 |
jari |
269 |
break; |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
case CY5:{ |
2 |
26 Feb 07 |
jari |
272 |
currentIntensity[1] = value; |
2 |
26 Feb 07 |
jari |
273 |
break; |
2 |
26 Feb 07 |
jari |
274 |
} |
2 |
26 Feb 07 |
jari |
275 |
} |
2 |
26 Feb 07 |
jari |
276 |
} |
2 |
26 Feb 07 |
jari |
277 |
|
2 |
26 Feb 07 |
jari |
278 |
/** |
2 |
26 Feb 07 |
jari |
* Sets current (altered) intensity |
2 |
26 Feb 07 |
jari |
280 |
*/ |
2 |
26 Feb 07 |
jari |
281 |
public void setCurrentIntensity(int intensityType, float value){ |
2 |
26 Feb 07 |
jari |
282 |
switch (intensityType) { |
2 |
26 Feb 07 |
jari |
283 |
case CY3:{ |
2 |
26 Feb 07 |
jari |
284 |
currentIntensity[0] = value; |
2 |
26 Feb 07 |
jari |
285 |
break; |
2 |
26 Feb 07 |
jari |
286 |
} |
2 |
26 Feb 07 |
jari |
287 |
case CY5:{ |
2 |
26 Feb 07 |
jari |
288 |
currentIntensity[1] = value; |
2 |
26 Feb 07 |
jari |
289 |
break; |
2 |
26 Feb 07 |
jari |
290 |
} |
2 |
26 Feb 07 |
jari |
291 |
} |
2 |
26 Feb 07 |
jari |
292 |
} |
2 |
26 Feb 07 |
jari |
293 |
/** |
2 |
26 Feb 07 |
jari |
* Sets true intensity value. |
2 |
26 Feb 07 |
jari |
295 |
*/ |
2 |
26 Feb 07 |
jari |
296 |
public void setTrueIntensity(int intensityType, float value) { |
2 |
26 Feb 07 |
jari |
297 |
switch (intensityType) { |
2 |
26 Feb 07 |
jari |
298 |
case CY3: trueIntensity[0] = value; break; |
2 |
26 Feb 07 |
jari |
299 |
case CY5: trueIntensity[1] = value; break; |
2 |
26 Feb 07 |
jari |
300 |
} |
2 |
26 Feb 07 |
jari |
301 |
} |
2 |
26 Feb 07 |
jari |
302 |
|
2 |
26 Feb 07 |
jari |
//Replaces getTrueCy3, getTrueCy5 |
2 |
26 Feb 07 |
jari |
304 |
public float getTrueIntensity(int intensityType) { |
2 |
26 Feb 07 |
jari |
305 |
float targetIntensity = -1; |
2 |
26 Feb 07 |
jari |
306 |
switch (intensityType) { |
2 |
26 Feb 07 |
jari |
307 |
case CY3: try {targetIntensity = trueIntensity[0]; break;} catch (NullPointerException npe) {targetIntensity = 0; break;} |
2 |
26 Feb 07 |
jari |
308 |
case CY5: try {targetIntensity = trueIntensity[1]; break;} catch (NullPointerException npe) {targetIntensity = 0; break;} |
2 |
26 Feb 07 |
jari |
//TODO remove try/catch blocks above. |
2 |
26 Feb 07 |
jari |
310 |
} |
2 |
26 Feb 07 |
jari |
311 |
return targetIntensity; |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
|
2 |
26 Feb 07 |
jari |
314 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a ratio value for specified intensities. |
2 |
26 Feb 07 |
jari |
316 |
*/ |
2 |
26 Feb 07 |
jari |
317 |
public float getRatio(int intensityIndex1, int intensityIndex2, int logState) { |
2 |
26 Feb 07 |
jari |
318 |
return getRatio(intensityIndex1, intensityIndex2, logState, isNonZero); |
2 |
26 Feb 07 |
jari |
319 |
} |
2 |
26 Feb 07 |
jari |
320 |
|
2 |
26 Feb 07 |
jari |
321 |
public float getRatio(int intensityIndex1, int intensityIndex2, int logState, boolean nonZero) { |
2 |
26 Feb 07 |
jari |
322 |
float ratio; |
2 |
26 Feb 07 |
jari |
323 |
if (nonZero) { |
2 |
26 Feb 07 |
jari |
324 |
if ((getIntensity(intensityIndex1) == 0) && (getIntensity(intensityIndex2) == 0)) { |
2 |
26 Feb 07 |
jari |
325 |
return Float.NaN; |
2 |
26 Feb 07 |
jari |
326 |
} else if (getIntensity(intensityIndex1) == 0) { |
2 |
26 Feb 07 |
jari |
327 |
ratio = 1f / (float)getIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
328 |
} else if (getIntensity(intensityIndex2) == 0) { |
2 |
26 Feb 07 |
jari |
329 |
ratio = (float)getIntensity(intensityIndex1)/1f; |
2 |
26 Feb 07 |
jari |
330 |
} else { |
2 |
26 Feb 07 |
jari |
331 |
ratio = (float)getIntensity(intensityIndex1)/(float)getIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
332 |
} |
2 |
26 Feb 07 |
jari |
333 |
} else { |
2 |
26 Feb 07 |
jari |
334 |
if (getIntensity(intensityIndex1) == 0) return Float.NaN; |
2 |
26 Feb 07 |
jari |
335 |
if (getIntensity(intensityIndex2) == 0) return Float.NaN; |
2 |
26 Feb 07 |
jari |
336 |
ratio = (float)getIntensity(intensityIndex1)/(float)getIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
if (logState == IData.LOG) |
2 |
26 Feb 07 |
jari |
//LOG |
2 |
26 Feb 07 |
jari |
//ratio = (float) Xcon.log2(ratio); |
2 |
26 Feb 07 |
jari |
341 |
ratio = (float)(Math.log(ratio)/Math.log(2.0)); |
2 |
26 Feb 07 |
jari |
342 |
return ratio; |
2 |
26 Feb 07 |
jari |
343 |
} |
2 |
26 Feb 07 |
jari |
344 |
|
2 |
26 Feb 07 |
jari |
345 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a true ratio value for specified intensities. |
2 |
26 Feb 07 |
jari |
347 |
*/ |
2 |
26 Feb 07 |
jari |
348 |
public double getTrueRatio(int intensityIndex1, int intensityIndex2, int logState) { |
2 |
26 Feb 07 |
jari |
349 |
return getTrueRatio(intensityIndex1, intensityIndex2, logState, isNonZero); |
2 |
26 Feb 07 |
jari |
350 |
} |
2 |
26 Feb 07 |
jari |
351 |
|
2 |
26 Feb 07 |
jari |
352 |
public double getTrueRatio(int intensityIndex1, int intensityIndex2, int logState, boolean nonZero) { |
2 |
26 Feb 07 |
jari |
353 |
double ratio; |
2 |
26 Feb 07 |
jari |
354 |
if (nonZero) { |
2 |
26 Feb 07 |
jari |
355 |
if ((getTrueIntensity(intensityIndex1) == 0) && (getTrueIntensity(intensityIndex2) == 0)) { |
2 |
26 Feb 07 |
jari |
356 |
return Float.NaN; |
2 |
26 Feb 07 |
jari |
357 |
} else if (getTrueIntensity(intensityIndex1) == 0) { |
2 |
26 Feb 07 |
jari |
358 |
ratio = (double) 1.0 / (double) getTrueIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
359 |
} else if (getTrueIntensity(intensityIndex2) == 0) { |
2 |
26 Feb 07 |
jari |
360 |
ratio = (double) getTrueIntensity(intensityIndex1) / (double) 1.0; |
2 |
26 Feb 07 |
jari |
361 |
} else { |
2 |
26 Feb 07 |
jari |
362 |
ratio = (double) getTrueIntensity(intensityIndex1) / (double) getTrueIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
363 |
} |
2 |
26 Feb 07 |
jari |
364 |
} else { |
2 |
26 Feb 07 |
jari |
365 |
if (getTrueIntensity(intensityIndex1) == 0) return Float.NaN; |
2 |
26 Feb 07 |
jari |
366 |
if (getTrueIntensity(intensityIndex2) == 0) return Float.NaN; |
2 |
26 Feb 07 |
jari |
367 |
ratio = (double) getTrueIntensity(intensityIndex1) / (double) getTrueIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
368 |
} |
2 |
26 Feb 07 |
jari |
369 |
|
2 |
26 Feb 07 |
jari |
370 |
if (logState == IData.LOG) |
2 |
26 Feb 07 |
jari |
//LOG |
2 |
26 Feb 07 |
jari |
//ratio = (float) Xcon.log2(ratio); |
2 |
26 Feb 07 |
jari |
373 |
ratio = (float)(Math.log(ratio)/Math.log(2.0)); |
2 |
26 Feb 07 |
jari |
374 |
return ratio; |
2 |
26 Feb 07 |
jari |
375 |
} |
2 |
26 Feb 07 |
jari |
376 |
|
2 |
26 Feb 07 |
jari |
377 |
public float getIntensityMean(int intensityType) { |
2 |
26 Feb 07 |
jari |
378 |
return(float) 0.0; |
2 |
26 Feb 07 |
jari |
379 |
} |
2 |
26 Feb 07 |
jari |
380 |
|
2 |
26 Feb 07 |
jari |
381 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the non-zero flag. |
2 |
26 Feb 07 |
jari |
383 |
*/ |
2 |
26 Feb 07 |
jari |
384 |
public void setNonZero(boolean state) {this.isNonZero = state;} |
2 |
26 Feb 07 |
jari |
385 |
|
2 |
26 Feb 07 |
jari |
//pcahan, to implement ISlideDataElement changes for Affy |
2 |
26 Feb 07 |
jari |
387 |
public void setDetection(String value){} |
2 |
26 Feb 07 |
jari |
388 |
public String getDetection(){ |
2 |
26 Feb 07 |
jari |
389 |
return ""; |
2 |
26 Feb 07 |
jari |
390 |
} |
2 |
26 Feb 07 |
jari |
391 |
|
2 |
26 Feb 07 |
jari |
//wwang add p-value for affy |
2 |
26 Feb 07 |
jari |
393 |
public void setPvalue(float value){ |
2 |
26 Feb 07 |
jari |
394 |
pvalue=value; |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
|
2 |
26 Feb 07 |
jari |
397 |
public float getPvalue(){ |
2 |
26 Feb 07 |
jari |
398 |
return pvalue; |
2 |
26 Feb 07 |
jari |
399 |
} |
2 |
26 Feb 07 |
jari |
400 |
public void setGenePixFlags(int value){ |
2 |
26 Feb 07 |
jari |
401 |
flags=value; |
2 |
26 Feb 07 |
jari |
402 |
} |
2 |
26 Feb 07 |
jari |
403 |
|
2 |
26 Feb 07 |
jari |
404 |
public int getGenePixFlags(){ |
2 |
26 Feb 07 |
jari |
405 |
return flags; |
2 |
26 Feb 07 |
jari |
406 |
} |
2 |
26 Feb 07 |
jari |
407 |
|
2 |
26 Feb 07 |
jari |
408 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the non-zero flag. |
2 |
26 Feb 07 |
jari |
410 |
*/ |
2 |
26 Feb 07 |
jari |
411 |
public boolean isNonZero() {return this.isNonZero;} |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the isNull flag. |
2 |
26 Feb 07 |
jari |
415 |
*/ |
2 |
26 Feb 07 |
jari |
416 |
public void setIsNull(boolean state) {this.isNull = state;} |
2 |
26 Feb 07 |
jari |
417 |
|
2 |
26 Feb 07 |
jari |
418 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the isNull flag. |
2 |
26 Feb 07 |
jari |
420 |
*/ |
2 |
26 Feb 07 |
jari |
421 |
public boolean getIsNull() {return this.isNull;} |
2 |
26 Feb 07 |
jari |
422 |
|
2 |
26 Feb 07 |
jari |
423 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if spot contains no zero intensities. |
2 |
26 Feb 07 |
jari |
425 |
*/ |
2 |
26 Feb 07 |
jari |
426 |
public boolean hasNoZeros() { |
2 |
26 Feb 07 |
jari |
427 |
if ((getTrueIntensity(CY3) != 0) && (getTrueIntensity(CY5) != 0)) return true; |
2 |
26 Feb 07 |
jari |
428 |
else return false; |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
431 |
public String getAttributeString(int number) { |
2 |
26 Feb 07 |
jari |
432 |
String retVal = ""; |
2 |
26 Feb 07 |
jari |
433 |
int coordinatePairs = TMEV.getCoordinatePairCount() * 2; //Did you see the (* 2)? |
2 |
26 Feb 07 |
jari |
434 |
int intensities = TMEV.getIntensityCount(); |
2 |
26 Feb 07 |
jari |
435 |
int extraFields = this.extraFields.length; |
2 |
26 Feb 07 |
jari |
436 |
|
2 |
26 Feb 07 |
jari |
437 |
if (number < coordinatePairs) { |
2 |
26 Feb 07 |
jari |
438 |
if (number % 2 == 0) |
2 |
26 Feb 07 |
jari |
439 |
retVal = String.valueOf(rows[number/2]); |
2 |
26 Feb 07 |
jari |
440 |
else |
2 |
26 Feb 07 |
jari |
441 |
retVal = String.valueOf(columns[(number+1)/2]); |
2 |
26 Feb 07 |
jari |
442 |
} else if (number < coordinatePairs + intensities) { |
2 |
26 Feb 07 |
jari |
443 |
retVal = String.valueOf(currentIntensity[number - (coordinatePairs)]); |
2 |
26 Feb 07 |
jari |
444 |
} else if (number < coordinatePairs + intensities + extraFields) { |
2 |
26 Feb 07 |
jari |
445 |
retVal = getFieldAt(number - (coordinatePairs + intensities)); |
2 |
26 Feb 07 |
jari |
446 |
} else retVal = ""; |
2 |
26 Feb 07 |
jari |
447 |
return retVal; |
2 |
26 Feb 07 |
jari |
448 |
} |
2 |
26 Feb 07 |
jari |
449 |
|
2 |
26 Feb 07 |
jari |
450 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a description by specified index. Or empty string if feild index |
2 |
26 Feb 07 |
jari |
* does not exist |
2 |
26 Feb 07 |
jari |
453 |
*/ |
2 |
26 Feb 07 |
jari |
454 |
public String getFieldAt(int index) { |
2 |
26 Feb 07 |
jari |
455 |
if(extraFields == null || index < 0 || index > (extraFields.length - 1)) { |
2 |
26 Feb 07 |
jari |
456 |
return ""; |
2 |
26 Feb 07 |
jari |
457 |
} |
2 |
26 Feb 07 |
jari |
458 |
return extraFields[index]; |
2 |
26 Feb 07 |
jari |
459 |
} |
2 |
26 Feb 07 |
jari |
460 |
|
2 |
26 Feb 07 |
jari |
461 |
/** |
2 |
26 Feb 07 |
jari |
* Returns clone on this element. |
2 |
26 Feb 07 |
jari |
463 |
*/ |
2 |
26 Feb 07 |
jari |
464 |
public ISlideDataElement copy() { |
2 |
26 Feb 07 |
jari |
465 |
return new SlideDataElement(this); |
2 |
26 Feb 07 |
jari |
466 |
} |
2 |
26 Feb 07 |
jari |
467 |
|
2 |
26 Feb 07 |
jari |
468 |
public String toString() { |
2 |
26 Feb 07 |
jari |
469 |
return "SDE " + getRow(BASE) + ", " + getColumn(BASE); |
2 |
26 Feb 07 |
jari |
470 |
} |
2 |
26 Feb 07 |
jari |
471 |
|
2 |
26 Feb 07 |
jari |
/** Sets the UID field |
2 |
26 Feb 07 |
jari |
473 |
*/ |
2 |
26 Feb 07 |
jari |
474 |
public void setUID(String uid) { |
2 |
26 Feb 07 |
jari |
475 |
this.UID = uid; |
2 |
26 Feb 07 |
jari |
476 |
} |
2 |
26 Feb 07 |
jari |
477 |
|
2 |
26 Feb 07 |
jari |
/** Returns the UID field |
2 |
26 Feb 07 |
jari |
479 |
*/ |
2 |
26 Feb 07 |
jari |
480 |
public String getUID() { |
2 |
26 Feb 07 |
jari |
481 |
return this.UID; |
2 |
26 Feb 07 |
jari |
482 |
} |
2 |
26 Feb 07 |
jari |
483 |
|
2 |
26 Feb 07 |
jari |
484 |
} |