X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fanalysis%2FRnaTest.java;h=1faf3f2a85ff767931ed15526443a68728881e69;hb=3ac6f45c254aaafa6bdf163bf66bb4031de21fa3;hp=df396b72ca246f9f48d7adae4f4534e5fea66b4c;hpb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;p=jalview.git diff --git a/test/jalview/analysis/RnaTest.java b/test/jalview/analysis/RnaTest.java index df396b7..1faf3f2 100644 --- a/test/jalview/analysis/RnaTest.java +++ b/test/jalview/analysis/RnaTest.java @@ -1,6 +1,6 @@ /* - * 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. * @@ -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()); + } }