+
+ @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));
+ }
+
+ /**
+ * 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());
+ }
+
+ /**
+ * Test for the alignSequenceAs method where we have protein mapped to protein
+ */
+ @Test(groups = { "Functional" })
+ public void testAlignSequenceAs_mappedProteinProtein()
+ {
+
+ SequenceI alignMe = new Sequence("Match", "MGAASEV");
+ alignMe.createDatasetSequence();
+ SequenceI alignFrom = new Sequence("Query", "LQTGYMGAASEVMFSPTRR");
+ alignFrom.createDatasetSequence();
+
+ AlignedCodonFrame acf = new AlignedCodonFrame();
+ // this is like a domain or motif match of part of a peptide sequence
+ MapList map = new MapList(new int[] { 6, 12 }, new int[] { 1, 7 }, 1, 1);
+ acf.addMap(alignFrom.getDatasetSequence(),
+ alignMe.getDatasetSequence(), map);
+
+ AlignmentUtils.alignSequenceAs(alignMe, alignFrom, acf, "-", '-', true,
+ true);
+ assertEquals("-----MGAASEV-------", alignMe.getSequenceAsString());
+ }
+
+ /**
+ * Test for the alignSequenceAs method where there are trailing unmapped
+ * residues in the model sequence
+ */
+ @Test(groups = { "Functional" })
+ public void testAlignSequenceAs_withTrailingPeptide()
+ {
+ // map first 3 codons to KPF; G is a trailing unmapped residue
+ MapList map = new MapList(new int[] { 1, 9 }, new int[] { 1, 3 }, 3, 1);
+
+ checkAlignSequenceAs("AAACCCTTT", "K-PFG", true, true, map,
+ "AAA---CCCTTT---");
+ }