JAL-2597 Fix and unit test bug/JAL-2597
authorkiramt <k.mourao@dundee.ac.uk>
Thu, 29 Jun 2017 13:02:45 +0000 (14:02 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Thu, 29 Jun 2017 13:02:45 +0000 (14:02 +0100)
src/jalview/datamodel/HiddenColumns.java
test/jalview/datamodel/HiddenColumnsTest.java

index d34b316..169b0a4 100644 (file)
@@ -1407,8 +1407,7 @@ public class HiddenColumns
     // recover mapping between sequence's non-gap positions and positions
     // mapping to view.
     pruneDeletions(ShiftList.parseMap(origseq.gapMap()));
-    int[] viscontigs = al.getHiddenColumns().getVisibleContigs(0,
-            profileseq.getLength());
+    int[] viscontigs = getVisibleContigs(0, profileseq.getLength());
     int spos = 0;
     int offset = 0;
 
index fbb354b..7c88d71 100644 (file)
@@ -689,4 +689,46 @@ public class HiddenColumnsTest
     assertNull(result);
   }
 
+  @Test(groups = "Functional")
+  public void testPropagateInsertions()
+  {
+    // create an alignment with no gaps - this will be the profile seq and other
+    // JPRED seqs
+    AlignmentGenerator gen = new AlignmentGenerator(false);
+    AlignmentI al = gen.generate(20, 10, 1234, 0, 0);
+
+    // get the profileseq
+    SequenceI profileseq = al.getSequenceAt(0);
+    SequenceI gappedseq = new Sequence(profileseq);
+    gappedseq.insertCharAt(5, al.getGapCharacter());
+    gappedseq.insertCharAt(6, al.getGapCharacter());
+    gappedseq.insertCharAt(7, al.getGapCharacter());
+    gappedseq.insertCharAt(8, al.getGapCharacter());
+    
+    // create an alignment view with the gapped sequence
+    SequenceI[] seqs = new SequenceI[1];
+    seqs[0] = gappedseq;
+    AlignmentI newal = new Alignment(seqs);
+    HiddenColumns hidden = new HiddenColumns();
+    hidden.hideColumns(15, 17);
+
+    AlignmentView view = new AlignmentView(newal, hidden, null, true, false,
+            false);
+
+    // confirm that original contigs are as expected
+    int[] oldcontigs = hidden.getVisibleContigs(0, 20);
+    int[] testcontigs = { 0, 14, 18, 19 };
+    assertTrue(Arrays.equals(oldcontigs, testcontigs));
+            
+    // propagate insertions
+    HiddenColumns result = HiddenColumns.propagateInsertions(profileseq, al,
+            view);
+
+    // confirm that the contigs have changed to account for the gaps
+    int[] newcontigs = result.getVisibleContigs(0, 20);
+    testcontigs[1] = 10;
+    testcontigs[2] = 14;
+    assertTrue(Arrays.equals(newcontigs, testcontigs));
+    
+  }
 }