From 4ffd862cba27561e83a5e25982c742627cc363e5 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 3 Mar 2016 11:02:10 +0000 Subject: [PATCH] JAL-1705 unit test for aligning with incomplete start codon --- test/jalview/analysis/AlignmentUtilsTests.java | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 818267d..f9c1a11 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -1696,4 +1696,55 @@ public class AlignmentUtilsTests 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 acfs = new ArrayList(); + 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()); + } } -- 1.7.10.2