/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
- * Copyright (C) 2014 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.
*
*/
package jalview.ws.jabaws;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
+import jalview.gui.AlignFrame;
import jalview.gui.Jalview2XML;
+import jalview.gui.JvOptionPane;
import jalview.io.AnnotationFile;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.JPred301Client;
import jalview.ws.jws2.JabaParamStore;
-import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.SequenceAnnotationWSClient;
import jalview.ws.jws2.jabaws2.Jws2Instance;
-import jalview.ws.params.ArgumentI;
import jalview.ws.params.AutoCalcSetting;
import java.awt.Component;
+import java.net.ConnectException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
+import javax.xml.ws.WebServiceException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import compbio.data.msa.Category;
+import compbio.data.msa.JABAService;
import compbio.metadata.Argument;
import compbio.metadata.WrongParameterException;
+import compbio.ws.client.Jws2Client;
+import compbio.ws.client.Services;
public class JpredJabaStructExportImport
{
- public static String testseqs = "examples/uniref50.fa";
- public static Jws2Discoverer disc;
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
- public static Jws2Instance jpredws;
+ private static String testseqs = "examples/uniref50.fa";
- jalview.ws.jws2.JPred301Client jpredClient;
+ private static Jws2Instance jpredws;
- public static jalview.gui.AlignFrame af = null;
+ private static AlignFrame af = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception
+ @BeforeClass(alwaysRun = true)
+ public static void setUpBeforeClass() throws ConnectException,
+ WebServiceException
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
+ Boolean.TRUE.toString());
+ Cache.applicationProperties.setProperty("SHOW_QUALITY",
+ Boolean.FALSE.toString());
+ Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
+ Boolean.FALSE.toString());
+ Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+ Boolean.FALSE.toString());
+ Cache.initLogger();
+ getJabaws();
+
+ FileLoader fl = new FileLoader(false);
+ af = fl.LoadFileWaitTillLoaded(testseqs, DataSourceType.FILE);
+ assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
+ }
- jalview.bin.Cache.initLogger();
- disc = JalviewJabawsTestUtils.getJabawsDiscoverer(false);
-
- for (Jws2Instance svc : disc.getServices())
+ /**
+ * @throws WebServiceException
+ * @throws ConnectException
+ *
+ */
+ static void getJabaws() throws ConnectException, WebServiceException
+ {
+ String jabaws = "http://www.compbio.dundee.ac.uk/jabaws";
+ JABAService service = null;
+ for (Category category : Category.getCategories())
{
-
- if (svc.getServiceTypeURI().toLowerCase().contains("jpred"))
+ for (Services srv : category.getServices())
{
- jpredws = svc;
+ if ("JpredWS".equals(srv.name()))
+ {
+ service = Jws2Client.connect(jabaws, srv);
+ }
}
}
-
- System.out.println("State of jpredws: " + jpredws);
-
- if (jpredws == null)
- System.exit(0);
-
- jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
-
- af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
-
- assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
-
+ jpredws = new Jws2Instance(jabaws, "JpredWs",
+ "Secondary Structure Prediction",
+ "SERVICE: JpredWS version 3.0.3", service);
+ Assert.assertNotNull(jpredws, "jpredws is null!");
}
- @AfterClass
+ @AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
if (af != null)
}
}
- @Test
+ @Test(groups = { "Network" })
public void testJPredStructOneSeqOnly()
{
af.selectAllSequenceMenuItem_actionPerformed(null);
af.getViewport().getSelectionGroup().getSequenceAt(0),
false);
af.hideSelSequences_actionPerformed(null);
- jpredClient = new JPred301Client(jpredws, af, null, null);
+ JPred301Client jpredClient = new JPred301Client(jpredws, af, null, null);
assertTrue(
"Didn't find any default args to check for. Buggy implementation of hardwired arguments in client.",
if (!success)
{
jpredClient.cancelCurrentJob();
- fail("Jpred Client didn't run with hardwired default parameters.");
+ Assert.fail("Jpred Client didn't run with hardwired default parameters.");
}
} catch (InterruptedException x)
}
- @Test
- public void testJPredStructExport()
+ /*
+ * test disabled pending completion of JAL-1601
+ * (JPred301Client is currently hidden in Jalview in
+ *
+ */
+ @Test(groups = { "Network" })
+ public void testJPredStructExport() throws InterruptedException
{
- jpredClient = new JPred301Client(jpredws, af, null, null);
+ JPred301Client jpredClient = new JPred301Client(jpredws, af, null, null);
af.getViewport().getCalcManager().startWorker(jpredClient);
;
} while (af.getViewport().getCalcManager().isWorking());
+ synchronized (this)
+ {
+ wait(2000);
+ }
AlignmentI orig_alig = af.getViewport().getAlignment();
-
- testAnnotationFileIO("Testing JPredWS Annotation IO", orig_alig);
+ System.out.println("Alignment now has "
+ + orig_alig.getAlignmentAnnotation().length + " annotations");
+ verifyAnnotationFileIO("Testing JPredWS Annotation IO", orig_alig);
}
- public static void testAnnotationFileIO(String testname, AlignmentI al)
+ protected static void verifyAnnotationFileIO(String testname,
+ AlignmentI al)
{
try
{
// what format would be appropriate for RNAalifold annotations?
- String aligfileout = new FormatAdapter().formatSequences("PFAM",
- al.getSequencesArray());
+ String aligfileout = FileFormat.Fasta.getWriter(null).print(
+ al.getSequencesArray(), true);
- String anfileout = new AnnotationFile().printAnnotations(
- al.getAlignmentAnnotation(), al.getGroups(),
- al.getProperties());
+ String anfileout = new AnnotationFile()
+ .printAnnotationsForAlignment(al);
assertTrue(
"Test "
+ testname
// again what format would be appropriate?
AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
- FormatAdapter.PASTE, "PFAM");
+ DataSourceType.PASTE, FileFormat.Fasta);
assertTrue(
"Test "
+ testname
+ "\nregenerated annotation file did not annotate alignment.",
new AnnotationFile().readAnnotationFile(al_new, anfileout,
- FormatAdapter.PASTE));
+ DataSourceType.PASTE));
// test for consistency in io
- StockholmFileTest.testAlignmentEquivalence(al, al_new);
+ StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
return;
} catch (Exception e)
{
e.printStackTrace();
+ Assert.fail("Test "
+ + testname
+ + "\nCouldn't complete Annotation file roundtrip input/output/input test.");
}
- fail("Test "
- + testname
- + "\nCouldn't complete Annotation file roundtrip input/output/input test.");
}
- // @Test
+ @Test(groups = { "Network" }, enabled = false)
public void testJpredwsSettingsRecovery()
{
- fail("not implemnented");
+ Assert.fail("not implemented");
List<compbio.metadata.Argument> opts = new ArrayList<compbio.metadata.Argument>();
for (compbio.metadata.Argument rg : (List<compbio.metadata.Argument>) jpredws
.getRunnerConfig().getArguments())
rg.setValue("292");
} catch (WrongParameterException q)
{
- fail("Couldn't set the temperature parameter "
+ Assert.fail("Couldn't set the temperature parameter "
+ q.getStackTrace());
}
opts.add(rg);
opts.add(rg);
}
}
- jpredClient = new JPred301Client(jpredws, af, null, opts);
+ JPred301Client jpredClient = new JPred301Client(jpredws, af, null, opts);
af.getViewport().getCalcManager().startWorker(jpredClient);
// write out parameters
jalview.gui.AlignFrame nalf = null;
assertTrue("Couldn't write out the Jar file",
- new Jalview2XML(false).SaveAlignment(af,
+ new Jalview2XML(false).saveAlignment(af,
"testJPredWS_param.jar", "trial parameter writeout"));
assertTrue("Couldn't read back the Jar file", (nalf = new Jalview2XML(
- false).LoadJalviewAlign("testJpredWS_param.jar")) != null);
+ false).loadJalviewAlign("testJpredWS_param.jar")) != null);
if (nalf != null)
{
AutoCalcSetting acs = af.getViewport().getCalcIdSettingsFor(