client - 1 week\r
docs - 1 week\r
\r
+make sure that aacon checks its input (must be alignment) and log errors/throws\r
+exceptions if the input is not correct or absent! \r
+\r
Cluster stats: \r
+cancelled should not be reported as incomplete!\r
-Remove hyperlinks from tasks which workdirs were removed \r
<?xml version="1.0" encoding="UTF-8"?>\r
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>\r
<endpoint\r
+ name='RegistryWS'\r
+ implementation='compbio.ws.server.RegistryWS'\r
+ url-pattern='/RegistryWS'/>\r
+ <endpoint\r
name='ClustalWS'\r
implementation='compbio.ws.server.ClustalWS'\r
url-pattern='/ClustalWS'/>\r
</servlet>\r
\r
<servlet>\r
+ <servlet-name>RegistryWS</servlet-name>\r
+ <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>\r
+ <load-on-startup>1</load-on-startup>\r
+ </servlet>\r
+ \r
+ <servlet>\r
<servlet-name>ClustalWS</servlet-name>\r
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>\r
<load-on-startup>1</load-on-startup>\r
</servlet-mapping> \r
\r
<servlet-mapping>\r
+ <servlet-name>RegistryWS</servlet-name>\r
+ <url-pattern>/RegistryWS</url-pattern>\r
+ </servlet-mapping>\r
+ \r
+ <servlet-mapping>\r
<servlet-name>ClustalWS</servlet-name>\r
<url-pattern>/ClustalWS</url-pattern>\r
</servlet-mapping>\r
probcons.cluster.settings=-l h_cpu=24:00:00 -l h_vmem=6000M -l ram=6000M\r
\r
### Jronn configuration ### \r
-local.jronn.bin.windows=D:\\Java\\jdk1.6.0_14\\bin\\java.exe \r
+local.jronn.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
local.jronn.bin=/sw/java/latest/bin/java\r
cluster.jronn.bin=/sw/java/latest/bin/java\r
jronn.jar.file=binaries/jronn3.1.jar\r
\r
\r
### AACon configuration ###\r
-local.aacon.bin.windows=D:\\Java\\jdk1.6.0_14\\bin\\java.exe \r
+local.aacon.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
local.aacon.bin=/sw/java/latest/bin/java\r
cluster.aacon.bin=/sw/java/latest/bin/java\r
aacon.jar.file=binaries/aaconservation.jar\r
// Cache for Limits information\r
private LimitsManager<T> limits;\r
\r
- protected String inputFile = "input.txt";\r
- protected String outputFile = "output.txt";\r
- protected String errorFile = "error.txt";\r
+ public static final String INPUT = "input.txt";\r
+ public static final String OUTPUT = "result.txt";\r
+ public static final String ERROR = "error.txt";\r
+\r
+ protected String inputFile = INPUT;\r
+ protected String outputFile = OUTPUT;\r
+ protected String errorFile = ERROR;\r
\r
private boolean isInputSet = false;\r
private boolean isOutputSet = false;\r
--- /dev/null
+package compbio.ws.client;\r
+\r
+import static org.testng.Assert.assertTrue;\r
+\r
+import java.io.PrintWriter;\r
+\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.metadata.AllTestSuit;\r
+\r
+public class WSTesterTester {\r
+\r
+ public static final String SERVER = "http://localhost:8080/jabaws";\r
+\r
+ @Test(groups = {AllTestSuit.test_group_runner})\r
+ public void testAllWindowsWS() {\r
+ WSTester tester = new WSTester(new PrintWriter(System.out, true));\r
+ JABAService ws = Jws2Client.connect(SERVER, Services.AAConWS);\r
+ assertTrue(tester.checkService(ws));\r
+\r
+ ws = Jws2Client.connect(SERVER, Services.JronnWS);\r
+ assertTrue(tester.checkService(ws));\r
+\r
+ ws = Jws2Client.connect(SERVER, Services.ClustalWS);\r
+ assertTrue(tester.checkService(ws));\r
+\r
+ ws = Jws2Client.connect(SERVER, Services.MuscleWS);\r
+ assertTrue(tester.checkService(ws));\r
+\r
+ // Will throw UnsupportedRuntimeException on windows\r
+ // ws = Jws2Client.connect(SERVER, Services.MafftWS);\r
+ // assertTrue(tester.checkService(ws));\r
+\r
+ }\r
+\r
+ @Test(groups = {AllTestSuit.test_group_non_windows})\r
+ public void testAllWS() {\r
+ WSTester tester = new WSTester(new PrintWriter(System.out));\r
+\r
+ for (Services service : Services.values()) {\r
+ JABAService ws = Jws2Client.connect(SERVER, service);\r
+ assertTrue(tester.checkService(ws));\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package compbio.ws.server;\r
+\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.ws.client.Jws2Client;\r
+import compbio.ws.client.Services;\r
+import compbio.ws.client.WSTesterTester;\r
+\r
+public class RegistryWSTester {\r
+\r
+ @Test\r
+ public void testGetSupportedServices() {\r
+ compbio.data.msa.RegistryWS reg = Jws2Client\r
+ .connectToRegistry(WSTesterTester.SERVER);\r
+ System.out.println(reg.getSupportedServices());\r
+ }\r
+\r
+ @Test\r
+ public void testTestService() {\r
+ compbio.data.msa.RegistryWS reg = Jws2Client\r
+ .connectToRegistry(WSTesterTester.SERVER);\r
+ System.out.println(reg.testService(Services.AAConWS));\r
+ }\r
+\r
+}\r
--- /dev/null
+package compbio.data.msa;\r
+\r
+import java.util.Date;\r
+import java.util.Set;\r
+\r
+import javax.jws.WebService;\r
+\r
+import compbio.ws.client.Services;\r
+\r
+@WebService(targetNamespace = "http://msa.data.compbio/01/12/2010/")\r
+public interface RegistryWS extends JABAService {\r
+ Set<Services> getSupportedServices();\r
+ Date getLastTestedOn(Services service);\r
+ String testAllServices();\r
+ String testService(Services service);\r
+ boolean isOperating(Services service);\r
+\r
+}\r
import java.util.logging.Level;\r
import java.util.logging.Logger;\r
\r
+import javax.xml.namespace.QName;\r
import javax.xml.ws.Service;\r
import javax.xml.ws.WebServiceException;\r
\r
public class Jws2Client {\r
\r
/*\r
- * Use java.util.Logger instead of log4j logger to reduce the size of the\r
- * client package\r
+ * TODO Use java.util.Logger instead of log4j logger to reduce the size of\r
+ * the client package\r
*/\r
private static final Logger log = Logger.getLogger(Jws2Client.class\r
.getCanonicalName());\r
* @return Set<Score> the conservation scores\r
* @throws UnknownFileFormatException\r
*/\r
- <T> ScoreManager analize(File file, SequenceAnnotation<T> wsproxy,\r
- Preset<T> preset, List<Option<T>> customOptions) {\r
+ static <T> ScoreManager analize(List<FastaSequence> fastalist,\r
+ SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
+ List<Option<T>> customOptions) {\r
\r
- List<FastaSequence> fastalist = null;\r
ScoreManager scores = null;\r
try {\r
- fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
- assert !fastalist.isEmpty() : "Input is empty!";\r
-\r
String jobId = null;\r
if (customOptions != null && preset != null) {\r
System.out\r
} else if (preset != null) {\r
jobId = wsproxy.presetAnalize(fastalist, preset);\r
} else {\r
- System.out.println("\n\ncalling analise.........");\r
jobId = wsproxy.analize(fastalist);\r
}\r
- Thread.sleep(2000);\r
-\r
+ System.out.println("\n\ncalling analise.........");\r
+ Thread.sleep(1000);\r
scores = wsproxy.getAnnotation(jobId);\r
\r
- } catch (IOException e) {\r
- System.err\r
- .println("Exception while reading the input file. "\r
- + "Check that the input file contains a list of fasta formatted sequences! "\r
- + "Exception details are below:");\r
- e.printStackTrace();\r
} catch (JobSubmissionException e) {\r
System.err\r
.println("Exception while submitting job to a web server. "\r
System.err.println("Exception while waiting for results. "\r
+ "Exception details are below:");\r
e.printStackTrace();\r
- } catch (InterruptedException ignored) {\r
+ } catch (InterruptedException e) {\r
// ignore and propagate an interruption\r
Thread.currentThread().interrupt();\r
+ System.err.println("Exception while waiting for results. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
} catch (WrongParameterException e) {\r
System.err\r
.println("Exception while parsing the web method input parameters. "\r
+ "Exception details are below:");\r
e.printStackTrace();\r
+ }\r
+ return scores;\r
+\r
+ }\r
+\r
+ /**\r
+ * Calculate conservation for sequences loaded from the file\r
+ * \r
+ * @param wsproxy\r
+ * a web service proxy\r
+ * @param file\r
+ * the file to read the results from\r
+ * @param preset\r
+ * Preset to use optional\r
+ * @param customOptions\r
+ * the list of options\r
+ * @return Set<Score> the conservation scores\r
+ * @throws IOException\r
+ * @throws UnknownFileFormatException\r
+ */\r
+ static <T> ScoreManager analize(File file, SequenceAnnotation<T> wsproxy,\r
+ Preset<T> preset, List<Option<T>> customOptions) {\r
+ List<FastaSequence> fastalist = null;\r
+ try {\r
+ fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
+ assert !fastalist.isEmpty() : "Input is empty!";\r
+ } catch (IOException e) {\r
+ System.err\r
+ .println("Exception while reading the input file. "\r
+ + "Check that the input file contains a list of fasta formatted sequences! "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
} catch (UnknownFileFormatException e) {\r
System.err\r
.println("Exception while attempting to read the input file "\r
System.out.println(e.getMessage());\r
e.printStackTrace();\r
}\r
- return scores;\r
+ return analize(fastalist, wsproxy, preset, customOptions);\r
}\r
-\r
/**\r
* Connects to a web service by the host and the service name\r
* \r
try {\r
serv = service.getService(url, QUALIFIED_SERVICE_NAME);\r
} catch (WebServiceException wse) {\r
- System.out.println("Conecting to JABAWS version 2 service");\r
+ System.out.println("Connecting to JABAWS version 2 service");\r
if (isV2service(wse)) {\r
serv = service.getService(url, V2_QUALIFIED_SERVICE_NAME);\r
}\r
return false;\r
}\r
\r
+ public static compbio.data.msa.RegistryWS connectToRegistry(String host)\r
+ throws WebServiceException {\r
+ URL url = null;\r
+ String service = "RegistryWS";\r
+ log.log(Level.FINE, "Attempting to connect...");\r
+\r
+ try {\r
+ url = new URL(host + "/" + service + "?wsdl");\r
+ } catch (MalformedURLException e) {\r
+ e.printStackTrace();\r
+ // ignore as the host name is already verified\r
+ }\r
+ QName qname = new QName(V2_QUALIFIED_SERVICE_NAME, service);\r
+ Service serv = Service.create(url, qname);\r
+\r
+ if (serv == null) {\r
+ System.err.println("Could not connect to " + url\r
+ + " the server is down?");\r
+ }\r
+\r
+ QName portName = new QName(serv.getServiceName().getNamespaceURI(),\r
+ service + "Port");\r
+ compbio.data.msa.RegistryWS serviceIF = serv.getPort(portName,\r
+ compbio.data.msa.RegistryWS.class);\r
+\r
+ log.log(Level.INFO, "Connected to " + service + " successfully!");\r
+\r
+ return serviceIF;\r
+ }\r
+\r
/**\r
* Align sequences from the file using MsaWS\r
* \r
} else {\r
jobId = msaws.align(fastalist);\r
}\r
+ System.out.println("\n\ncalling align.........");\r
Thread.sleep(1000);\r
alignment = msaws.getResult(jobId);\r
\r
}\r
}\r
\r
- public static Class<? extends Executable<?>> getRunnerByJobDirectory(File jobdir) {\r
+ public static Class<? extends Executable<?>> getRunnerByJobDirectory(\r
+ File jobdir) {\r
Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));\r
return service.getServiceImpl();\r
}\r
import java.io.ByteArrayInputStream;\r
import java.io.Closeable;\r
import java.io.IOException;\r
+import java.io.PrintWriter;\r
import java.util.Arrays;\r
import java.util.List;\r
\r
import javax.xml.ws.WebServiceException;\r
\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.data.msa.Metadata;\r
import compbio.data.msa.MsaWS;\r
+import compbio.data.msa.SequenceAnnotation;\r
import compbio.data.sequence.Alignment;\r
import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.ScoreManager;\r
import compbio.data.sequence.SequenceUtil;\r
import compbio.metadata.JobStatus;\r
import compbio.metadata.JobSubmissionException;\r
import compbio.metadata.Limit;\r
import compbio.metadata.LimitsManager;\r
+import compbio.metadata.Option;\r
import compbio.metadata.Preset;\r
import compbio.metadata.PresetManager;\r
import compbio.metadata.ResultNotAvailableException;\r
*/\r
public class WSTester {\r
\r
+ private static Logger log = Logger.getLogger(WSTester.class);\r
/**\r
* Sequences to be used as input for all WS\r
*/\r
- static final String fastaInput = ">Foobar\n"\r
- + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKA"\r
- + "\n>Barbar\n"\r
- + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI"\r
- + "\n>Foofriend\n"\r
- + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI\n";\r
+ static final String fastaInput = ">Foo\n"\r
+ + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV"\r
+ + "\n>Bar\n"\r
+ + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVA";\r
+\r
+ static final String fastaAlignment = ">Foo\r\n"\r
+ + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV--------\r\n"\r
+ + ">Bar\r\n"\r
+ + "ASDAAPEH------------PGIALWLHALE-DAGQAEAAA---AYTRAHQLLPEEPYITAQLLNAVA\r\n"\r
+ + "";\r
\r
static final List<FastaSequence> seqs = loadSeqs();\r
\r
private static final String FAILED = "FAILED";\r
private static final String OK = "OK";\r
\r
+ private static final String UNSUPPORTED = "UNSUPPORTED";\r
+\r
/**\r
* Converting input to a form accepted by WS\r
* \r
}\r
\r
/**\r
+ * Converting input to a form accepted by WS\r
+ * \r
+ * @return List of FastaSequence records\r
+ */\r
+ static List<FastaSequence> loadAlignment() {\r
+ try {\r
+ return SequenceUtil.readFasta(new ByteArrayInputStream(\r
+ fastaAlignment.getBytes()));\r
+ } catch (IOException ignored) {\r
+ // Should not happen as a source is not a external stream\r
+ ignored.printStackTrace();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ private final PrintWriter writer;\r
+\r
+ public WSTester(PrintWriter writer) {\r
+ this.writer = writer;\r
+ }\r
+\r
+ /**\r
* Prints usage\r
*/\r
- static void printUsage() {\r
- System.out.println("Usage: <Class or Jar file name> " + hostkey\r
+ void printUsage() {\r
+ writer.println("Usage: <Class or Jar file name> " + hostkey\r
+ pseparator + "host_and_context " + "<" + servicekey\r
+ pseparator + "serviceName>");\r
- System.out.println();\r
- System.out\r
- .println(hostkey\r
- + pseparator\r
- + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
- System.out\r
- .println(servicekey\r
- + pseparator\r
- + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
- + Arrays.toString(Services.values()));\r
- System.out.println();\r
+ writer.println();\r
+ writer.println(hostkey\r
+ + pseparator\r
+ + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
+ writer.println(servicekey\r
+ + pseparator\r
+ + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
+ + Arrays.toString(Services.values()));\r
+ writer.println();\r
\r
}\r
\r
* list of the Preset\r
* @throws UnsupportedRuntimeException\r
*/\r
- static <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
+ <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
throws UnsupportedRuntimeException {\r
boolean succeed = false;\r
for (Preset<T> preset : presets) {\r
- System.out.print("Aligning with preset '" + preset.getName()\r
- + "'... ");\r
+ writer.print("Aligning with preset '" + preset.getName() + "'... ");\r
Alignment al = null;\r
try {\r
String taskId = msaws.presetAlign(seqs, preset);\r
al = msaws.getResult(taskId);\r
if (al != null) {\r
- System.out.println(OK);\r
+ writer.println(OK);\r
}\r
succeed = true;\r
} catch (UnsupportedRuntimeException e) {\r
- System.out.println(FAILED);\r
+ writer.println(FAILED);\r
// If executable is not supported than none of the presets are\r
// going to work\r
throw new UnsupportedRuntimeException(e);\r
} catch (JobSubmissionException e) {\r
// TODO custom message\r
- System.out.println(FAILED);\r
- System.out.println();\r
- e.printStackTrace();\r
+ writer.println(FAILED);\r
+ writer.println();\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
continue;\r
} catch (WrongParameterException e) {\r
// TODO custom message\r
- System.out.println(FAILED);\r
- System.out.println();\r
- e.printStackTrace();\r
+ writer.println(FAILED);\r
+ writer.println();\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
continue;\r
} catch (ResultNotAvailableException e) {\r
// TODO custom message\r
- System.out.println(FAILED);\r
- System.out.println();\r
- e.printStackTrace();\r
+ writer.println(FAILED);\r
+ writer.println();\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
continue;\r
}\r
}\r
return succeed;\r
}\r
\r
+ private <T> boolean testMsaWS(MsaWS<T> msaws)\r
+ throws UnsupportedRuntimeException {\r
+\r
+ boolean succeed = testDefaultAlignment(msaws);\r
+\r
+ // If exception above is thrown than the tests below is not run\r
+\r
+ PresetManager<T> pmanager = msaws.getPresets();\r
+ if (pmanager != null && pmanager.getPresets().size() > 0) {\r
+ writer.println("Testing alignment with presets:");\r
+ List<Preset<T>> plist = pmanager.getPresets();\r
+ succeed = !succeed ? presetAlign(msaws, plist) : succeed;\r
+ }\r
+ testMetadata(msaws);\r
+ return succeed;\r
+ }\r
/**\r
* Call most of web services functions and check the output\r
* \r
* the web service is not functional. e.g. when native\r
* executable does not exists for a server platform\r
*/\r
- static <T> boolean checkService(MsaWS<T> msaws)\r
+ @SuppressWarnings("unchecked")\r
+ public <T> boolean checkService(JABAService wservice) {\r
+ try {\r
+ if (wservice == null) {\r
+ throw new NullPointerException(\r
+ "JABAService instance must be provided!");\r
+ }\r
+ if (wservice instanceof MsaWS) {\r
+ return testMsaWS((MsaWS<T>) wservice);\r
+ } else if (wservice instanceof SequenceAnnotation) {\r
+ return testSequenceAnnotationWS((SequenceAnnotation<T>) wservice);\r
+ } else {\r
+ throw new UnsupportedOperationException("The service: "\r
+ + wservice.getClass() + " is not supported! ");\r
+ }\r
+ } catch (UnsupportedRuntimeException e) {\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
+ return false;\r
+ }\r
+ }\r
+\r
+ private <T> boolean testSequenceAnnotationWS(SequenceAnnotation<T> wservice)\r
throws UnsupportedRuntimeException {\r
+ boolean success = testDefaultAnalyse(loadAlignment(), wservice, null,\r
+ null);\r
+ PresetManager<T> presetman = wservice.getPresets();\r
+ if (presetman != null) {\r
+ List<Preset<T>> presets = presetman.getPresets();\r
+ if (presets != null && !presets.isEmpty()) {\r
+ Preset<T> preset = presets.get(0);\r
+ success = testDefaultAnalyse(loadAlignment(), wservice, preset,\r
+ null);\r
+ }\r
+ }\r
+ testMetadata(wservice);\r
+ return success;\r
+ }\r
\r
- boolean succeed = testDefaultAlignment(msaws);\r
+ <T> boolean testDefaultAnalyse(List<FastaSequence> fastalist,\r
+ SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
+ List<Option<T>> customOptions) throws UnsupportedRuntimeException {\r
\r
- // If exception above is thrown than the tests below is not run\r
+ ScoreManager scores = null;\r
+ try {\r
+ String jobId = null;\r
+ if (customOptions != null) {\r
+ jobId = wsproxy.customAnalize(fastalist, customOptions);\r
+ } else if (preset != null) {\r
+ jobId = wsproxy.presetAnalize(fastalist, preset);\r
+ } else {\r
+ jobId = wsproxy.analize(fastalist);\r
+ }\r
+ writer.println("\n\ncalling analise.........");\r
+ Thread.sleep(1000);\r
+ scores = wsproxy.getAnnotation(jobId);\r
\r
- PresetManager<T> pmanager = msaws.getPresets();\r
- if (pmanager != null && pmanager.getPresets().size() > 0) {\r
- System.out.println("Testing alignment with presets:");\r
- List<Preset<T>> plist = pmanager.getPresets();\r
- succeed = !succeed ? presetAlign(msaws, plist) : succeed;\r
+ } catch (JobSubmissionException e) {\r
+ writer.println("Exception while submitting job to a web server. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace(writer);\r
+ } catch (ResultNotAvailableException e) {\r
+ writer.println("Exception while waiting for results. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace(writer);\r
+ } catch (InterruptedException e) {\r
+ // ignore and propagate an interruption\r
+ Thread.currentThread().interrupt();\r
+ writer.println("Exception while waiting for results. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace(writer);\r
+ } catch (WrongParameterException e) {\r
+ writer.println("Exception while parsing the web method input parameters. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace(writer);\r
}\r
+ return scores != null;\r
+ }\r
\r
- System.out.print("Querying presets...");\r
+ private <T> void testMetadata(Metadata<T> msaws)\r
+ throws UnsupportedRuntimeException {\r
\r
+ writer.print("Querying presets...");\r
+ PresetManager<T> pmanager = msaws.getPresets();\r
if (pmanager != null && pmanager.getPresets().size() > 0) {\r
- System.out.println(OK);\r
+ writer.println(OK);\r
} else {\r
- System.out.println("UNSUPPORTED");\r
+ writer.println(UNSUPPORTED);\r
}\r
\r
- System.out.print("Querying Parameters...");\r
+ writer.print("Querying Parameters...");\r
RunnerConfig<T> options = msaws.getRunnerOptions();\r
if (options != null && options.getArguments().size() > 0) {\r
- System.out.println(OK);\r
+ writer.println(OK);\r
} else {\r
- System.out.println(FAILED);\r
- succeed = false;\r
+ writer.println(UNSUPPORTED);\r
}\r
\r
- System.out.print("Querying Limits...");\r
+ writer.print("Querying Limits...");\r
LimitsManager<T> limits = msaws.getLimits();\r
if (limits != null && limits.getLimits().size() > 0) {\r
- System.out.println(OK);\r
+ writer.println(OK);\r
} else {\r
- System.out.println("UNSUPPORTED");\r
+ writer.println(UNSUPPORTED);\r
}\r
\r
- System.out.print("Querying Local Engine Limits...");\r
+ writer.print("Querying Local Engine Limits...");\r
Limit<T> localLimit = msaws\r
.getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET);\r
if (localLimit != null) {\r
- System.out.println(OK);\r
+ writer.println(OK);\r
} else {\r
- System.out.println("UNSUPPORTED");\r
+ writer.println(UNSUPPORTED);\r
}\r
- return succeed;\r
}\r
\r
/**\r
* @param msaws\r
* @throws UnsupportedRuntimeException\r
*/\r
- static <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
+ public <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
throws UnsupportedRuntimeException {\r
- System.out.print("Testing alignment with default parameters:");\r
+ writer.print("Testing alignment with default parameters:");\r
Alignment al = null;\r
boolean succeed = false;\r
try {\r
String taskId = msaws.align(seqs);\r
- System.out.print("\nQuerying job status...");\r
+ writer.print("\nQuerying job status...");\r
JobStatus status = msaws.getJobStatus(taskId);\r
while (status != JobStatus.FINISHED) {\r
Thread.sleep(1000);\r
status = msaws.getJobStatus(taskId);\r
}\r
- System.out.println(OK);\r
- System.out.print("Retrieving results...");\r
+ writer.println(OK);\r
+ writer.print("Retrieving results...");\r
al = msaws.getResult(taskId);\r
succeed = true;\r
} catch (ResultNotAvailableException e) {\r
- System.out.println(FAILED);\r
- e.printStackTrace();\r
+ writer.println(FAILED);\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
} catch (JobSubmissionException e) {\r
- System.out.println(FAILED);\r
- System.out.println();\r
- e.printStackTrace();\r
+ writer.println(FAILED);\r
+ writer.println();\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
} catch (InterruptedException e) {\r
- System.out.println(FAILED);\r
- System.out.println();\r
- e.printStackTrace();\r
+ writer.println(FAILED);\r
+ writer.println();\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
}\r
if (al != null) {\r
- System.out.println(OK);\r
+ writer.println(OK);\r
}\r
return succeed;\r
}\r
* @param service\r
* @return\r
*/\r
- static <T> MsaWS<T> connect(String host, Services service) {\r
- MsaWS<T> msaws = null;\r
+ <T> JABAService connect(String host, Services service) {\r
+ JABAService jabaservice = null;\r
try {\r
- System.out.print("Connecting to service " + service + " on " + host\r
+ writer.print("Connecting to service " + service + " on " + host\r
+ " ... ");\r
- msaws = (MsaWS<T>) Jws2Client.connect(host, service);\r
- System.out.println(OK);\r
+ jabaservice = Jws2Client.connect(host, service);\r
+ writer.println(OK);\r
} catch (WebServiceException e) {\r
- System.out.println(FAILED);\r
+ writer.println(FAILED);\r
+ writer.println(e.getLocalizedMessage());\r
+ e.printStackTrace(writer);\r
}\r
- return msaws;\r
+ return jabaservice;\r
}\r
\r
/**\r
* @throws IOException\r
*/\r
public static <T> void main(String[] args) throws IOException {\r
-\r
+ WSTester tester = new WSTester(new PrintWriter(System.out, true));\r
if (args == null || args.length < 1) {\r
- printUsage();\r
+ tester.printUsage();\r
System.exit(0);\r
}\r
String host = CmdHelper.getHost(args);\r
String serviceName = CmdHelper.getServiceName(args);\r
if (!Jws2Client.validURL(host)) {\r
- System.out\r
+ tester.writer\r
.println("<host_and_context> parameter is not provided or is incorrect!");\r
System.exit(1);\r
}\r
if (serviceName != null) {\r
Services service = Services.getService(serviceName);\r
if (service == null) {\r
- System.out.println("Service '" + serviceName\r
+ tester.writer.println("Service '" + serviceName\r
+ "' is not supported. Valid values are: "\r
+ Arrays.toString(Services.values()));\r
- System.out.println();\r
- printUsage();\r
+ tester.writer.println();\r
+ tester.printUsage();\r
System.exit(1);\r
}\r
\r
- msaws = connect(host, service);\r
+ msaws = (MsaWS<T>) tester.connect(host, service);\r
if (msaws == null) {\r
System.exit(1);\r
}\r
try {\r
- succeed = checkService(msaws);\r
- } catch (UnsupportedRuntimeException ignored) {\r
- System.exit(1);\r
+ succeed = tester.checkService(msaws);\r
} finally {\r
((Closeable) msaws).close();\r
}\r
- reportResults(service, succeed);\r
+ // TODO test results printing!\r
+ tester.reportResults(service, succeed);\r
System.exit(0);\r
}\r
\r
- System.out\r
+ tester.writer\r
.println("<ServiceName> is not provided checking all known services...");\r
\r
for (Services serv : Services.values()) {\r
- System.out.println();\r
- msaws = connect(host, serv);\r
+ tester.writer.println();\r
+ msaws = (MsaWS<T>) tester.connect(host, serv);\r
if (msaws == null) {\r
continue;\r
}\r
try {\r
- succeed = checkService(msaws);\r
- } catch (UnsupportedRuntimeException ignored) {\r
- System.out.println("Service " + serv + " IS NOT FUNCTIONAL");\r
- continue;\r
+ succeed = tester.checkService(msaws);\r
} finally {\r
((Closeable) msaws).close();\r
}\r
- reportResults(serv, succeed);\r
+ tester.reportResults(serv, succeed);\r
}\r
\r
}\r
-\r
- private static void reportResults(Services serv, boolean succeed) {\r
+ private void reportResults(Services serv, boolean succeed) {\r
if (succeed) {\r
- System.out.println("Check is completed. The Service " + serv\r
+ writer.println("Check is completed. The Service " + serv\r
+ " IS WORKING");\r
} else {\r
- System.out.println("Check is completed. The Service " + serv\r
+ writer.println("Check is completed. The Service " + serv\r
+ " HAS SOME PROBLEMS");\r
}\r
}\r
\r
import java.io.File;\r
import java.util.Arrays;\r
-import java.util.HashSet;\r
import java.util.List;\r
\r
import javax.annotation.Resource;\r
\r
import compbio.data.msa.SequenceAnnotation;\r
import compbio.data.sequence.FastaSequence;\r
-import compbio.data.sequence.Score;\r
import compbio.data.sequence.ScoreManager;\r
import compbio.engine.AsyncExecutor;\r
import compbio.engine.Configurator;\r
import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
import compbio.metadata.ChunkHolder;\r
import compbio.metadata.JobStatus;\r
import compbio.metadata.JobSubmissionException;\r
ConfiguredExecutable<AACon> init(List<FastaSequence> sequences)\r
throws JobSubmissionException {\r
AACon aacon = new AACon();\r
+ aacon.setInput(SkeletalExecutable.INPUT).setOutput(\r
+ SkeletalExecutable.OUTPUT);\r
return Configurator.configureExecutable(aacon, sequences);\r
}\r
\r
AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
ConfiguredExecutable<AACon> aacon = (ConfiguredExecutable<AACon>) asyncEngine\r
.getResults(jobId);\r
- HashSet<Score> mas = aacon.getResults();\r
- // ScoreManager result = new HashMap<String, HashSet<Score>>();\r
- // result.put("Alignment", mas);\r
+ ScoreManager mas = aacon.getResults();\r
log.trace(jobId + " getConservation : " + mas);\r
- // FIXME\r
- return null;\r
+ return mas;\r
}\r
/*\r
* @SuppressWarnings("unchecked") public JalviewAnnotation\r
import compbio.engine.AsyncExecutor;\r
import compbio.engine.Configurator;\r
import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
import compbio.metadata.ChunkHolder;\r
import compbio.metadata.JobStatus;\r
import compbio.metadata.JobSubmissionException;\r
ConfiguredExecutable<Disembl> init(List<FastaSequence> sequences)\r
throws JobSubmissionException {\r
Disembl disembl = new Disembl();\r
+ disembl.setInput(SkeletalExecutable.INPUT);\r
return Configurator.configureExecutable(disembl, sequences);\r
}\r
\r
import compbio.engine.AsyncExecutor;\r
import compbio.engine.Configurator;\r
import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
import compbio.metadata.ChunkHolder;\r
import compbio.metadata.JobStatus;\r
import compbio.metadata.JobSubmissionException;\r
ConfiguredExecutable<GlobPlot> init(List<FastaSequence> sequences)\r
throws JobSubmissionException {\r
GlobPlot globPlot = new GlobPlot();\r
+ globPlot.setInput(SkeletalExecutable.INPUT);\r
return Configurator.configureExecutable(globPlot, sequences);\r
}\r
-\r
@Override\r
public ScoreManager getAnnotation(String jobId)\r
throws ResultNotAvailableException {\r
import compbio.engine.AsyncExecutor;\r
import compbio.engine.Configurator;\r
import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
import compbio.metadata.ChunkHolder;\r
import compbio.metadata.JobStatus;\r
import compbio.metadata.JobSubmissionException;\r
ConfiguredExecutable<Jronn> init(List<FastaSequence> sequences)\r
throws JobSubmissionException {\r
Jronn jronn = new Jronn();\r
+ jronn.setInput(SkeletalExecutable.INPUT).setOutput(\r
+ SkeletalExecutable.OUTPUT);\r
return Configurator.configureExecutable(jronn, sequences);\r
}\r
\r
import compbio.engine.AsyncExecutor;\r
import compbio.engine.Configurator;\r
import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
import compbio.metadata.ChunkHolder;\r
import compbio.metadata.JobStatus;\r
import compbio.metadata.JobSubmissionException;\r
ConfiguredExecutable<Muscle> init(List<FastaSequence> sequences)\r
throws JobSubmissionException {\r
Muscle muscle = new Muscle();\r
+ muscle.setInput(SkeletalExecutable.INPUT)\r
+ .setOutput(SkeletalExecutable.OUTPUT)\r
+ .setError(SkeletalExecutable.ERROR);\r
return Configurator.configureExecutable(muscle, sequences);\r
}\r
\r
--- /dev/null
+package compbio.ws.server;\r
+\r
+import java.io.PrintWriter;\r
+import java.io.StringWriter;\r
+import java.io.Writer;\r
+import java.util.Date;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+\r
+import javax.annotation.Resource;\r
+import javax.jws.WebService;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.xml.ws.WebServiceContext;\r
+import javax.xml.ws.handler.MessageContext;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.ws.client.Jws2Client;\r
+import compbio.ws.client.Services;\r
+import compbio.ws.client.WSTester;\r
+\r
+/**\r
+ * TODO\r
+ * \r
+ * @author pvtroshin\r
+ * \r
+ */\r
+@WebService(endpointInterface = "compbio.data.msa.RegistryWS", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "RegistryWS")\r
+public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {\r
+\r
+ // Ask for resource injection\r
+ @Resource\r
+ WebServiceContext wsContext;\r
+\r
+ private static Logger statLog = Logger.getLogger("RegistryWS-stats");\r
+ private static Logger log = Logger.getLogger(RegistryWS.class);\r
+\r
+ private final static Map<Services, Date> operating = new ConcurrentHashMap<Services, Date>();\r
+\r
+ /**\r
+ * 1) Check that the actual executable is configured\r
+ * \r
+ * 2) Check whether the service is enabled?\r
+ * \r
+ * 3) Attempt to execute?\r
+ * \r
+ * @return\r
+ */\r
+ @Override\r
+ public Set<Services> getSupportedServices() {\r
+ init();\r
+ return operating.keySet();\r
+ }\r
+\r
+ private void init() {\r
+ // This can be run concurrently\r
+ if (operating.isEmpty()) {\r
+ testAllServices();\r
+ }\r
+ }\r
+ @Override\r
+ public Date getLastTestedOn(Services service) {\r
+ return operating.get(service);\r
+ }\r
+\r
+ @Override\r
+ public String testAllServices() {\r
+ Writer testlog = new StringWriter();\r
+ PrintWriter writer = new PrintWriter(testlog, true);\r
+ WSTester tester = new WSTester(writer);\r
+\r
+ for (Services service : Services.values()) {\r
+ JABAService ws = Jws2Client.connect(getServicePath(), service);\r
+ if (tester.checkService(ws)) {\r
+ operating.put(service, new Date());\r
+ }\r
+ }\r
+ return testlog.toString();\r
+ }\r
+\r
+ private String getServicePath() {\r
+ assert wsContext != null : "WS context injection failed!";\r
+ MessageContext msContext = wsContext.getMessageContext();\r
+ HttpServletRequest request = (HttpServletRequest) msContext\r
+ .get(MessageContext.SERVLET_REQUEST);\r
+\r
+ StringBuffer server = request.getRequestURL();\r
+ server = server.delete(server.lastIndexOf("/"), server.length());\r
+ return server.toString();\r
+ }\r
+\r
+ @Override\r
+ public String testService(Services service) {\r
+ String server = getServicePath();\r
+ Writer testlog = new StringWriter();\r
+ PrintWriter writer = new PrintWriter(testlog, true);\r
+ WSTester tester = new WSTester(writer);\r
+ writer.println("Attempting to connect to the service " + service\r
+ + " on the server " + server + "...");\r
+ JABAService ws = Jws2Client.connect(server, service);\r
+ writer.println("Connected successfully!");\r
+ try {\r
+ boolean succeed = tester.checkService(ws);\r
+ if (succeed) {\r
+ // TODO extract messages (see WSTester main)\r
+ writer.println("Check is completed. The Service "\r
+ + service.toString() + " IS WORKING");\r
+ operating.put(service, new Date());\r
+ } else {\r
+ writer.println("Check is completed. The Service "\r
+ + service.toString() + " HAS SOME PROBLEMS");\r
+ }\r
+ } finally {\r
+ writer.close();\r
+ }\r
+ return testlog.toString();\r
+ }\r
+ @Override\r
+ public boolean isOperating(Services service) {\r
+ init();\r
+ return operating.containsKey(service);\r
+ }\r
+\r
+}\r