+
+ @Test(groups = "Functional")
+ public void testGetMappedPositions()
+ {
+ // CDS including stop codon taa
+ SequenceI cds = new Sequence("cds/10-21", "ATGcgtGGAtaa");
+ SequenceI peptide = new Sequence("peptide", "MRG"); // ATG, CGT, GGA
+
+ /*
+ * emulate 'map from' range based on CDS _including_ stop codon
+ */
+ MapList map = new MapList(new int[] { 10, 21 }, new int[] { 1, 3 }, 3,
+ 1);
+ Mapping mapping = new Mapping(peptide, map);
+
+ MappedFeatures mf = new MappedFeatures(mapping, cds, 2, 'M', null);
+
+ /*
+ * scenario: sequence_variant feature on CDS at position 14;
+ * find the corresponding position on peptide
+ */
+ int[] pepPos = mf.getMappedPositions(14, 14);
+ assertEquals(pepPos[0], 2);
+ assertEquals(pepPos[1], 2);
+
+ /*
+ * scenario: exon feature on CDS including stop codon;
+ */
+ pepPos = mf.getMappedPositions(10, 21);
+ assertEquals(pepPos[0], 1);
+ assertEquals(pepPos[1], 3);
+
+ /*
+ * now with the mapping from protein to CDS
+ */
+ mapping = new Mapping(cds, map.getInverse());
+ mf = new MappedFeatures(mapping, peptide, 15, 't', null);
+ int[] cdsPos = mf.getMappedPositions(2, 2);
+ assertEquals(cdsPos[0], 13);
+ assertEquals(cdsPos[1], 15);
+ }