+ exon = exons.get(1);
+ assertEquals("aaaccc", exon.getSequenceAsString());
+ assertEquals("dna1|A12346", exon.getName());
+ assertEquals(1, exon.getDBRef().length);
+ cdsRef = exon.getDBRef()[0];
+ assertEquals("EMBLCDS", cdsRef.getSource());
+ assertEquals("3", cdsRef.getVersion());
+ assertEquals("A12346", cdsRef.getAccessionId());
+
+ exon = exons.get(2);
+ assertEquals("aaaTTT", exon.getSequenceAsString());
+ assertEquals("dna1|A12347", exon.getName());
+ assertEquals(1, exon.getDBRef().length);
+ cdsRef = exon.getDBRef()[0];
+ assertEquals("EMBLCDS", cdsRef.getSource());
+ assertEquals("4", cdsRef.getVersion());
+ assertEquals("A12347", cdsRef.getAccessionId());
+
+ /*
+ * Verify there are mappings from each exon sequence to its protein product
+ * and also to its dna source
+ */
+ Iterator<AlignedCodonFrame> newMappingsIterator = mappings.iterator();
+
+ // mappings for dna1 - exon1 - pep1
+ AlignedCodonFrame exonMapping = newMappingsIterator.next();
+ List<Mapping> dnaMappings = exonMapping.getMappingsForSequence(dna1);
+ assertEquals(1, dnaMappings.size());
+ assertSame(exons.get(0).getDatasetSequence(), dnaMappings.get(0)
+ .getTo());
+ assertEquals("G(1) in CDS should map to G(4) in DNA", 4, dnaMappings
+ .get(0).getMap().getToPosition(1));
+ List<Mapping> peptideMappings = exonMapping
+ .getMappingsForSequence(pep1);
+ assertEquals(1, peptideMappings.size());
+ assertSame(pep1.getDatasetSequence(), peptideMappings.get(0).getTo());
+
+ // mappings for dna1 - exon2 - pep2
+ exonMapping = newMappingsIterator.next();
+ dnaMappings = exonMapping.getMappingsForSequence(dna1);
+ assertEquals(1, dnaMappings.size());
+ assertSame(exons.get(1).getDatasetSequence(), dnaMappings.get(0)
+ .getTo());
+ assertEquals("c(4) in CDS should map to c(7) in DNA", 7, dnaMappings
+ .get(0).getMap().getToPosition(4));
+ peptideMappings = exonMapping.getMappingsForSequence(pep2);
+ assertEquals(1, peptideMappings.size());
+ assertSame(pep2.getDatasetSequence(), peptideMappings.get(0).getTo());
+
+ // mappings for dna1 - exon3 - pep3
+ exonMapping = newMappingsIterator.next();
+ dnaMappings = exonMapping.getMappingsForSequence(dna1);
+ assertEquals(1, dnaMappings.size());
+ assertSame(exons.get(2).getDatasetSequence(), dnaMappings.get(0)
+ .getTo());
+ assertEquals("T(4) in CDS should map to T(10) in DNA", 10, dnaMappings
+ .get(0).getMap().getToPosition(4));
+ peptideMappings = exonMapping.getMappingsForSequence(pep3);
+ assertEquals(1, peptideMappings.size());
+ assertSame(pep3.getDatasetSequence(), peptideMappings.get(0).getTo());
+ }
+
+ @Test(groups = { "Functional" })
+ public void testIsMappable()
+ {
+ SequenceI dna1 = new Sequence("dna1", "cgCAGtgGT");
+ SequenceI aa1 = new Sequence("aa1", "RSG");
+ AlignmentI al1 = new Alignment(new SequenceI[] { dna1 });
+ AlignmentI al2 = new Alignment(new SequenceI[] { aa1 });
+
+ assertFalse(AlignmentUtils.isMappable(null, null));
+ assertFalse(AlignmentUtils.isMappable(al1, null));
+ assertFalse(AlignmentUtils.isMappable(null, al1));
+ assertFalse(AlignmentUtils.isMappable(al1, al1));
+ assertFalse(AlignmentUtils.isMappable(al2, al2));
+
+ assertTrue(AlignmentUtils.isMappable(al1, al2));
+ assertTrue(AlignmentUtils.isMappable(al2, al1));