1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.ws.client;
\r
21 import java.io.File;
\r
22 import java.net.URL;
\r
23 import java.util.Set;
\r
25 import javax.xml.namespace.QName;
\r
26 import javax.xml.ws.Service;
\r
28 import compbio.data.msa.JABAService;
\r
29 import compbio.data.msa.MsaWS;
\r
30 import compbio.data.msa.SequenceAnnotation;
\r
31 import compbio.engine.client.ConfExecutable;
\r
32 import compbio.engine.client.Executable;
\r
33 import compbio.runner.conservation.AACon;
\r
34 import compbio.runner.disorder.Disembl;
\r
35 import compbio.runner.disorder.GlobPlot;
\r
36 import compbio.runner.disorder.Jronn;
\r
37 import compbio.runner.msa.ClustalW;
\r
38 import compbio.runner.msa.Mafft;
\r
39 import compbio.runner.msa.Muscle;
\r
40 import compbio.runner.msa.Probcons;
\r
41 import compbio.runner.msa.Tcoffee;
\r
44 * List of web services currently supported by JABAWS version 2
\r
47 public enum Services {
\r
48 MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPred;
\r
50 public static Services getService(String servName) {
\r
51 servName = servName.trim().toLowerCase();
\r
52 for (Services service : Services.values()) {
\r
53 if (service.toString().equalsIgnoreCase(servName)) {
\r
60 public static Services getServiceByRunner(
\r
61 Class<Executable<?>> runnerClassName) {
\r
62 assert runnerClassName != null;
\r
63 String sname = runnerClassName.getSimpleName().toLowerCase();
\r
64 for (Services service : Services.values()) {
\r
65 if (service.toString().toLowerCase().contains(sname)) {
\r
72 public Class<? extends Executable<?>> getServiceImpl() {
\r
77 return ClustalW.class;
\r
81 return Muscle.class;
\r
83 return Tcoffee.class;
\r
85 return Probcons.class;
\r
87 return Disembl.class;
\r
89 return GlobPlot.class;
\r
93 throw new RuntimeException(
\r
94 "Unknown web service implementation class for service: "
\r
99 public static Class<? extends Executable<?>> getRunnerByJobDirectory(
\r
101 Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));
\r
102 return service.getServiceImpl();
\r
105 private static String getRunnerNameByJobDirectory(File jobdir) {
\r
106 String name = jobdir.getName().split("#")[0];
\r
108 if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) {
\r
109 assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1;
\r
110 name = name.substring(1);
\r
115 public static Services getServiceByJobDirectory(File jobdir) {
\r
116 return getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));
\r
119 private static Services getServiceByRunnerName(String name) {
\r
120 for (Services service : Services.values()) {
\r
121 String runnerName = service.getServiceImpl().getSimpleName()
\r
123 name = name.trim().toLowerCase();
\r
124 if (name.startsWith(runnerName)) {
\r
131 Service getService(URL url, String sqname) {
\r
132 QName qname = new QName(sqname, this.toString());
\r
133 return Service.create(url, qname);
\r
136 public static String toString(Set<Services> services) {
\r
137 if (services == null || services.isEmpty()) {
\r
141 String delim = ", ";
\r
142 for (Services serv : services) {
\r
143 value += serv.toString() + delim;
\r
145 value = value.substring(0, value.length() - delim.length());
\r
149 Class<? extends JABAService> getServiceType() {
\r
151 // deliberate leaking
\r
157 return SequenceAnnotation.class;
\r
159 // deliberate leaking
\r
166 return MsaWS.class;
\r
168 throw new RuntimeException("Unrecognised Web Service Type "
\r
169 + this + " - Should never happened!");
\r
173 JABAService getInterface(Service service) {
\r
174 assert service != null;
\r
176 QName portName = new QName(service.getServiceName().getNamespaceURI(),
\r
177 this.toString() + "Port");
\r
178 return service.getPort(portName, this.getServiceType());
\r