JAL-4366 fixed wrinkles in reconstructing peptide alignment using 3di alignment....
[jalview.git] / test / jalview / datamodel / AlignmentTest.java
index 67965c2..30c0de4 100644 (file)
@@ -100,9 +100,9 @@ public class AlignmentTest
   
   private static final String AA_SEQS_2 = 
           ">Seq1Name/5-8\n" +
-          "K-QY--L\n" +
+          "K-QY-L\n" +
           ">Seq2Name/12-15\n" +
-          "-R-FP-W-\n";
+          "-R-FPW\n";
   private static final String AA_SEQS_2_DS = 
           ">Seq1Name/5-8\n" +
           "KQYL\n" +
@@ -813,7 +813,7 @@ public class AlignmentTest
     AlignmentI al1 = loadAlignment(TD_SEQS_2, FileFormat.Fasta);
     AlignmentI al2 = loadAlignment(AA_SEQS_2_DS, FileFormat.Fasta);
     al1.setDataset(null);
-    al2.setDataset(null);
+    al2.setDataset(al1.getDataset());
     AlignmentI al1copy = new Alignment(al1);
     AlignmentI al2copy = new Alignment(al2);
     AlignmentUtils.map3diPeptideToProteinAligment(al2, al1);
@@ -828,6 +828,32 @@ public class AlignmentTest
     
   }
   /**
+   * Recover TdI MSA from protein msa
+   * 
+   * @throws IOException
+   */
+  @Test(groups = { "Functional" })
+  public void testAlignAs_tdi_prot() throws Exception
+  {
+    // see also AlignmentUtilsTests
+    AlignmentI al1 = loadAlignment(AA_SEQS_2, FileFormat.Fasta);
+    AlignmentI al2 = loadAlignment(TD_SEQS_2_DS, FileFormat.Fasta);
+    al1.setDataset(null);
+    al2.setDataset(al1.getDataset());
+    AlignmentI al1copy = new Alignment(al1);
+    AlignmentI al2copy = new Alignment(al2);
+    AlignmentUtils.map3diPeptideToProteinAligment(al1, al2);
+    if (al2.getCodonFrames().isEmpty()) {al2.getCodonFrames().addAll(al1.getCodonFrames()); }
+    else {al1.getCodonFrames().addAll(al2.getCodonFrames()); };
+    
+    ((Alignment) al2).alignAs(al1);
+    assertEquals("K-QY-L", al1.getSequenceAt(0).getSequenceAsString());
+    assertEquals("-R-FPW", al1.getSequenceAt(1).getSequenceAsString());
+    assertEquals("N-MP-R", al2.getSequenceAt(0).getSequenceAsString());
+    assertEquals("-V-XYA", al2.getSequenceAt(1).getSequenceAsString());
+    
+  }
+  /**
    * Test aligning cdna as per protein alignment.
    * 
    * @throws IOException