JAL-845 SplitFrame for "show product" and after aligning from SplitFrame
[jalview.git] / test / jalview / analysis / AlignmentUtilsTests.java
index d1300fe..c29658b 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.analysis;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import jalview.analysis.AlignmentUtils.MappingResult;
 import jalview.datamodel.AlignedCodonFrame;
@@ -481,4 +482,29 @@ public class AlignmentUtilsTests
     checkAlignSequenceAs("GG-G-AA-A-C-CC-T-TT", "AL",
             false, true, map, "GG-G-AA-ACCCTTT");
   }
+
+  /**
+   * Test for the method that generates an aligned translated sequence from one
+   * mapping.
+   */
+  @Test
+  public void testGetAlignedTranslation_dnaLikeProtein()
+  {
+    // dna alignment will be replaced
+    SequenceI dna = new Sequence("Seq1", "T-G-CC-A--T-TAC-CAG-");
+    dna.createDatasetSequence();
+    // protein alignment will be 'applied' to dna
+    SequenceI protein = new Sequence("Seq1", "-CH-Y--Q-");
+    protein.createDatasetSequence();
+    MapList map = new MapList(new int[]
+    { 1, 12 }, new int[]
+    { 1, 4 }, 3, 1);
+    AlignedCodonFrame acf = new AlignedCodonFrame();
+    acf.addMap(dna.getDatasetSequence(), protein.getDatasetSequence(), map);
+
+    final SequenceI aligned = AlignmentUtils
+                .getAlignedTranslation(protein, '-', acf);
+    assertEquals("---TGCCAT---TAC------CAG---", aligned.getSequenceAsString());
+    assertSame(aligned.getDatasetSequence(), dna.getDatasetSequence());
+  }
 }