assertEquals("[11, 17]", Arrays.toString(cdsColumns.get(2)));
assertEquals("[19, 23]", Arrays.toString(cdsColumns.get(3)));
}
+
+ /**
+ * Test the method that realigns protein to match mapped codon alignment.
+ */
+ @Test(groups = { "Functional" })
+ public void testAlignProteinAsDna_incompleteStartCodon()
+ {
+ // seq1: incomplete start codon (not mapped), then [3, 11]
+ SequenceI dna1 = new Sequence("Seq1", "ccAAA-TTT-GGG-");
+ // seq2 codons are [4, 5], [8, 11]
+ SequenceI dna2 = new Sequence("Seq2", "ccaAA-ttT-GGG-");
+ // seq3 incomplete start codon at 'tt'
+ SequenceI dna3 = new Sequence("Seq3", "ccaaa-ttt-GGG-");
+ AlignmentI dna = new Alignment(new SequenceI[] { dna1, dna2, dna3 });
+ dna.setDataset(null);
+
+ // prot1 has 'X' for incomplete start codon (not mapped)
+ SequenceI prot1 = new Sequence("Seq1", "XKFG"); // X for incomplete start
+ SequenceI prot2 = new Sequence("Seq2", "NG");
+ SequenceI prot3 = new Sequence("Seq3", "XG"); // X for incomplete start
+ AlignmentI protein = new Alignment(new SequenceI[] { prot1, prot2,
+ prot3 });
+ protein.setDataset(null);
+
+ // map dna1 [3, 11] to prot1 [2, 4] KFG
+ MapList map = new MapList(new int[] { 3, 11 }, new int[] { 2, 4 }, 3, 1);
+ AlignedCodonFrame acf = new AlignedCodonFrame();
+ acf.addMap(dna1.getDatasetSequence(), prot1.getDatasetSequence(), map);
+
+ // map dna2 [4, 5] [8, 11] to prot2 [1, 2] NG
+ map = new MapList(new int[] { 4, 5, 8, 11 }, new int[] { 1, 2 }, 3, 1);
+ acf.addMap(dna2.getDatasetSequence(), prot2.getDatasetSequence(), map);
+
+ // map dna3 [9, 11] to prot3 [2, 2] G
+ map = new MapList(new int[] { 9, 11 }, new int[] { 2, 2 }, 3, 1);
+ acf.addMap(dna3.getDatasetSequence(), prot3.getDatasetSequence(), map);
+
+ ArrayList<AlignedCodonFrame> acfs = new ArrayList<AlignedCodonFrame>();
+ acfs.add(acf);
+ protein.setCodonFrames(acfs);
+
+ /*
+ * verify X is included in the aligned proteins, and placed just
+ * before the first mapped residue
+ * CCT is between CCC and TTT
+ */
+ AlignmentUtils.alignProteinAsDna(protein, dna);
+ assertEquals("XK-FG", prot1.getSequenceAsString());
+ assertEquals("--N-G", prot2.getSequenceAsString());
+ assertEquals("---XG", prot3.getSequenceAsString());
+ }
}