JAL-3010 unit test for vararg findColumnsWithFeature
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 4 Jun 2018 10:55:48 +0000 (11:55 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 4 Jun 2018 10:55:48 +0000 (11:55 +0100)
test/jalview/controller/AlignViewControllerTest.java

index 469481d..ab32616 100644 (file)
@@ -60,25 +60,24 @@ public class AlignViewControllerTest
   public void testFindColumnsWithFeature()
   {
     SequenceI seq1 = new Sequence("seq1", "-a-MMMaaaaaaaaaaaaaaaa");
-    SequenceI seq2 = new Sequence("seq2", "aa--aMM-MMMMMaaaaaaaaaa");
+    SequenceI seq2 = new Sequence("seq2/11-30", "aa--aMM-MMMMMaaaaaaaaaa");
     SequenceI seq3 = new Sequence("seq3", "abcab-caD-aaMMMMMaaaaa");
     SequenceI seq4 = new Sequence("seq4", "abc--abcaaaaaaaaaaaaaa");
 
     /*
-     * features start/end are base 1
+     * features
      */
-    seq1.addSequenceFeature(new SequenceFeature("Metal", "desc", 2, 4, 0f,
-            null));
-    seq1.addSequenceFeature(new SequenceFeature("Helix", "desc", 1, 15, 0f,
-            null));
-    seq2.addSequenceFeature(new SequenceFeature("Metal", "desc", 4, 10,
-            10f,
-            null));
-    seq3.addSequenceFeature(new SequenceFeature("Metal", "desc", 11, 15,
-            10f, null));
+    seq1.addSequenceFeature(
+            new SequenceFeature("Metal", "desc", 2, 4, 0f, null));
+    seq1.addSequenceFeature(
+            new SequenceFeature("Helix", "desc", 1, 15, 0f, null));
+    seq2.addSequenceFeature(
+            new SequenceFeature("Metal", "desc", 14, 20, 10f, null));
+    seq3.addSequenceFeature(
+            new SequenceFeature("Metal", "desc", 11, 15, 10f, null));
     // disulfide bond is a 'contact feature' - only select its 'start' and 'end'
-    seq3.addSequenceFeature(new SequenceFeature("disulfide bond", "desc",
-            8, 12, 0f, null));
+    seq3.addSequenceFeature(
+            new SequenceFeature("disulfide bond", "desc", 8, 12, 0f, null));
 
     /*
      * select the first five columns --> Metal in seq1 cols 4-5
@@ -94,8 +93,10 @@ public class AlignViewControllerTest
     /*
      * set features visible on a viewport as only visible features are selected
      */
-    AlignFrame af = new AlignFrame(new Alignment(new SequenceI[] { seq1,
-        seq2, seq3, seq4 }), 100, 100);
+    Alignment al = new Alignment(
+            new SequenceI[]
+            { seq1, seq2, seq3, seq4 });
+    AlignFrame af = new AlignFrame(al, 100, 100);
     af.getFeatureRenderer().findAllFeatures(true);
 
     AlignViewController avc = new AlignViewController(af, af.getViewport(),
@@ -183,6 +184,29 @@ public class AlignViewControllerTest
     assertTrue(bs.get(13));
 
     /*
+     * look for multiple features; should match 
+     * transcript_variant in seq3 positions 3-6, columns 3-7
+     * sequence_variant in seq2 positions 15-18, columns 7-11
+     * transcript_variant in seq3 positions 8 and 12, columns 9 and 14 
+     */
+    seq3.addSequenceFeature(new SequenceFeature("transcript_variant",
+            "desc", 3, 6, 0f, null));
+    seq2.addSequenceFeature(new SequenceFeature("sequence_variant", "desc",
+            15, 18, 0f, null));
+    sg.setStartRes(0);
+    sg.setEndRes(20);
+    bs.clear();
+    seqCount = avc.findColumnsWithFeature(sg, bs, "transcript_variant",
+            "sequence_variant", "disulfide bond", "junk");
+    assertEquals(2, seqCount);
+    assertEquals(10, bs.cardinality()); // 2-10 and 13, base 0
+    for (int i = 2; i <= 10; i++)
+    {
+      assertTrue(bs.get(i));
+    }
+    assertTrue(bs.get(13));
+
+    /*
      * look for a feature that isn't there
      */
     sg.setStartRes(0);