Merge branch 'develop' into Release_2_9_0b1_Branch
[jalview.git] / test / jalview / analysis / AlignmentUtilsTests.java
index 75cc18b..6225397 100644 (file)
@@ -281,7 +281,7 @@ public class AlignmentUtilsTests
    * @throws IOException
    */
   @Test(groups = { "Functional" })
-  public void testMapProteinToCdna_noXrefs() throws IOException
+  public void testMapProteinAlignmentToCdna_noXrefs() throws IOException
   {
     List<SequenceI> protseqs = new ArrayList<SequenceI>();
     protseqs.add(new Sequence("UNIPROT|V12345", "EIQ"));
@@ -298,7 +298,7 @@ public class AlignmentUtilsTests
     AlignmentI cdna = new Alignment(dnaseqs.toArray(new SequenceI[4]));
     cdna.setDataset(null);
 
-    assertTrue(AlignmentUtils.mapProteinToCdna(protein, cdna));
+    assertTrue(AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna));
 
     // 3 mappings made, each from 1 to 1 sequence
     assertEquals(3, protein.getCodonFrames().size());
@@ -617,7 +617,7 @@ public class AlignmentUtilsTests
    * @throws IOException
    */
   @Test(groups = { "Functional" })
-  public void testMapProteinToCdna_withStartAndStopCodons()
+  public void testMapProteinAlignmentToCdna_withStartAndStopCodons()
           throws IOException
   {
     List<SequenceI> protseqs = new ArrayList<SequenceI>();
@@ -638,7 +638,7 @@ public class AlignmentUtilsTests
     AlignmentI cdna = new Alignment(dnaseqs.toArray(new SequenceI[4]));
     cdna.setDataset(null);
 
-    assertTrue(AlignmentUtils.mapProteinToCdna(protein, cdna));
+    assertTrue(AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna));
 
     // 3 mappings made, each from 1 to 1 sequence
     assertEquals(3, protein.getCodonFrames().size());
@@ -710,7 +710,7 @@ public class AlignmentUtilsTests
    * @throws IOException
    */
   @Test(groups = { "Functional" })
-  public void testMapProteinToCdna_withXrefs() throws IOException
+  public void testMapProteinAlignmentToCdna_withXrefs() throws IOException
   {
     List<SequenceI> protseqs = new ArrayList<SequenceI>();
     protseqs.add(new Sequence("UNIPROT|V12345", "EIQ"));
@@ -739,7 +739,7 @@ public class AlignmentUtilsTests
     // A11111 should be mapped to V12347
     // A55555 is spare and has no xref so is not mapped
 
-    assertTrue(AlignmentUtils.mapProteinToCdna(protein, cdna));
+    assertTrue(AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna));
 
     // 4 protein mappings made for 3 proteins, 2 to V12345, 1 each to V12346/7
     assertEquals(3, protein.getCodonFrames().size());
@@ -786,7 +786,8 @@ public class AlignmentUtilsTests
    * @throws IOException
    */
   @Test(groups = { "Functional" })
-  public void testMapProteinToCdna_prioritiseXrefs() throws IOException
+  public void testMapProteinAlignmentToCdna_prioritiseXrefs()
+          throws IOException
   {
     List<SequenceI> protseqs = new ArrayList<SequenceI>();
     protseqs.add(new Sequence("UNIPROT|V12345", "EIQ"));
@@ -806,7 +807,7 @@ public class AlignmentUtilsTests
     // A11111 should then be mapped to the unmapped V12346
     dnaseqs.get(1).addDBRef(new DBRefEntry("UNIPROT", "1", "V12345"));
 
-    assertTrue(AlignmentUtils.mapProteinToCdna(protein, cdna));
+    assertTrue(AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna));
 
     // 2 protein mappings made
     assertEquals(2, protein.getCodonFrames().size());
@@ -1279,4 +1280,27 @@ public class AlignmentUtilsTests
     assertTrue(AlignmentUtils.isMappable(al1, al2));
     assertTrue(AlignmentUtils.isMappable(al2, al1));
   }
+
+  /**
+   * Test creating a mapping when the sequences involved do not start at residue
+   * 1
+   * 
+   * @throws IOException
+   */
+  @Test(groups = { "Functional" })
+  public void testMapProteinSequenceToCdna_forSubsequence()
+          throws IOException
+  {
+    SequenceI prot = new Sequence("UNIPROT|V12345", "E-I--Q", 10, 12);
+    prot.createDatasetSequence();
+
+    SequenceI dna = new Sequence("EMBL|A33333", "GAA--AT-C-CAG", 40, 48);
+    dna.createDatasetSequence();
+
+    MapList map = AlignmentUtils.mapProteinSequenceToCdna(prot, dna);
+    assertEquals(10, map.getToLowest());
+    assertEquals(12, map.getToHighest());
+    assertEquals(40, map.getFromLowest());
+    assertEquals(48, map.getFromHighest());
+  }
 }