expected.addResult(dna1.getDatasetSequence(), 17, 18);
assertEquals(sr, expected);
}
+
+ @Test(groups = { "Functional" })
+ public void testGetCoveringCodonMapping()
+ {
+ SequenceI dna = new Sequence("dna/10-30", "acttcaATGGCGGACtaattt");
+ // CDS sequence with its own dataset sequence (JAL-3763)
+ SequenceI cds = new Sequence("cds/1-9", "-A--TGGC-GGAC");
+ cds.createDatasetSequence();
+ SequenceI pep = new Sequence("pep/1-3", "MAD");
+
+ /*
+ * with null argument or no mappings
+ */
+ AlignedCodonFrame acf = new AlignedCodonFrame();
+ assertNull(acf.getCoveringCodonMapping(null));
+ assertNull(acf.getCoveringCodonMapping(dna));
+ assertNull(acf.getCoveringCodonMapping(pep));
+
+ /*
+ * with a non-covering mapping e.g. overlapping exon
+ */
+ MapList map = new MapList(new int[] { 16, 18 }, new int[] {
+ 1, 1 }, 3, 1);
+ acf.addMap(dna, pep, map);
+ assertNull(acf.getCoveringCodonMapping(dna));
+ assertNull(acf.getCoveringCodonMapping(pep));
+
+ acf = new AlignedCodonFrame();
+ MapList map2 = new MapList(new int[] { 13, 18 }, new int[] {
+ 2, 2 }, 3, 1);
+ acf.addMap(dna, pep, map2);
+ assertNull(acf.getCoveringCodonMapping(dna));
+ assertNull(acf.getCoveringCodonMapping(pep));
+
+ /*
+ * with a covering mapping from CDS (dataset) to protein
+ */
+ acf = new AlignedCodonFrame();
+ MapList map3 = new MapList(new int[] { 1, 9 }, new int[] {
+ 1, 3 }, 3, 1);
+ acf.addMap(cds.getDatasetSequence(), pep, map3);
+ assertNull(acf.getCoveringCodonMapping(dna));
+ SequenceToSequenceMapping mapping = acf.getCoveringCodonMapping(pep);
+ assertNotNull(mapping);
+ SequenceToSequenceMapping mapping2 = acf.getCoveringCodonMapping(cds.getDatasetSequence());
+ assertSame(mapping, mapping2);
+
+ /*
+ * with a mapping that extends to stop codon
+ * (EMBL CDS location often includes the stop codon)
+ * - getCoveringCodonMapping is lenient (doesn't require exact length match)
+ */
+ SequenceI cds2 = new Sequence("cds/1-12", "-A--TGGC-GGACTAA");
+ cds2.createDatasetSequence();
+ acf = new AlignedCodonFrame();
+ MapList map4 = new MapList(new int[] { 1, 12 }, new int[] {
+ 1, 3 }, 3, 1);
+ acf.addMap(cds2, pep, map4);
+ mapping = acf.getCoveringCodonMapping(cds2.getDatasetSequence());
+ assertNotNull(mapping);
+ mapping2 = acf.getCoveringCodonMapping(pep);
+ assertSame(mapping, mapping2);
+ }
}