X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2FRnaTest.java;h=1faf3f2a85ff767931ed15526443a68728881e69;hb=7dc7404ce7a339c600130e9828e3efc05b1e3270;hp=9d35a1929d64fa2ac031f3fc96dd411e966a63a5;hpb=37de9310bec3501cbc6381e0c3dcb282fcaad812;p=jalview.git diff --git a/test/jalview/analysis/RnaTest.java b/test/jalview/analysis/RnaTest.java index 9d35a19..1faf3f2 100644 --- a/test/jalview/analysis/RnaTest.java +++ b/test/jalview/analysis/RnaTest.java @@ -27,18 +27,29 @@ import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.fail; import jalview.analysis.SecStrConsensus.SimpleBP; +import jalview.datamodel.SequenceFeature; +import jalview.gui.JvOptionPane; -import java.util.Vector; +import java.util.List; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class RnaTest { + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + @Test(groups = { "Functional" }) public void testGetSimpleBPs() throws WUSSParseException { String rna = "([{})]"; // JAL-1081 example - Vector bps = Rna.getSimpleBPs(rna); + List bps = Rna.getSimpleBPs(rna); assertEquals(3, bps.size()); /* @@ -303,4 +314,54 @@ public class RnaTest .valueOf((char) i) + " ")); } } + + @Test(groups = "Functional") + public void testGetHelixMap_oneHelix() throws WUSSParseException + { + String rna = ".(..[{.<..>}..].)"; + SequenceFeature[] sfs = Rna.getHelixMap(rna); + assertEquals(4, sfs.length); + + /* + * pairs are added in the order in which the closing bracket is found + * (see testGetSimpleBPs) + */ + assertEquals(7, sfs[0].getBegin()); + assertEquals(10, sfs[0].getEnd()); + assertEquals("0", sfs[0].getFeatureGroup()); + assertEquals(5, sfs[1].getBegin()); + assertEquals(11, sfs[1].getEnd()); + assertEquals("0", sfs[1].getFeatureGroup()); + assertEquals(4, sfs[2].getBegin()); + assertEquals(14, sfs[2].getEnd()); + assertEquals("0", sfs[2].getFeatureGroup()); + assertEquals(1, sfs[3].getBegin()); + assertEquals(16, sfs[3].getEnd()); + assertEquals("0", sfs[3].getFeatureGroup()); + } + + @Test(groups = "Functional") + public void testGetHelixMap_twoHelices() throws WUSSParseException + { + String rna = ".([.)]..{.<}.>"; + SequenceFeature[] sfs = Rna.getHelixMap(rna); + assertEquals(4, sfs.length); + + /* + * pairs are added in the order in which the closing bracket is found + * (see testGetSimpleBPs) + */ + assertEquals(1, sfs[0].getBegin()); + assertEquals(4, sfs[0].getEnd()); + assertEquals("0", sfs[0].getFeatureGroup()); + assertEquals(2, sfs[1].getBegin()); + assertEquals(5, sfs[1].getEnd()); + assertEquals("0", sfs[1].getFeatureGroup()); + assertEquals(8, sfs[2].getBegin()); + assertEquals(11, sfs[2].getEnd()); + assertEquals("1", sfs[2].getFeatureGroup()); + assertEquals(10, sfs[3].getBegin()); + assertEquals(13, sfs[3].getEnd()); + assertEquals("1", sfs[3].getFeatureGroup()); + } }