import static org.junit.Assert.*;
+import java.awt.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
import jalview.api.AlignCalcManagerI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.gui.Jalview2XML;
import jalview.io.AnnotationFile;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.AADisorderClient;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.RNAalifoldClient;
+import jalview.ws.jws2.SequenceAnnotationWSClient;
+import jalview.ws.jws2.dm.JabaOption;
import jalview.ws.jws2.jabaws2.Jws2Instance;
+import jalview.ws.params.AutoCalcSetting;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-public class RNAStructExportImport
+import compbio.metadata.WrongParameterException;
+
+public class RNAStructExportImport
{
public static String testseqs = "examples/unfolded_RF00031.aln";
+ "\nCouldn't complete Annotation file roundtrip input/output/input test.");
}
+ @Test
+ public void testRnaalifoldSettingsRecovery()
+ {
+ List<compbio.metadata.Argument> opts = new ArrayList<compbio.metadata.Argument>();
+ for (compbio.metadata.Argument rg : (List<compbio.metadata.Argument>) rnaalifoldws
+ .getRunnerConfig().getArguments())
+ {
+ if (rg.getDescription().contains("emperature"))
+ {
+ try
+ {
+ rg.setValue("292");
+ } catch (WrongParameterException q)
+ {
+ fail("Couldn't set the temperature parameter "
+ + q.getStackTrace());
+ }
+ opts.add(rg);
+ }
+ if (rg.getDescription().contains("max"))
+ {
+ opts.add(rg);
+ }
+ }
+ alifoldClient = new RNAalifoldClient(rnaalifoldws, af, null, opts);
+
+ af.getViewport().getCalcManager().startWorker(alifoldClient);
+
+ do
+ {
+ try
+ {
+ Thread.sleep(50);
+ } catch (InterruptedException x)
+ {
+ }
+ ;
+ } while (af.getViewport().getCalcManager().isWorking());
+ AutoCalcSetting oldacs = af.getViewport().getCalcIdSettingsFor(alifoldClient.getCalcId());
+ String oldsettings = oldacs.getWsParamFile();
+ // write out parameters
+ jalview.gui.AlignFrame nalf=null;
+ assertTrue("Couldn't write out the Jar file",new Jalview2XML(false).SaveAlignment(af, "testRnalifold_param.jar","trial parameter writeout"));
+ assertTrue("Couldn't read back the Jar file",(nalf = new Jalview2XML(false).LoadJalviewAlign("testRnalifold_param.jar"))!=null);
+ if (nalf!=null)
+ {
+ AutoCalcSetting acs = af.getViewport().getCalcIdSettingsFor(alifoldClient.getCalcId());
+ assertTrue("Calc ID settings not recovered from viewport stash", acs.equals(oldacs));
+ assertTrue("Serialised Calc ID settings not identical to those recovered from viewport stash", acs.getWsParamFile().equals(oldsettings));
+ JMenu nmenu=new JMenu();
+ new SequenceAnnotationWSClient().attachWSMenuEntry(nmenu, rnaalifoldws, af);
+ assertTrue("Couldn't get menu entry for service",nmenu.getItemCount()>0);
+ for (Component itm: nmenu.getMenuComponents())
+ {
+ if (itm instanceof JMenuItem)
+ {
+ JMenuItem i = (JMenuItem) itm;
+ if (i.getText().equals(rnaalifoldws.getAlignAnalysisUI().getAAconToggle()))
+ {
+ i.doClick();
+ break;
+ }
+ }
+ }
+ while (af.getViewport().isCalcInProgress())
+ {
+ try { Thread.sleep(200);
+ } catch (Exception x) {};
+ }
+ AutoCalcSetting acs2 = af.getViewport().getCalcIdSettingsFor(alifoldClient.getCalcId());
+ assertTrue("Calc ID settings after recalculation has not been recovered.", acs2.getWsParamFile().equals(oldsettings));
+ }
+ }
}