X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2FAlignmentUtilsTests.java;h=74e4940b43ffefa5e53dadbaf03d9ca3f6369399;hb=239d28bd8c08790bbc513a09b2b869fff862f63f;hp=2beacfee7509cff25808b9ec3970850f419cfe26;hpb=52288466dd1e71946a06fd1e6ea15fa8e652c693;p=jalview.git diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 2beacfe..74e4940 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -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 protseqs = new ArrayList(); 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 protseqs = new ArrayList(); @@ -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 protseqs = new ArrayList(); 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 protseqs = new ArrayList(); 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()); @@ -987,7 +988,7 @@ public class AlignmentUtilsTests assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1)); // now the other way round - seq1.setDBRef(null); + seq1.setDBRefs(null); seq2.addDBRef(new DBRefEntry("EMBL", "1", "A12345")); assertTrue(AlignmentUtils.haveCrossRef(seq1, seq2)); assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1)); @@ -1123,8 +1124,8 @@ public class AlignmentUtilsTests assertEquals("GGGTTT", exon.getSequenceAsString()); assertEquals("dna1|A12345", exon.getName()); - assertEquals(1, exon.getDBRef().length); - DBRefEntry cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + DBRefEntry cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("2", cdsRef.getVersion()); assertEquals("A12345", cdsRef.getAccessionId()); @@ -1194,8 +1195,8 @@ public class AlignmentUtilsTests SequenceI exon = exons.get(0); assertEquals("GGGTTT", exon.getSequenceAsString()); assertEquals("dna1|A12345", exon.getName()); - assertEquals(1, exon.getDBRef().length); - DBRefEntry cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + DBRefEntry cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("2", cdsRef.getVersion()); assertEquals("A12345", cdsRef.getAccessionId()); @@ -1203,8 +1204,8 @@ public class AlignmentUtilsTests exon = exons.get(1); assertEquals("aaaccc", exon.getSequenceAsString()); assertEquals("dna1|A12346", exon.getName()); - assertEquals(1, exon.getDBRef().length); - cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("3", cdsRef.getVersion()); assertEquals("A12346", cdsRef.getAccessionId()); @@ -1212,8 +1213,8 @@ public class AlignmentUtilsTests exon = exons.get(2); assertEquals("aaaTTT", exon.getSequenceAsString()); assertEquals("dna1|A12347", exon.getName()); - assertEquals(1, exon.getDBRef().length); - cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("4", cdsRef.getVersion()); assertEquals("A12347", cdsRef.getAccessionId()); @@ -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()); + } }