JAL-3748 maximal test for JAL-3748 using covid19 CDS/Protein
authorJim Procter <jprocter@issues.jalview.org>
Wed, 23 Sep 2020 16:11:39 +0000 (17:11 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 23 Sep 2020 16:11:39 +0000 (17:11 +0100)
test/jalview/gui/SplitFrameTest.java

index f9ef572..7420e71 100644 (file)
@@ -186,5 +186,39 @@ public class SplitFrameTest
             !copyComplement.getSequenceAt(0).getSequenceAsString().equals(
                     copyComplement.getSequenceAt(1).getSequenceAsString()),
             "Didn't reconstruct CDS correctly");
+    // now get the result again, do some edits and reconstruct again
+    alAndHidden = inputView.getAlignmentAndHiddenColumns(
+            proteinAf.getViewport().getGapCharacter());
+    AlignmentI newresult = new Alignment((SequenceI[]) alAndHidden[0]);
+    newresult.setHiddenColumns((HiddenColumns) alAndHidden[1]);
+    newresult.setDataset(complementDs);
+    newresult.getSequenceAt(0).insertCharAt(3, 3, '-');
+    newresult.getSequenceAt(1).insertCharAt(0, 3, '-');
+    newresult.padGaps();
+    AlignmentI newcomplement = inputView.getComplementView()
+            .getVisibleAlignment('-');
+    newcomplement.alignAs(newresult);
+    assertEquals(newcomplement.getWidth(), newresult.getWidth() * 3);
+    assertEquals(newcomplement.getHeight(), newresult.getHeight());
+    // if reconstruction worked, the first sequence should not equal the first
+    // sequence in the original CDS 'alignAs'
+    for (int sq = 0; sq < 3; sq++)
+    {
+      // check same CDS in same position
+      assertTrue(newcomplement.getSequenceAt(sq)
+              .getDatasetSequence() == newcomplement.getSequenceAt(sq)
+                      .getDatasetSequence());
+      // verify that sequence strings are different
+      assertTrue(!newcomplement.getSequenceAt(sq).getSequenceAsString()
+              .equals(copyComplement.getSequenceAt(sq)
+                      .getSequenceAsString()));
+    }
+    // JAL-3748 bug manifests as duplicated CDS sequence content, so need to
+    // also check each CDS is distinct.
+    assertTrue(
+            !newcomplement.getSequenceAt(0).getSequenceAsString().equals(
+                    newcomplement.getSequenceAt(1).getSequenceAsString()),
+            "Didn't reconstruct CDS correctly");
+
   }
 }