1 |
|
package jalview.renderer.seqfeatures; |
2 |
|
|
3 |
|
import static org.testng.Assert.assertEquals; |
4 |
|
import static org.testng.Assert.assertFalse; |
5 |
|
import static org.testng.Assert.assertNotEquals; |
6 |
|
import static org.testng.Assert.assertNull; |
7 |
|
import static org.testng.Assert.assertTrue; |
8 |
|
|
9 |
|
import jalview.api.FeatureColourI; |
10 |
|
import jalview.datamodel.SequenceFeature; |
11 |
|
import jalview.datamodel.SequenceI; |
12 |
|
import jalview.gui.AlignFrame; |
13 |
|
import jalview.gui.AlignViewport; |
14 |
|
import jalview.gui.FeatureRenderer; |
15 |
|
import jalview.io.DataSourceType; |
16 |
|
import jalview.io.FileLoader; |
17 |
|
import jalview.schemes.FeatureColour; |
18 |
|
import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean; |
19 |
|
|
20 |
|
import java.awt.Color; |
21 |
|
import java.util.List; |
22 |
|
|
23 |
|
import org.testng.annotations.BeforeMethod; |
24 |
|
import org.testng.annotations.BeforeTest; |
25 |
|
import org.testng.annotations.Test; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
|
|
| 99.6% |
Uncovered Elements: 1 (227) |
Complexity: 17 |
Complexity Density: 0.08 |
|
44 |
|
public class FeatureColourFinderTest |
45 |
|
{ |
46 |
|
private AlignViewport av; |
47 |
|
|
48 |
|
private SequenceI seq; |
49 |
|
|
50 |
|
private FeatureColourFinder finder; |
51 |
|
|
52 |
|
private AlignFrame af; |
53 |
|
|
54 |
|
private FeatureRenderer fr; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
56 |
1 |
@BeforeTest(alwaysRun = true)... |
57 |
|
public void setUp() |
58 |
|
{ |
59 |
|
|
60 |
1 |
String s = ">s1\nABCDE---FGHIJKLMNOPQRSTUVWXYZ\n"; |
61 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded(s, |
62 |
|
DataSourceType.PASTE); |
63 |
1 |
av = af.getViewport(); |
64 |
1 |
seq = av.getAlignment().getSequenceAt(0); |
65 |
1 |
fr = af.getFeatureRenderer(); |
66 |
1 |
finder = new FeatureColourFinder(fr); |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
73 |
15 |
@BeforeMethod(alwaysRun = true)... |
74 |
|
public void setUpBeforeTest() |
75 |
|
{ |
76 |
15 |
List<SequenceFeature> sfs = seq.getSequenceFeatures(); |
77 |
15 |
for (SequenceFeature sf : sfs) |
78 |
|
{ |
79 |
20 |
seq.deleteFeature(sf); |
80 |
|
} |
81 |
15 |
fr.findAllFeatures(true); |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
15 |
for (String group : fr.getGroups(false)) |
87 |
|
{ |
88 |
0 |
fr.setGroupVisibility(group, true); |
89 |
|
} |
90 |
|
|
91 |
15 |
fr.clearRenderOrder(); |
92 |
15 |
av.setShowSequenceFeatures(true); |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
95 |
1 |
@Test(groups = "Functional")... |
96 |
|
public void testFindFeatureColour_noFeatures() |
97 |
|
{ |
98 |
1 |
av.setShowSequenceFeatures(false); |
99 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
100 |
1 |
assertEquals(c, Color.blue); |
101 |
|
|
102 |
1 |
av.setShowSequenceFeatures(true); |
103 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
104 |
1 |
assertEquals(c, Color.blue); |
105 |
|
} |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
107 |
1 |
@Test(groups = "Functional")... |
108 |
|
public void testFindFeatureColour_noFeaturesShown() |
109 |
|
{ |
110 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
111 |
|
Float.NaN, "MetalGroup")); |
112 |
1 |
fr.featuresAdded(); |
113 |
1 |
av.setShowSequenceFeatures(false); |
114 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
115 |
1 |
assertEquals(c, Color.blue); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
118 |
1 |
@Test(groups = "Functional")... |
119 |
|
public void testFindFeatureColour_singleFeatureAtPosition() |
120 |
|
{ |
121 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
122 |
|
Float.NaN, "MetalGroup")); |
123 |
1 |
fr.setColour("Metal", new FeatureColour(Color.red)); |
124 |
1 |
fr.featuresAdded(); |
125 |
1 |
av.setShowSequenceFeatures(true); |
126 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
127 |
1 |
assertEquals(c, Color.red); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
134 |
1 |
@Test(groups = "Functional")... |
135 |
|
public void testFindFeatureColour_gapPosition() |
136 |
|
{ |
137 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, 0f, |
138 |
|
null)); |
139 |
1 |
fr.setColour("Metal", new FeatureColour(Color.red)); |
140 |
1 |
fr.featuresAdded(); |
141 |
1 |
av.setShowSequenceFeatures(true); |
142 |
1 |
Color c = finder.findFeatureColour(null, seq, 6); |
143 |
1 |
assertNull(c); |
144 |
|
} |
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
146 |
1 |
@Test(groups = "Functional")... |
147 |
|
public void testFindFeatureColour_multipleFeaturesAtPositionNoTransparency() |
148 |
|
{ |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
154 |
|
Float.NaN, "MetalGroup")); |
155 |
1 |
FeatureColour red = new FeatureColour(Color.red); |
156 |
1 |
fr.setColour("Metal", red); |
157 |
1 |
fr.featuresAdded(); |
158 |
1 |
seq.addSequenceFeature(new SequenceFeature("Domain", "Domain", 4, 15, |
159 |
|
Float.NaN, "DomainGroup")); |
160 |
1 |
FeatureColour green = new FeatureColour(Color.green); |
161 |
1 |
fr.setColour("Domain", green); |
162 |
1 |
fr.featuresAdded(); |
163 |
1 |
av.setShowSequenceFeatures(true); |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
169 |
1 |
assertEquals(c, Color.green); |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
1 |
FeatureSettingsBean[] data = new FeatureSettingsBean[2]; |
177 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, true); |
178 |
1 |
data[1] = new FeatureSettingsBean("Domain", green, null, true); |
179 |
1 |
fr.setFeaturePriority(data); |
180 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
181 |
1 |
assertEquals(c, Color.red); |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, false); |
187 |
1 |
fr.setFeaturePriority(data); |
188 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
189 |
1 |
assertEquals(c, Color.green); |
190 |
|
} |
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
192 |
1 |
@Test(groups = "Functional")... |
193 |
|
public void testFindFeatureColour_singleFeatureNotAtPosition() |
194 |
|
{ |
195 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 8, 12, |
196 |
|
Float.NaN, "MetalGroup")); |
197 |
1 |
fr.setColour("Metal", new FeatureColour(Color.red)); |
198 |
1 |
fr.featuresAdded(); |
199 |
1 |
av.setShowSequenceFeatures(true); |
200 |
|
|
201 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 2); |
202 |
1 |
assertEquals(c, Color.blue); |
203 |
|
} |
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
205 |
1 |
@Test(groups = "Functional")... |
206 |
|
public void testFindFeatureColour_featureTypeNotDisplayed() |
207 |
|
{ |
208 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
209 |
|
Float.NaN, "MetalGroup")); |
210 |
1 |
FeatureColour red = new FeatureColour(Color.red); |
211 |
1 |
fr.setColour("Metal", red); |
212 |
1 |
fr.featuresAdded(); |
213 |
1 |
av.setShowSequenceFeatures(true); |
214 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
215 |
1 |
assertEquals(c, Color.red); |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
1 |
FeatureSettingsBean[] data = new FeatureSettingsBean[1]; |
221 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, false); |
222 |
1 |
fr.setFeaturePriority(data); |
223 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
224 |
1 |
assertEquals(c, Color.blue); |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, true); |
230 |
1 |
fr.setFeaturePriority(data); |
231 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
232 |
1 |
assertEquals(c, Color.red); |
233 |
|
} |
234 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
235 |
1 |
@Test(groups = "Functional")... |
236 |
|
public void testFindFeatureColour_featureGroupNotDisplayed() |
237 |
|
{ |
238 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
239 |
|
Float.NaN, "MetalGroup")); |
240 |
1 |
FeatureColour red = new FeatureColour(Color.red); |
241 |
1 |
fr.setColour("Metal", red); |
242 |
1 |
fr.featuresAdded(); |
243 |
1 |
av.setShowSequenceFeatures(true); |
244 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
245 |
1 |
assertEquals(c, Color.red); |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
1 |
fr.setGroupVisibility("MetalGroup", false); |
251 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
252 |
1 |
assertEquals(c, Color.blue); |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
1 |
fr.setGroupVisibility("MetalGroup", true); |
258 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 10); |
259 |
1 |
assertEquals(c, Color.red); |
260 |
|
} |
261 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
262 |
1 |
@Test(groups = "Functional")... |
263 |
|
public void testFindFeatureColour_contactFeature() |
264 |
|
{ |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
1 |
seq.addSequenceFeature(new SequenceFeature("Disulphide Bond", |
269 |
|
"Contact", 2, 12, Float.NaN, "Disulphide")); |
270 |
1 |
fr.setColour("Disulphide Bond", new FeatureColour(Color.red)); |
271 |
1 |
fr.featuresAdded(); |
272 |
1 |
av.setShowSequenceFeatures(true); |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 10); |
280 |
1 |
assertEquals(c, Color.blue); |
281 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 8); |
282 |
1 |
assertEquals(c, Color.blue); |
283 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 1); |
284 |
1 |
assertEquals(c, Color.red); |
285 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 14); |
286 |
1 |
assertEquals(c, Color.red); |
287 |
|
} |
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
289 |
1 |
@Test(groups = "Functional")... |
290 |
|
public void testFindFeatureAtEnd() |
291 |
|
{ |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
1 |
seq.addSequenceFeature(new SequenceFeature("PDBRESNUM", "pdb res 1", |
296 |
|
seq.getEnd(), seq.getEnd(), Float.NaN, "1seq.pdb")); |
297 |
1 |
fr.setColour("PDBRESNUM", new FeatureColour(Color.red)); |
298 |
1 |
fr.featuresAdded(); |
299 |
1 |
av.setShowSequenceFeatures(true); |
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, |
305 |
|
seq.getLength() - 2); |
306 |
1 |
assertNotEquals(c, Color.red); |
307 |
1 |
c = finder.findFeatureColour(Color.blue, seq, seq.getLength() - 1); |
308 |
1 |
assertEquals(c, Color.red); |
309 |
|
} |
310 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
311 |
1 |
@Test(groups = "Functional")... |
312 |
|
public void testFindFeatureColour_graduatedFeatureColour() |
313 |
|
{ |
314 |
1 |
seq.addSequenceFeature(new SequenceFeature("kd", "hydrophobicity", 2, |
315 |
|
2, 0f, "KdGroup")); |
316 |
1 |
seq.addSequenceFeature(new SequenceFeature("kd", "hydrophobicity", 4, |
317 |
|
4, 5f, "KdGroup")); |
318 |
1 |
seq.addSequenceFeature(new SequenceFeature("kd", "hydrophobicity", 7, |
319 |
|
7, 10f, "KdGroup")); |
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
1 |
Color min = new Color(100, 50, 150); |
325 |
1 |
Color max = new Color(200, 0, 100); |
326 |
1 |
FeatureColourI fc = new FeatureColour(min, max, 0, 10); |
327 |
1 |
fr.setColour("kd", fc); |
328 |
1 |
fr.featuresAdded(); |
329 |
1 |
av.setShowSequenceFeatures(true); |
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 1); |
335 |
1 |
assertEquals(c, min); |
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 9); |
341 |
1 |
assertEquals(c, max); |
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 3); |
347 |
1 |
assertEquals(c, new Color(150, 25, 125)); |
348 |
|
} |
349 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
350 |
1 |
@Test(groups = "Functional")... |
351 |
|
public void testFindFeatureColour_transparencySingleFeature() |
352 |
|
{ |
353 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
354 |
|
Float.NaN, "MetalGroup")); |
355 |
1 |
FeatureColour red = new FeatureColour(Color.red); |
356 |
1 |
fr.setColour("Metal", red); |
357 |
1 |
fr.featuresAdded(); |
358 |
1 |
av.setShowSequenceFeatures(true); |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
1 |
fr.setTransparency(0.4f); |
367 |
1 |
Color c = finder.findFeatureColour(Color.cyan, seq, 10); |
368 |
1 |
assertEquals(c, new Color(102, 153, 153)); |
369 |
|
} |
370 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
371 |
1 |
@Test(groups = "Functional")... |
372 |
|
public void testFindFeatureColour_transparencyTwoFeatures() |
373 |
|
{ |
374 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
375 |
|
Float.NaN, "MetalGroup")); |
376 |
1 |
FeatureColour red = new FeatureColour(Color.red); |
377 |
1 |
fr.setColour("Metal", red); |
378 |
1 |
fr.featuresAdded(); |
379 |
1 |
seq.addSequenceFeature(new SequenceFeature("Domain", "Domain", 4, 15, |
380 |
|
Float.NaN, "DomainGroup")); |
381 |
1 |
FeatureColour green = new FeatureColour(Color.green); |
382 |
1 |
fr.setColour("Domain", green); |
383 |
1 |
fr.featuresAdded(); |
384 |
1 |
av.setShowSequenceFeatures(true); |
385 |
|
|
386 |
|
|
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
391 |
1 |
fr.setTransparency(0.6f); |
392 |
1 |
Color c = finder.findFeatureColour(Color.cyan, seq, 10); |
393 |
1 |
assertEquals(c, new Color(61, 194, 41)); |
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
1 |
FeatureSettingsBean[] data = new FeatureSettingsBean[2]; |
404 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, true); |
405 |
1 |
data[1] = new FeatureSettingsBean("Domain", green, null, true); |
406 |
1 |
fr.setFeaturePriority(data); |
407 |
1 |
c = finder.findFeatureColour(Color.cyan, seq, 10); |
408 |
1 |
assertEquals(c, new Color(153, 102, 41)); |
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, false); |
416 |
1 |
fr.setFeaturePriority(data); |
417 |
1 |
c = finder.findFeatureColour(Color.pink, seq, 10); |
418 |
1 |
assertEquals(c, new Color(102, 223, 70)); |
419 |
|
} |
420 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
421 |
1 |
@Test(groups = "Functional")... |
422 |
|
public void testNoFeaturesDisplayed() |
423 |
|
{ |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
1 |
assertTrue(finder.noFeaturesDisplayed()); |
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
1 |
av.setShowSequenceFeatures(false); |
435 |
1 |
seq.addSequenceFeature(new SequenceFeature("Metal", "Metal", 2, 12, |
436 |
|
Float.NaN, "MetalGroup")); |
437 |
1 |
FeatureColour red = new FeatureColour(Color.red); |
438 |
1 |
fr.setColour("Metal", red); |
439 |
1 |
fr.featuresAdded(); |
440 |
1 |
assertTrue(finder.noFeaturesDisplayed()); |
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
1 |
av.setShowSequenceFeatures(true); |
446 |
1 |
assertFalse(finder.noFeaturesDisplayed()); |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
1 |
FeatureSettingsBean[] data = new FeatureSettingsBean[1]; |
452 |
1 |
data[0] = new FeatureSettingsBean("Metal", red, null, false); |
453 |
1 |
fr.setFeaturePriority(data); |
454 |
1 |
assertTrue(finder.noFeaturesDisplayed()); |
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
1 |
fr.setVisible("Metal"); |
460 |
1 |
assertFalse(finder.noFeaturesDisplayed()); |
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
1 |
fr.setGroupVisibility("MetalGroup", false); |
467 |
1 |
assertFalse(finder.noFeaturesDisplayed()); |
468 |
|
|
469 |
|
|
470 |
|
|
471 |
|
|
472 |
1 |
FeatureColourFinder finder2 = new FeatureColourFinder(null); |
473 |
1 |
assertTrue(finder2.noFeaturesDisplayed()); |
474 |
|
} |
475 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
476 |
1 |
@Test(groups = "Functional")... |
477 |
|
public void testFindFeatureColour_graduatedWithThreshold() |
478 |
|
{ |
479 |
1 |
String kdFeature = "kd"; |
480 |
1 |
String metalFeature = "Metal"; |
481 |
1 |
seq.addSequenceFeature(new SequenceFeature(kdFeature, "hydrophobicity", 2, |
482 |
|
2, 0f, "KdGroup")); |
483 |
1 |
seq.addSequenceFeature(new SequenceFeature(kdFeature, "hydrophobicity", 4, |
484 |
|
4, 5f, "KdGroup")); |
485 |
1 |
seq.addSequenceFeature(new SequenceFeature(metalFeature, "Fe", 4, 4, |
486 |
|
5f, "MetalGroup")); |
487 |
1 |
seq.addSequenceFeature(new SequenceFeature(kdFeature, "hydrophobicity", 7, |
488 |
|
7, 10f, "KdGroup")); |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
1 |
Color min = new Color(100, 50, 150); |
495 |
1 |
Color max = new Color(200, 0, 100); |
496 |
1 |
FeatureColourI fc = new FeatureColour(min, max, 0, 10); |
497 |
1 |
fc.setAboveThreshold(true); |
498 |
1 |
fc.setThreshold(5f); |
499 |
1 |
fr.setColour(kdFeature, fc); |
500 |
1 |
FeatureColour green = new FeatureColour(Color.green); |
501 |
1 |
fr.setColour(metalFeature, green); |
502 |
1 |
fr.featuresAdded(); |
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
1 |
FeatureSettingsBean[] data = new FeatureSettingsBean[2]; |
508 |
1 |
data[0] = new FeatureSettingsBean(kdFeature, fc, null, true); |
509 |
1 |
data[1] = new FeatureSettingsBean(metalFeature, green, null, true); |
510 |
1 |
fr.setFeaturePriority(data); |
511 |
|
|
512 |
1 |
av.setShowSequenceFeatures(true); |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
1 |
Color c = finder.findFeatureColour(Color.blue, seq, 1); |
518 |
1 |
assertEquals(c, Color.blue); |
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 3); |
525 |
1 |
assertEquals(c, Color.green); |
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 9); |
531 |
1 |
assertEquals(c, max); |
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
1 |
fc.setBelowThreshold(true); |
537 |
|
|
538 |
|
|
539 |
|
|
540 |
|
|
541 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 1); |
542 |
1 |
assertEquals(c, min); |
543 |
|
|
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 3); |
549 |
1 |
assertEquals(c, Color.green); |
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
1 |
c = finder.findFeatureColour(Color.blue, seq, 9); |
555 |
1 |
assertEquals(c, Color.blue); |
556 |
|
} |
557 |
|
} |