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