import jalview.datamodel.AlignmentI;
import jalview.gui.AlignFrame;
import jalview.gui.JvOptionPane;
-import jalview.io.AnnotationFile;
-import jalview.io.DataSourceType;
-import jalview.io.FileFormat;
-import jalview.io.FormatAdapter;
-import jalview.io.StockholmFileTest;
import jalview.ws.api.ServiceWithParameters;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.SeqAnnotationServiceCalcWorker;
+import jalview.ws.slivkaws.SlivkaWSDiscoverer;
import java.util.ArrayList;
import java.util.List;
-import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/*
* if there is no network.
*/
@Test(singleThreaded = true)
-public class DisorderAnnotExportImport
+public class AAConAnnotAndSettingsIO
{
@BeforeClass(alwaysRun = true)
public static Jws2Discoverer disc;
- public static List<ServiceWithParameters> aacon;
+ public static List<ServiceWithParameters[]> aacon;
jalview.ws.jws2.SeqAnnotationServiceCalcWorker aaconClient;
Thread.sleep(100);
}
+
aacon = new ArrayList<>();
for (ServiceWithParameters svc : disc.getServices())
{
if (svc.getNameURI().toLowerCase().contains("aacon"))
{
- aacon.add(svc);
+ aacon.add(new ServiceWithParameters[] { svc });
+ }
+ }
+
+ for (ServiceWithParameters svc : SlivkaWSDiscoverer.getServices())
+ {
+ if (svc.getNameURI().toLowerCase().contains("aacon"))
+ {
+ aacon.add(new ServiceWithParameters[] { svc });
}
}
assertTrue("Couldn't discover any AACon services to use to test.",
aacon.size() > 0);
- jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
- af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.DataSourceType.FILE);
- assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
}
@AfterClass(alwaysRun = true)
}
}
+ @DataProvider(name = "aacons")
+ public Object[][] getAaconArray()
+ {
+
+ Object[][] rtn = new Object[aacon.size()][1];
+ int i = 0;
+ for (ServiceWithParameters[] aa : aacon)
+ {
+ rtn[i++] = aa;
+ }
+ return rtn;
+ }
/**
* Run AACon on an alignment with defaults and verify Just Shenkin annotation
* appears
*/
- @Test(groups = { "External", "Network" })
- public void testAAConAnnotAndRecovery()
+ @Test(groups = { "External", "Network" }, dataProvider = "aacons")
+ public void testAAConAnnotAndRecovery(ServiceWithParameters service)
{
- testAAConClient(af, aacon.get(0));
+ jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
+ AlignFrame _af = fl.LoadFileWaitTillLoaded(testseqs,
+ jalview.io.DataSourceType.FILE);
+ assertNotNull("Couldn't load test data ('" + testseqs + "')", _af);
+ af = _af;
+ try
+ {
+ testAAConClient(_af, service);
+ } finally
+ {
+ af = null;
+ _af.setVisible(false);
+ _af.dispose();
+ _af = null;
+
+ }
}
+ /**
+ * triggers the given aacon worker on the alignment, waits for 5s and gives up
+ * or verifies SHENKIN annotation is produced.
+ *
+ * @param af
+ * - test data in an alignment frame
+ * @param aacon
+ * - the service to test
+ */
static void testAAConClient(AlignFrame af, ServiceWithParameters aacon)
{
SeqAnnotationServiceCalcWorker aaconClient = new SeqAnnotationServiceCalcWorker(
aacon, af, null,
null);
+ long current = System.currentTimeMillis(), limit = 5;
af.getViewport().getCalcManager().startWorker(aaconClient);
do
{
{
}
;
+ assertTrue(
+ "Waited " + limit + "s for " + aacon.getHostURL()
+ + " - giving up.",
+ (System.currentTimeMillis() - current) < limit * 1000);
} while (af.getViewport().getCalcManager().isWorking());
AlignmentI orig_alig = af.getViewport().getAlignment();
boolean foundShenkin = false;
}
assertTrue("Failed to locate 'SHENKIN' annotation row.", foundShenkin);
}
-
- static void checkAnnotationFileIO(String testname, AlignmentI al)
- {
- try
- {
- String aligfileout = FileFormat.Pfam.getWriter(al).print(
- al.getSequencesArray(), true);
- String anfileout = new AnnotationFile()
- .printAnnotationsForAlignment(al);
- assertTrue(
- "Test "
- + testname
- + "\nAlignment annotation file was not regenerated. Null string",
- anfileout != null);
- assertTrue(
- "Test "
- + testname
- + "\nAlignment annotation file was not regenerated. Empty string",
- anfileout.length() > "JALVIEW_ANNOTATION".length());
-
- System.out.println("Output annotation file:\n" + anfileout
- + "\n<<EOF\n");
-
- AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
- DataSourceType.PASTE, FileFormat.Pfam);
- assertTrue(
- "Test "
- + testname
- + "\nregenerated annotation file did not annotate alignment.",
- new AnnotationFile().readAnnotationFile(al_new, anfileout,
- DataSourceType.PASTE));
-
- // test for consistency in io
- StockholmFileTest.testAlignmentEquivalence(al, al_new, true, false,
- false);
- return;
- } catch (Exception e)
- {
- e.printStackTrace();
- }
- Assert.fail("Test "
- + testname
- + "\nCouldn't complete Annotation file roundtrip input/output/input test.");
- }
-
}