| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.gui; |
| 22 |
|
|
| 23 |
|
import static org.testng.AssertJUnit.assertEquals; |
| 24 |
|
import static org.testng.AssertJUnit.assertFalse; |
| 25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
| 26 |
|
import static org.testng.AssertJUnit.assertNotSame; |
| 27 |
|
import static org.testng.AssertJUnit.assertSame; |
| 28 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 29 |
|
|
| 30 |
|
import java.util.ArrayList; |
| 31 |
|
import java.util.List; |
| 32 |
|
|
| 33 |
|
import org.testng.Assert; |
| 34 |
|
import org.testng.annotations.BeforeClass; |
| 35 |
|
import org.testng.annotations.BeforeMethod; |
| 36 |
|
import org.testng.annotations.Test; |
| 37 |
|
|
| 38 |
|
import jalview.bin.Cache; |
| 39 |
|
import jalview.bin.Jalview; |
| 40 |
|
import jalview.datamodel.AlignedCodonFrame; |
| 41 |
|
import jalview.datamodel.Alignment; |
| 42 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 43 |
|
import jalview.datamodel.AlignmentI; |
| 44 |
|
import jalview.datamodel.Annotation; |
| 45 |
|
import jalview.datamodel.ContactMatrixI; |
| 46 |
|
import jalview.datamodel.SearchResults; |
| 47 |
|
import jalview.datamodel.SearchResultsI; |
| 48 |
|
import jalview.datamodel.SeqDistanceContactMatrix; |
| 49 |
|
import jalview.datamodel.Sequence; |
| 50 |
|
import jalview.datamodel.SequenceGroup; |
| 51 |
|
import jalview.datamodel.SequenceI; |
| 52 |
|
import jalview.io.DataSourceType; |
| 53 |
|
import jalview.io.FileLoader; |
| 54 |
|
import jalview.schemes.ClustalxColourScheme; |
| 55 |
|
import jalview.schemes.ColourSchemeI; |
| 56 |
|
import jalview.schemes.PIDColourScheme; |
| 57 |
|
import jalview.structure.StructureSelectionManager; |
| 58 |
|
import jalview.util.MapList; |
| 59 |
|
import jalview.viewmodel.ViewportRanges; |
| 60 |
|
|
| |
|
| 99.2% |
Uncovered Elements: 2 (254) |
Complexity: 17 |
Complexity Density: 0.07 |
|
| 61 |
|
public class AlignViewportTest |
| 62 |
|
{ |
| 63 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 64 |
1 |
@BeforeClass(alwaysRun = true)... |
| 65 |
|
public void setUpJvOptionPane() |
| 66 |
|
{ |
| 67 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 68 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
AlignmentI al; |
| 72 |
|
|
| 73 |
|
AlignViewport testee; |
| 74 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 75 |
1 |
@BeforeClass(alwaysRun = true)... |
| 76 |
|
public static void setUpBeforeClass() throws Exception |
| 77 |
|
{ |
| 78 |
1 |
Jalview.main( |
| 79 |
|
new String[] |
| 80 |
|
{ "--nonews", "--props", "test/jalview/testProps.jvprops" }); |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
1 |
StructureSelectionManager ssm = StructureSelectionManager |
| 86 |
|
.getStructureSelectionManager(Desktop.instance); |
| 87 |
1 |
ssm.resetAll(); |
| 88 |
|
} |
| 89 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 90 |
11 |
@BeforeMethod(alwaysRun = true)... |
| 91 |
|
public void setUp() |
| 92 |
|
{ |
| 93 |
11 |
SequenceI seq1 = new Sequence("Seq1", "ABC"); |
| 94 |
11 |
SequenceI seq2 = new Sequence("Seq2", "ABC"); |
| 95 |
11 |
SequenceI seq3 = new Sequence("Seq3", "ABC"); |
| 96 |
11 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3 }; |
| 97 |
11 |
al = new Alignment(seqs); |
| 98 |
11 |
al.setDataset(null); |
| 99 |
11 |
testee = new AlignViewport(al); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 106 |
1 |
@Test(groups = { "Functional" })... |
| 107 |
|
public void testDeregisterMapping_onCloseView() |
| 108 |
|
{ |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
1 |
AlignFrame af1 = new FileLoader() |
| 113 |
|
.LoadFileWaitTillLoaded(">Seq1\nCAGT\n", DataSourceType.PASTE); |
| 114 |
|
|
| 115 |
1 |
SequenceI s1 = af1.getViewport().getAlignment().getSequenceAt(0); |
| 116 |
1 |
AlignedCodonFrame acf1 = new AlignedCodonFrame(); |
| 117 |
1 |
acf1.addMap(s1, s1, |
| 118 |
|
new MapList(new int[] |
| 119 |
|
{ 1, 4 }, new int[] { 1, 4 }, 1, 1)); |
| 120 |
1 |
AlignedCodonFrame acf2 = new AlignedCodonFrame(); |
| 121 |
1 |
acf2.addMap(s1, s1, |
| 122 |
|
new MapList(new int[] |
| 123 |
|
{ 1, 4 }, new int[] { 4, 1 }, 1, 1)); |
| 124 |
|
|
| 125 |
1 |
List<AlignedCodonFrame> mappings = new ArrayList<>(); |
| 126 |
1 |
mappings.add(acf1); |
| 127 |
1 |
mappings.add(acf2); |
| 128 |
1 |
af1.getViewport().getAlignment().setCodonFrames(mappings); |
| 129 |
1 |
af1.newView_actionPerformed(null); |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
1 |
StructureSelectionManager ssm = StructureSelectionManager |
| 136 |
|
.getStructureSelectionManager(Desktop.instance); |
| 137 |
1 |
List<AlignedCodonFrame> sequenceMappings = ssm.getSequenceMappings(); |
| 138 |
1 |
assertEquals(2, sequenceMappings.size()); |
| 139 |
1 |
assertTrue(sequenceMappings.contains(acf1)); |
| 140 |
1 |
assertTrue(sequenceMappings.contains(acf2)); |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
1 |
af1.closeMenuItem_actionPerformed(false); |
| 147 |
1 |
assertEquals(2, sequenceMappings.size()); |
| 148 |
1 |
assertTrue(sequenceMappings.contains(acf1)); |
| 149 |
1 |
assertTrue(sequenceMappings.contains(acf2)); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 155 |
1 |
@Test(groups = { "Functional" })... |
| 156 |
|
public void testDeregisterMapping_withNoReference() |
| 157 |
|
{ |
| 158 |
1 |
Desktop d = Desktop.instance; |
| 159 |
1 |
assertNotNull(d); |
| 160 |
1 |
StructureSelectionManager ssm = StructureSelectionManager |
| 161 |
|
.getStructureSelectionManager(Desktop.instance); |
| 162 |
1 |
ssm.resetAll(); |
| 163 |
|
|
| 164 |
1 |
AlignFrame af1 = new FileLoader() |
| 165 |
|
.LoadFileWaitTillLoaded(">Seq1\nRSVQ\n", DataSourceType.PASTE); |
| 166 |
1 |
AlignFrame af2 = new FileLoader() |
| 167 |
|
.LoadFileWaitTillLoaded(">Seq2\nDGEL\n", DataSourceType.PASTE); |
| 168 |
1 |
SequenceI cs1 = new Sequence("cseq1", "CCCGGGTTTAAA"); |
| 169 |
1 |
SequenceI cs2 = new Sequence("cseq2", "CTTGAGTCTAGA"); |
| 170 |
1 |
SequenceI s1 = af1.getViewport().getAlignment().getSequenceAt(0); |
| 171 |
1 |
SequenceI s2 = af2.getViewport().getAlignment().getSequenceAt(0); |
| 172 |
|
|
| 173 |
1 |
AlignedCodonFrame acf1 = new AlignedCodonFrame(); |
| 174 |
1 |
acf1.addMap(cs1, s1, |
| 175 |
|
new MapList(new int[] |
| 176 |
|
{ 1, 4 }, new int[] { 1, 12 }, 1, 3)); |
| 177 |
1 |
AlignedCodonFrame acf2 = new AlignedCodonFrame(); |
| 178 |
1 |
acf2.addMap(cs2, s2, |
| 179 |
|
new MapList(new int[] |
| 180 |
|
{ 1, 4 }, new int[] { 1, 12 }, 1, 3)); |
| 181 |
1 |
AlignedCodonFrame acf3 = new AlignedCodonFrame(); |
| 182 |
1 |
acf3.addMap(cs2, cs2, |
| 183 |
|
new MapList(new int[] |
| 184 |
|
{ 1, 12 }, new int[] { 1, 12 }, 1, 1)); |
| 185 |
|
|
| 186 |
1 |
List<AlignedCodonFrame> mappings1 = new ArrayList<>(); |
| 187 |
1 |
mappings1.add(acf1); |
| 188 |
1 |
af1.getViewport().getAlignment().setCodonFrames(mappings1); |
| 189 |
|
|
| 190 |
1 |
List<AlignedCodonFrame> mappings2 = new ArrayList<>(); |
| 191 |
1 |
mappings2.add(acf2); |
| 192 |
1 |
mappings2.add(acf3); |
| 193 |
1 |
af2.getViewport().getAlignment().setCodonFrames(mappings2); |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
1 |
List<AlignedCodonFrame> ssmMappings = ssm.getSequenceMappings(); |
| 200 |
1 |
assertEquals(0, ssmMappings.size()); |
| 201 |
1 |
ssm.registerMapping(acf1); |
| 202 |
1 |
assertEquals(1, ssmMappings.size()); |
| 203 |
1 |
ssm.registerMapping(acf2); |
| 204 |
1 |
assertEquals(2, ssmMappings.size()); |
| 205 |
1 |
ssm.registerMapping(acf3); |
| 206 |
1 |
assertEquals(3, ssmMappings.size()); |
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
1 |
af2.closeMenuItem_actionPerformed(true); |
| 213 |
1 |
assertEquals(1, ssmMappings.size()); |
| 214 |
1 |
assertTrue(ssmMappings.contains(acf1)); |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (37) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
| 221 |
1 |
@Test(groups = { "Functional" })... |
| 222 |
|
public void testDeregisterMapping_withReference() |
| 223 |
|
{ |
| 224 |
1 |
Desktop d = Desktop.instance; |
| 225 |
1 |
assertNotNull(d); |
| 226 |
1 |
StructureSelectionManager ssm = StructureSelectionManager |
| 227 |
|
.getStructureSelectionManager(Desktop.instance); |
| 228 |
1 |
ssm.resetAll(); |
| 229 |
|
|
| 230 |
1 |
AlignFrame af1 = new FileLoader() |
| 231 |
|
.LoadFileWaitTillLoaded(">Seq1\nRSVQ\n", DataSourceType.PASTE); |
| 232 |
1 |
AlignFrame af2 = new FileLoader() |
| 233 |
|
.LoadFileWaitTillLoaded(">Seq2\nDGEL\n", DataSourceType.PASTE); |
| 234 |
1 |
SequenceI cs1 = new Sequence("cseq1", "CCCGGGTTTAAA"); |
| 235 |
1 |
SequenceI cs2 = new Sequence("cseq2", "CTTGAGTCTAGA"); |
| 236 |
1 |
SequenceI s1 = af1.getViewport().getAlignment().getSequenceAt(0); |
| 237 |
1 |
SequenceI s2 = af2.getViewport().getAlignment().getSequenceAt(0); |
| 238 |
|
|
| 239 |
1 |
AlignedCodonFrame acf1 = new AlignedCodonFrame(); |
| 240 |
1 |
acf1.addMap(cs1, s1, |
| 241 |
|
new MapList(new int[] |
| 242 |
|
{ 1, 4 }, new int[] { 1, 12 }, 1, 3)); |
| 243 |
1 |
AlignedCodonFrame acf2 = new AlignedCodonFrame(); |
| 244 |
1 |
acf2.addMap(cs2, s2, |
| 245 |
|
new MapList(new int[] |
| 246 |
|
{ 1, 4 }, new int[] { 1, 12 }, 1, 3)); |
| 247 |
1 |
AlignedCodonFrame acf3 = new AlignedCodonFrame(); |
| 248 |
1 |
acf3.addMap(cs2, cs2, |
| 249 |
|
new MapList(new int[] |
| 250 |
|
{ 1, 12 }, new int[] { 1, 12 }, 1, 1)); |
| 251 |
|
|
| 252 |
1 |
List<AlignedCodonFrame> mappings1 = new ArrayList<>(); |
| 253 |
1 |
mappings1.add(acf1); |
| 254 |
1 |
mappings1.add(acf2); |
| 255 |
1 |
af1.getViewport().getAlignment().setCodonFrames(mappings1); |
| 256 |
|
|
| 257 |
1 |
List<AlignedCodonFrame> mappings2 = new ArrayList<>(); |
| 258 |
1 |
mappings2.add(acf2); |
| 259 |
1 |
mappings2.add(acf3); |
| 260 |
1 |
af2.getViewport().getAlignment().setCodonFrames(mappings2); |
| 261 |
|
|
| 262 |
|
|
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
1 |
List<AlignedCodonFrame> ssmMappings = ssm.getSequenceMappings(); |
| 267 |
1 |
assertEquals(0, ssmMappings.size()); |
| 268 |
1 |
ssm.registerMapping(acf1); |
| 269 |
1 |
assertEquals(1, ssmMappings.size()); |
| 270 |
1 |
ssm.registerMapping(acf2); |
| 271 |
1 |
assertEquals(2, ssmMappings.size()); |
| 272 |
1 |
ssm.registerMapping(acf3); |
| 273 |
1 |
assertEquals(3, ssmMappings.size()); |
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
1 |
af2.closeMenuItem_actionPerformed(true); |
| 281 |
1 |
assertEquals(2, ssmMappings.size()); |
| 282 |
1 |
assertTrue(ssmMappings.contains(acf1)); |
| 283 |
1 |
assertTrue(ssmMappings.contains(acf2)); |
| 284 |
1 |
assertFalse(ssmMappings.contains(acf3)); |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 291 |
1 |
@Test(groups = { "Functional" }, timeOut = 2000)... |
| 292 |
|
public void testUpdateConservation_qualityOnly() |
| 293 |
|
{ |
| 294 |
1 |
Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", |
| 295 |
|
Boolean.TRUE.toString()); |
| 296 |
1 |
Cache.applicationProperties.setProperty("SHOW_QUALITY", |
| 297 |
|
Boolean.TRUE.toString()); |
| 298 |
1 |
Cache.applicationProperties.setProperty("SHOW_CONSERVATION", |
| 299 |
|
Boolean.FALSE.toString()); |
| 300 |
1 |
Cache.applicationProperties.setProperty("SHOW_OCCUPANCY", |
| 301 |
|
Boolean.FALSE.toString()); |
| 302 |
1 |
Cache.applicationProperties.setProperty("SHOW_IDENTITY", |
| 303 |
|
Boolean.FALSE.toString()); |
| 304 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
| 305 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
1 |
AlignViewport viewport = af.getViewport(); |
| 311 |
1 |
waitForCalculations(viewport); |
| 312 |
1 |
AlignmentAnnotation[] anns = viewport.getAlignment() |
| 313 |
|
.getAlignmentAnnotation(); |
| 314 |
1 |
assertNotNull("No annotations found", anns); |
| 315 |
1 |
assertEquals("More than one annotation found", 1, anns.length); |
| 316 |
1 |
assertTrue("Annotation is not Quality", |
| 317 |
|
anns[0].description.startsWith("Alignment Quality")); |
| 318 |
1 |
Annotation[] annotations = anns[0].annotations; |
| 319 |
1 |
assertNotNull("Quality annotations are null", annotations); |
| 320 |
1 |
assertNotNull("Quality in column 1 is null", annotations[0]); |
| 321 |
1 |
assertTrue("No quality value in column 1", annotations[0].value > 10f); |
| 322 |
|
} |
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
|
@param |
| 328 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 329 |
2 |
protected void waitForCalculations(AlignViewport viewport)... |
| 330 |
|
{ |
| 331 |
2 |
synchronized (this) |
| 332 |
|
{ |
| 333 |
2 |
do |
| 334 |
|
{ |
| 335 |
2 |
try |
| 336 |
|
{ |
| 337 |
2 |
wait(50); |
| 338 |
|
} catch (InterruptedException e) |
| 339 |
|
{ |
| 340 |
|
} |
| 341 |
2 |
} while (viewport.getCalcManager().isWorking()); |
| 342 |
|
} |
| 343 |
|
} |
| 344 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 345 |
1 |
@Test(groups = { "Functional" })... |
| 346 |
|
public void testSetGlobalColourScheme() |
| 347 |
|
{ |
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
1 |
Cache.applicationProperties.setProperty("DEFAULT_COLOUR_PROT", "None"); |
| 352 |
1 |
Cache.applicationProperties.setProperty("SHOW_CONSERVATION", |
| 353 |
|
Boolean.TRUE.toString()); |
| 354 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
| 355 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
| 356 |
1 |
ColourSchemeI cs = new PIDColourScheme(); |
| 357 |
1 |
AlignViewport viewport = af.getViewport(); |
| 358 |
1 |
viewport.setGlobalColourScheme(cs); |
| 359 |
1 |
assertFalse(viewport.getResidueShading().conservationApplied()); |
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
1 |
AlignmentI aln = viewport.getAlignment(); |
| 365 |
1 |
SequenceGroup sg1 = new SequenceGroup(); |
| 366 |
1 |
sg1.addSequence(aln.getSequenceAt(0), false); |
| 367 |
1 |
sg1.addSequence(aln.getSequenceAt(2), false); |
| 368 |
1 |
SequenceGroup sg2 = new SequenceGroup(); |
| 369 |
1 |
sg2.addSequence(aln.getSequenceAt(1), false); |
| 370 |
1 |
sg2.addSequence(aln.getSequenceAt(3), false); |
| 371 |
1 |
aln.addGroup(sg1); |
| 372 |
1 |
aln.addGroup(sg2); |
| 373 |
1 |
viewport.setColourAppliesToAllGroups(true); |
| 374 |
1 |
viewport.setGlobalColourScheme(new ClustalxColourScheme()); |
| 375 |
1 |
ColourSchemeI cs0 = viewport.getGlobalColourScheme(); |
| 376 |
1 |
ColourSchemeI cs1 = sg1.getColourScheme(); |
| 377 |
1 |
ColourSchemeI cs2 = sg2.getColourScheme(); |
| 378 |
1 |
assertTrue(cs0 instanceof ClustalxColourScheme); |
| 379 |
1 |
assertTrue(cs1 instanceof ClustalxColourScheme); |
| 380 |
1 |
assertTrue(cs2 instanceof ClustalxColourScheme); |
| 381 |
1 |
assertNotSame(cs0, cs1); |
| 382 |
1 |
assertNotSame(cs0, cs2); |
| 383 |
1 |
assertNotSame(cs1, cs2); |
| 384 |
|
} |
| 385 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
| 386 |
1 |
@Test(groups = { "Functional" })... |
| 387 |
|
public void testSetGetHasSearchResults() |
| 388 |
|
{ |
| 389 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
| 390 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
| 391 |
1 |
SearchResultsI sr = new SearchResults(); |
| 392 |
1 |
SequenceI s1 = af.getViewport().getAlignment().getSequenceAt(0); |
| 393 |
|
|
| 394 |
|
|
| 395 |
1 |
sr.addResult(s1, s1.getStart() + 10, s1.getStart() + 15); |
| 396 |
|
|
| 397 |
|
|
| 398 |
1 |
af.getViewport().setSearchResults(sr); |
| 399 |
|
|
| 400 |
1 |
assertTrue(af.getViewport().hasSearchResults()); |
| 401 |
|
|
| 402 |
1 |
assertEquals(sr, af.getViewport().getSearchResults()); |
| 403 |
|
|
| 404 |
|
|
| 405 |
|
|
| 406 |
1 |
af.getViewport().setSearchResults(null); |
| 407 |
1 |
assertFalse(af.getViewport().hasSearchResults()); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 415 |
1 |
@Test(groups = { "Functional" })... |
| 416 |
|
public void testSetSelectionGroup() |
| 417 |
|
{ |
| 418 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
| 419 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
| 420 |
1 |
AlignViewport av = af.getViewport(); |
| 421 |
1 |
SequenceGroup sg1 = new SequenceGroup(); |
| 422 |
1 |
SequenceGroup sg2 = new SequenceGroup(); |
| 423 |
1 |
SequenceGroup sg3 = new SequenceGroup(); |
| 424 |
|
|
| 425 |
1 |
av.setSelectionGroup(sg1); |
| 426 |
1 |
assertSame(sg1.getContext(), av.getAlignment()); |
| 427 |
1 |
assertFalse(sg1.isDefined()); |
| 428 |
|
|
| 429 |
1 |
sg2.setContext(sg1, false); |
| 430 |
1 |
av.setSelectionGroup(sg2); |
| 431 |
1 |
assertFalse(sg2.isDefined()); |
| 432 |
1 |
assertSame(sg2.getContext(), sg1); |
| 433 |
|
|
| 434 |
|
|
| 435 |
1 |
sg3.setContext(av.getAlignment(), true); |
| 436 |
1 |
av.setSelectionGroup(sg3); |
| 437 |
1 |
assertTrue(sg3.isDefined()); |
| 438 |
|
} |
| 439 |
|
|
| 440 |
|
|
| 441 |
|
|
| 442 |
|
|
| 443 |
|
|
| |
|
| 95% |
Uncovered Elements: 1 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 444 |
1 |
@Test(groups = { "Functional" })... |
| 445 |
|
public void testShowOrDontShowOccupancy() |
| 446 |
|
{ |
| 447 |
|
|
| 448 |
1 |
jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", |
| 449 |
|
Boolean.FALSE.toString()); |
| 450 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
| 451 |
|
"examples/uniref50.fa", DataSourceType.FILE); |
| 452 |
1 |
AlignViewport av = af.getViewport(); |
| 453 |
1 |
Assert.assertNull(av.getAlignmentGapAnnotation(), |
| 454 |
|
"Preference did not disable occupancy row."); |
| 455 |
1 |
int c = 0; |
| 456 |
1 |
for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null, |
| 457 |
|
null, "Occupancy")) |
| 458 |
|
{ |
| 459 |
0 |
c++; |
| 460 |
|
} |
| 461 |
1 |
Assert.assertEquals(c, 0, "Expected zero occupancy rows."); |
| 462 |
|
|
| 463 |
|
|
| 464 |
1 |
jalview.bin.Cache.setProperty("SHOW_OCCUPANCY", |
| 465 |
|
Boolean.TRUE.toString()); |
| 466 |
1 |
af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", |
| 467 |
|
DataSourceType.FILE); |
| 468 |
1 |
av = af.getViewport(); |
| 469 |
1 |
Assert.assertNotNull(av.getAlignmentGapAnnotation(), |
| 470 |
|
"Preference did not enable occupancy row."); |
| 471 |
1 |
c = 0; |
| 472 |
1 |
for (AlignmentAnnotation aa : av.getAlignment().findAnnotations(null, |
| 473 |
|
null, av.getAlignmentGapAnnotation().label)) |
| 474 |
|
{ |
| 475 |
1 |
c++; |
| 476 |
1 |
Assert.assertNotNull(aa.annotations); |
| 477 |
|
|
| 478 |
1 |
Assert.assertNotNull(aa.annotations[5], |
| 479 |
|
"Expected occupancy to be non-null in column 5"); |
| 480 |
1 |
Assert.assertNotEquals(aa.annotations[5].value, 0f, |
| 481 |
|
"Expected occupancy to not be zero in column 5"); |
| 482 |
|
|
| 483 |
|
} |
| 484 |
1 |
; |
| 485 |
1 |
Assert.assertEquals(c, 1, "Expected to find one occupancy row."); |
| 486 |
|
} |
| 487 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 488 |
1 |
@Test(groups = { "Functional" })... |
| 489 |
|
public void testGetConsensusSeq() |
| 490 |
|
{ |
| 491 |
|
|
| 492 |
|
|
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
|
|
| 497 |
|
|
| 498 |
1 |
String fasta = ">s1\nA-C\n>s2\nA-C\n>s3\nA-D\n>s4\n--D\n"; |
| 499 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta, |
| 500 |
|
DataSourceType.PASTE); |
| 501 |
1 |
AlignViewport testme = af.getViewport(); |
| 502 |
1 |
waitForCalculations(testme); |
| 503 |
1 |
SequenceI cons = testme.getConsensusSeq(); |
| 504 |
1 |
assertEquals("A-C", cons.getSequenceAsString()); |
| 505 |
|
} |
| 506 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 507 |
1 |
@Test(groups = { "Functional" })... |
| 508 |
|
public void testHideRevealSequences() |
| 509 |
|
{ |
| 510 |
1 |
ViewportRanges ranges = testee.getRanges(); |
| 511 |
1 |
assertEquals(3, al.getHeight()); |
| 512 |
1 |
assertEquals(0, ranges.getStartSeq()); |
| 513 |
1 |
assertEquals(2, ranges.getEndSeq()); |
| 514 |
|
|
| 515 |
|
|
| 516 |
|
|
| 517 |
|
|
| 518 |
1 |
testee.hideSequence(new SequenceI[] { al.getSequenceAt(0) }); |
| 519 |
1 |
assertEquals(2, al.getHeight()); |
| 520 |
1 |
assertEquals(0, ranges.getStartSeq()); |
| 521 |
1 |
assertEquals(1, ranges.getEndSeq()); |
| 522 |
|
|
| 523 |
|
|
| 524 |
|
|
| 525 |
|
|
| 526 |
1 |
testee.showSequence(0); |
| 527 |
1 |
assertEquals(3, al.getHeight()); |
| 528 |
1 |
assertEquals(0, ranges.getStartSeq()); |
| 529 |
1 |
assertEquals(2, ranges.getEndSeq()); |
| 530 |
|
|
| 531 |
|
|
| 532 |
|
|
| 533 |
|
|
| 534 |
1 |
testee.hideSequence( |
| 535 |
|
new SequenceI[] |
| 536 |
|
{ al.getSequenceAt(0), al.getSequenceAt(2) }); |
| 537 |
1 |
assertEquals(1, al.getHeight()); |
| 538 |
1 |
assertEquals(0, ranges.getStartSeq()); |
| 539 |
1 |
assertEquals(0, ranges.getEndSeq()); |
| 540 |
|
|
| 541 |
|
|
| 542 |
|
|
| 543 |
|
|
| 544 |
1 |
testee.showAllHiddenSeqs(); |
| 545 |
1 |
assertEquals(3, al.getHeight()); |
| 546 |
1 |
assertEquals(0, ranges.getStartSeq()); |
| 547 |
1 |
assertEquals(2, ranges.getEndSeq()); |
| 548 |
|
} |
| 549 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 550 |
1 |
@Test(groups = { "Functional" })... |
| 551 |
|
public void testGetSelectionAsNewSequences_withContactMatrices() |
| 552 |
|
{ |
| 553 |
1 |
SequenceI seq = new Sequence("seq", "ACADA"); |
| 554 |
1 |
ContactMatrixI cmat = new SeqDistanceContactMatrix(5); |
| 555 |
1 |
seq.addContactList(cmat); |
| 556 |
1 |
Alignment al = new Alignment(new SequenceI[] { seq.deriveSequence() }); |
| 557 |
1 |
al.addAnnotation(al.getSequenceAt(0).getAnnotation()[0]); |
| 558 |
1 |
AlignFrame af = new AlignFrame(al, 500, 500); |
| 559 |
|
|
| 560 |
1 |
SequenceI selseqs[] = af.getViewport().getSelectionAsNewSequence(); |
| 561 |
1 |
assertNotNull(selseqs[0].getAnnotation()); |
| 562 |
1 |
assertNotNull(selseqs[0].getAnnotation()[0]); |
| 563 |
1 |
assertEquals(cmat, |
| 564 |
|
selseqs[0].getContactMatrixFor(selseqs[0].getAnnotation()[0])); |
| 565 |
|
|
| 566 |
1 |
assertNotNull( |
| 567 |
|
selseqs[0].getContactListFor(selseqs[0].getAnnotation()[0], 2)); |
| 568 |
|
|
| 569 |
|
|
| 570 |
1 |
af.selectAllSequenceMenuItem_actionPerformed(null); |
| 571 |
1 |
selseqs = af.getViewport().getSelectionAsNewSequence(); |
| 572 |
1 |
assertNotNull(selseqs[0].getAnnotation()); |
| 573 |
1 |
assertNotNull(selseqs[0].getAnnotation()[0]); |
| 574 |
1 |
assertEquals(cmat, |
| 575 |
|
selseqs[0].getContactMatrixFor(selseqs[0].getAnnotation()[0])); |
| 576 |
1 |
assertNotNull( |
| 577 |
|
selseqs[0].getContactListFor(selseqs[0].getAnnotation()[0], 2)); |
| 578 |
|
} |
| 579 |
|
} |