X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FAlignedCodonFrameTest.java;fp=test%2Fjalview%2Fdatamodel%2FAlignedCodonFrameTest.java;h=4984e5e0ab239eaaf81819a013e5f05cc1fcc4ab;hb=ca38821c63596c7f3ed2ff379e4430cc43d88484;hp=69e584aba55b82a9aa0defde215779d8061c5eae;hpb=a31403382672ec59acdf56e095d6d0136199fb44;p=jalview.git diff --git a/test/jalview/datamodel/AlignedCodonFrameTest.java b/test/jalview/datamodel/AlignedCodonFrameTest.java index 69e584a..4984e5e 100644 --- a/test/jalview/datamodel/AlignedCodonFrameTest.java +++ b/test/jalview/datamodel/AlignedCodonFrameTest.java @@ -23,6 +23,7 @@ package jalview.datamodel; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; import jalview.util.MapList; @@ -213,6 +214,10 @@ public class AlignedCodonFrameTest 17)); } + /** + * Tests for the method that tests whether any mapping to a dummy sequence can + * be 'realised' to a given real sequence + */ @Test(groups = { "Functional" }) public void testIsRealisableWith() { @@ -238,27 +243,69 @@ public class AlignedCodonFrameTest seq1proxy.setName("Seq1a"); assertFalse(acf.isRealisableWith(seq1)); seq1proxy.setName("Seq1"); - seq1.setName("Seq1a"); + + SequenceI seq1ds = seq1.getDatasetSequence(); + seq1ds.setName("Seq1a"); assertFalse(acf.isRealisableWith(seq1)); - seq1.setName("Seq1"); + seq1ds.setName("Seq1"); /* * test should fail if no sequence overlap with mapping of bases 7-12 * use artificial start/end values to test this */ - seq1.setStart(1); - seq1.setEnd(6); + seq1ds.setStart(1); + seq1ds.setEnd(6); // seq1 precedes mapped region: assertFalse(acf.isRealisableWith(seq1)); - seq1.setEnd(7); + seq1ds.setEnd(7); // seq1 includes first mapped base: assertTrue(acf.isRealisableWith(seq1)); - seq1.setStart(13); - seq1.setEnd(18); + seq1ds.setStart(13); + seq1ds.setEnd(18); // seq1 follows mapped region: assertFalse(acf.isRealisableWith(seq1)); - seq1.setStart(12); + seq1ds.setStart(12); // seq1 includes last mapped base: assertTrue(acf.isRealisableWith(seq1)); } + + /** + * Tests for the method that converts mappings to a dummy sequence to mappings + * to a compatible real sequence + */ + @Test(groups = { "Functional" }) + public void testRealiseWith() + { + SequenceI seq1 = new Sequence("Seq1", "tttCAACCCGGGtttaaa"); + SequenceI seq2 = new Sequence("Seq2", "QPG"); + SequenceI seq1proxy = new SequenceDummy("Seq1"); + seq1.createDatasetSequence(); + seq2.createDatasetSequence(); + + /* + * Make two mappings from Seq2 peptide to dummy sequence Seq1 + */ + AlignedCodonFrame acf = new AlignedCodonFrame(); + + // map PG to codons 7-12 (CCCGGG) + MapList mapping1 = new MapList(new int[] { 7, 12 }, new int[] { 2, 3 }, + 3, 1); + acf.addMap(seq1proxy, seq2, mapping1); + + // map QP to codons 4-9 (CAACCC) + MapList mapping2 = new MapList(new int[] { 4, 9 }, new int[] { 1, 2 }, + 3, 1); + acf.addMap(seq1proxy, seq2, mapping2); + + assertEquals(2, acf.getdnaSeqs().length); + assertSame(seq1proxy, acf.getdnaSeqs()[0]); + assertSame(seq1proxy, acf.getdnaSeqs()[1]); + assertEquals(2, acf.getProtMappings().length); + + // 'realise' these mappings with the compatible sequence seq1 + // two mappings should be updated: + assertEquals(2, acf.realiseWith(seq1)); + assertSame(seq1.getDatasetSequence(), acf.getdnaSeqs()[0]); + assertSame(seq1.getDatasetSequence(), acf.getdnaSeqs()[1]); + } }