test for JAL-1177 store and recover RNA secondary structure for a stockholm file...
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 25 Apr 2014 12:49:44 +0000 (13:49 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 25 Apr 2014 12:49:44 +0000 (13:49 +0100)
test/jalview/io/Jalview2xmlTests.java [new file with mode: 0644]

diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java
new file mode 100644 (file)
index 0000000..2e19e99
--- /dev/null
@@ -0,0 +1,70 @@
+package jalview.io;
+
+import static org.junit.Assert.*;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+
+import java.io.File;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Jalview2xmlTests
+{
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception
+  {
+    jalview.bin.Jalview.main(new String[] {"-props","test/src/jalview/io/testProps.jvprops"});
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception
+  {
+    jalview.gui.Desktop.instance.quit();
+  }
+  public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
+  {
+    int numdsann=0;
+    for (SequenceI sq: avp.getAlignment().getDataset().getSequences()) {
+      if (sq.getAnnotation() != null)
+      {
+        for (AlignmentAnnotation dssa : sq.getAnnotation())
+        {
+          if (dssa.isValidStruc())
+          {
+            numdsann++;
+          }
+        }
+      }
+    }
+    return numdsann;
+  }
+  @Test
+  public void testRNAStructureRecovery() throws Exception
+  {
+    String inFile = "examples/RF00031_folded.stk";
+    String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath();
+    AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE);
+    assertTrue("Didn't read input file "+inFile, af!=null);
+    int olddsann=countDsAnn(af.getViewport());
+    assertTrue("Didn't find any dataset annotations",olddsann>0);
+    assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
+    af.closeMenuItem_actionPerformed(true);
+    af=null;
+    af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE);
+    assertTrue("Failed to import new project", af!=null);
+    int newdsann=countDsAnn(af.getViewport());
+    assertTrue("Differing numbers of dataset sequence annotation\nOriginally "+olddsann+" and now "+newdsann,olddsann==newdsann);
+    System.out.println("Read in same number of annotations as originally present ("+olddsann+")");
+  }
+
+}