JAL-1270 testPadGaps() added
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 29 Jan 2018 14:04:34 +0000 (14:04 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 29 Jan 2018 14:04:34 +0000 (14:04 +0000)
test/jalview/datamodel/AlignmentTest.java

index 2fed815..ddba949 100644 (file)
@@ -1437,4 +1437,20 @@ public class AlignmentTest
     assertTrue(Comparison.isGap(al.getSequenceAt(1).getSequence()[6]));
     assertFalse(Comparison.isGap(al.getSequenceAt(1).getSequence()[7]));
   }
+
+  @Test(groups = { "Functional" })
+  public void testPadGaps()
+  {
+    SequenceI seq1 = new Sequence("seq1", "ABCDEF--");
+    SequenceI seq2 = new Sequence("seq2", "-JKLMNO--");
+    SequenceI seq3 = new Sequence("seq2", "-PQR");
+    AlignmentI a = new Alignment(new SequenceI[] { seq1, seq2, seq3 });
+    a.setGapCharacter('.'); // this replaces existing gaps
+    assertEquals("ABCDEF..", seq1.getSequenceAsString());
+    a.padGaps();
+    // trailing gaps are pruned, short sequences padded with gap character
+    assertEquals("ABCDEF.", seq1.getSequenceAsString());
+    assertEquals(".JKLMNO", seq2.getSequenceAsString());
+    assertEquals(".PQR...", seq3.getSequenceAsString());
+  }
 }