X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Futil%2FMappingUtilsTest.java;h=9239ba596269f43cb57c3468a584e3a055b84346;hb=747167089ecf8d6afc70d417f5a20352e029bd95;hp=4b7c75c2eb8bc7c3f92b659a49ab84b2f60fb2c1;hpb=d52ea4bd9e9692c73c5a427b3aa0ad2fd988a26e;p=jalview.git diff --git a/test/jalview/util/MappingUtilsTest.java b/test/jalview/util/MappingUtilsTest.java index 4b7c75c..9239ba5 100644 --- a/test/jalview/util/MappingUtilsTest.java +++ b/test/jalview/util/MappingUtilsTest.java @@ -38,7 +38,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import jalview.api.AlignViewportI; -import jalview.bin.Cache; +import jalview.bin.Console; import jalview.commands.EditCommand; import jalview.commands.EditCommand.Action; import jalview.commands.EditCommand.Edit; @@ -59,12 +59,13 @@ import jalview.io.FileFormat; import jalview.io.FileFormatI; import jalview.io.FormatAdapter; + public class MappingUtilsTest { @BeforeClass(alwaysRun = true) public void setUp() { - Cache.initLogger(); + Console.initLogger(); } @BeforeClass(alwaysRun = true) @@ -244,7 +245,7 @@ public class MappingUtilsTest protein.setCodonFrames(acfList); /* - * Select Seq1 and Seq3 in the protein (startRes=endRes=0) + * Select Seq1 and Seq3 in the protein */ SequenceGroup sg = new SequenceGroup(); sg.setColourText(true); @@ -252,6 +253,7 @@ public class MappingUtilsTest sg.setOutlineColour(Color.LIGHT_GRAY); sg.addSequence(protein.getSequenceAt(0), false); sg.addSequence(protein.getSequenceAt(2), false); + sg.setEndRes(protein.getWidth() - 1); /* * Verify the mapped sequence group in dna @@ -265,7 +267,7 @@ public class MappingUtilsTest assertSame(cdna.getSequenceAt(0), mappedGroup.getSequences().get(0)); assertSame(cdna.getSequenceAt(2), mappedGroup.getSequences().get(1)); assertEquals(0, mappedGroup.getStartRes()); - assertEquals(2, mappedGroup.getEndRes()); + assertEquals(2, mappedGroup.getEndRes()); // 3 columns (1 codon) /* * Verify mapping sequence group from dna to protein @@ -1346,4 +1348,162 @@ public class MappingUtilsTest overlap = MappingUtils.findOverlap(ranges, 13, 15); assertNull(overlap); } + + /** + * Test mapping a sequence group where sequences in and outside the group + * share a dataset sequence (e.g. alternative CDS for the same gene) + *
+ * This scenario doesn't arise after JAL-3763 changes, but test left as still
+ * valid
+ *
+ * @throws IOException
+ */
+ @Test(groups = { "Functional" })
+ public void testMapSequenceGroup_sharedDataset() throws IOException
+ {
+ /*
+ * Set up dna and protein Seq1/2/3 with mappings (held on the protein
+ * viewport). CDS sequences share the same 'gene' dataset sequence.
+ */
+ SequenceI dna = new Sequence("dna", "aaatttgggcccaaatttgggccc");
+ SequenceI cds1 = new Sequence("cds1/1-6", "aaattt");
+ SequenceI cds2 = new Sequence("cds1/4-9", "tttggg");
+ SequenceI cds3 = new Sequence("cds1/19-24", "gggccc");
+
+ cds1.setDatasetSequence(dna);
+ cds2.setDatasetSequence(dna);
+ cds3.setDatasetSequence(dna);
+
+ SequenceI pep1 = new Sequence("pep1", "KF");
+ SequenceI pep2 = new Sequence("pep2", "FG");
+ SequenceI pep3 = new Sequence("pep3", "GP");
+ pep1.createDatasetSequence();
+ pep2.createDatasetSequence();
+ pep3.createDatasetSequence();
+
+ /*
+ * add mappings from coding positions of dna to respective peptides
+ */
+ AlignedCodonFrame acf = new AlignedCodonFrame();
+ acf.addMap(dna, pep1,
+ new MapList(new int[]
+ { 1, 6 }, new int[] { 1, 2 }, 3, 1));
+ acf.addMap(dna, pep2,
+ new MapList(new int[]
+ { 4, 9 }, new int[] { 1, 2 }, 3, 1));
+ acf.addMap(dna, pep3,
+ new MapList(new int[]
+ { 19, 24 }, new int[] { 1, 2 }, 3, 1));
+
+ List