/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import jalview.util.MapList;
-
import java.util.Arrays;
import java.util.List;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping;
+import jalview.gui.JvOptionPane;
+import jalview.util.MapList;
+
public class AlignedCodonFrameTest
{
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
/**
* Test the method that locates the first aligned sequence that has a mapping.
*/
assertEquals(1, acf.getMappingsFromSequence(seq1).size());
assertSame(before, acf.getMappingsFromSequence(seq1).get(0));
}
+
+ @Test(groups = { "Functional" })
+ public void testGetCoveringMapping()
+ {
+ SequenceI dna = new Sequence("dna", "acttcaATGGCGGACtaattt");
+ SequenceI cds = new Sequence("cds/7-15", "ATGGCGGAC");
+ cds.setDatasetSequence(dna);
+ SequenceI pep = new Sequence("pep", "MAD");
+
+ /*
+ * with null argument or no mappings
+ */
+ AlignedCodonFrame acf = new AlignedCodonFrame();
+ assertNull(acf.getCoveringMapping(null, null));
+ assertNull(acf.getCoveringMapping(dna, null));
+ assertNull(acf.getCoveringMapping(null, pep));
+ assertNull(acf.getCoveringMapping(dna, pep));
+
+ /*
+ * with a non-covering mapping e.g. overlapping exon
+ */
+ MapList map = new MapList(new int[] { 7, 9 }, new int[] {
+ 1, 1 }, 3, 1);
+ acf.addMap(dna, pep, map);
+ assertNull(acf.getCoveringMapping(dna, pep));
+
+ acf = new AlignedCodonFrame();
+ MapList map2 = new MapList(new int[] { 13, 18 }, new int[] {
+ 2, 2 }, 3, 1);
+ acf.addMap(dna, pep, map2);
+ assertNull(acf.getCoveringMapping(dna, pep));
+
+ /*
+ * with a covering mapping from CDS (dataset) to protein
+ */
+ acf = new AlignedCodonFrame();
+ MapList map3 = new MapList(new int[] { 7, 15 }, new int[] {
+ 1, 3 }, 3, 1);
+ acf.addMap(dna, pep, map3);
+ assertNull(acf.getCoveringMapping(dna, pep));
+ SequenceToSequenceMapping mapping = acf.getCoveringMapping(cds, pep);
+ assertNotNull(mapping);
+
+ /*
+ * with a mapping that extends to stop codon
+ */
+ acf = new AlignedCodonFrame();
+ MapList map4 = new MapList(new int[] { 7, 18 }, new int[] {
+ 1, 3 }, 3, 1);
+ acf.addMap(dna, pep, map4);
+ assertNull(acf.getCoveringMapping(dna, pep));
+ assertNull(acf.getCoveringMapping(cds, pep));
+ SequenceI cds2 = new Sequence("cds/7-18", "ATGGCGGACtaa");
+ cds2.setDatasetSequence(dna);
+ mapping = acf.getCoveringMapping(cds2, pep);
+ assertNotNull(mapping);
+ }
}