1 package jalview.ws.jabaws;
3 import static org.junit.Assert.*;
5 import java.util.ArrayList;
6 import java.util.Arrays;
8 import java.util.Vector;
10 import jalview.api.AlignCalcManagerI;
11 import jalview.datamodel.AlignmentAnnotation;
12 import jalview.datamodel.AlignmentI;
13 import jalview.datamodel.Annotation;
14 import jalview.io.AnnotationFile;
15 import jalview.io.FormatAdapter;
16 import jalview.io.StockholmFileTest;
17 import jalview.ws.jws2.AADisorderClient;
18 import jalview.ws.jws2.Jws2Discoverer;
19 import jalview.ws.jws2.RNAalifoldClient;
20 import jalview.ws.jws2.jabaws2.Jws2Instance;
22 import org.junit.AfterClass;
23 import org.junit.BeforeClass;
24 import org.junit.Test;
26 public class RNAStructExportImport
28 public static String testseqs = "examples/unfolded_RF00031.aln";
30 public static Jws2Discoverer disc;
32 public static Jws2Instance rnaalifoldws;
34 jalview.ws.jws2.RNAalifoldClient alifoldClient;
36 public static jalview.gui.AlignFrame af = null;
39 public static void setUpBeforeClass() throws Exception
43 jalview.bin.Cache.initLogger();
44 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
46 for (Jws2Instance svc : disc.getServices())
49 if (svc.getServiceTypeURI().toLowerCase().contains("rnaalifoldws"))
55 System.out.println("State of rnaalifoldws: " + rnaalifoldws);
57 if (rnaalifoldws == null) System.exit(0);
59 jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
61 af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
63 assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
68 public static void tearDownAfterClass() throws Exception
78 public void testRNAStructExport()
82 alifoldClient = new RNAalifoldClient(rnaalifoldws, af, null, null);
84 af.getViewport().getCalcManager().startWorker(alifoldClient);
92 } catch (InterruptedException x)
96 } while (af.getViewport().getCalcManager().isWorking());
99 AlignmentI orig_alig = af.getViewport().getAlignment();
101 testAnnotationFileIO("Testing RNAalifold Annotation IO", orig_alig);
105 public static void testAnnotationFileIO(String testname, AlignmentI al)
109 // what format would be appropriate for RNAalifold annotations?
110 String aligfileout = new FormatAdapter().formatSequences("PFAM",
111 al.getSequencesArray());
114 String anfileout = new AnnotationFile().printAnnotations(
115 al.getAlignmentAnnotation(), al.getGroups(),
120 + "\nAlignment annotation file was not regenerated. Null string",
125 + "\nAlignment annotation file was not regenerated. Empty string",
126 anfileout.length() > "JALVIEW_ANNOTATION".length());
128 System.out.println("Output annotation file:\n" + anfileout
131 // again what format would be appropriate?
132 AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
133 FormatAdapter.PASTE, "PFAM");
137 + "\nregenerated annotation file did not annotate alignment.",
138 new AnnotationFile().readAnnotationFile(al_new, anfileout,
139 FormatAdapter.PASTE));
141 // test for consistency in io
142 StockholmFileTest.testAlignmentEquivalence(al, al_new);
144 } catch (Exception e)
150 + "\nCouldn't complete Annotation file roundtrip input/output/input test.");