1 /* Copyright (c) 2011 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.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.IUPred;
\r
37 import compbio.runner.disorder.Jronn;
\r
38 import compbio.runner.msa.ClustalO;
\r
39 import compbio.runner.msa.ClustalW;
\r
40 import compbio.runner.msa.Mafft;
\r
41 import compbio.runner.msa.Muscle;
\r
42 import compbio.runner.msa.Probcons;
\r
43 import compbio.runner.msa.Tcoffee;
\r
46 * List of web services currently supported by JABAWS version 2
\r
49 public enum Services {
\r
50 MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS;
\r
52 public static Services getService(String servName) {
\r
53 servName = servName.trim().toLowerCase();
\r
54 for (Services service : Services.values()) {
\r
55 if (service.toString().equalsIgnoreCase(servName)) {
\r
62 public static Services getServiceByRunner(
\r
63 Class<Executable<?>> runnerClassName) {
\r
64 assert runnerClassName != null;
\r
65 String sname = runnerClassName.getSimpleName().toLowerCase();
\r
66 for (Services service : Services.values()) {
\r
67 if (service.toString().toLowerCase().contains(sname)) {
\r
74 public Class<? extends Executable<?>> getServiceImpl() {
\r
79 return ClustalO.class;
\r
81 return ClustalW.class;
\r
85 return Muscle.class;
\r
87 return Tcoffee.class;
\r
89 return Probcons.class;
\r
91 return Disembl.class;
\r
93 return GlobPlot.class;
\r
97 return IUPred.class;
\r
99 throw new RuntimeException(
\r
100 "Unknown web service implementation class for service: "
\r
105 public static Class<? extends Executable<?>> getRunnerByJobDirectory(
\r
107 Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));
\r
108 return service.getServiceImpl();
\r
111 private static String getRunnerNameByJobDirectory(File jobdir) {
\r
112 String name = jobdir.getName().split("#")[0];
\r
114 if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) {
\r
115 assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1;
\r
116 name = name.substring(1);
\r
121 public static Services getServiceByJobDirectory(File jobdir) {
\r
122 return getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));
\r
125 private static Services getServiceByRunnerName(String name) {
\r
126 for (Services service : Services.values()) {
\r
127 String runnerName = service.getServiceImpl().getSimpleName()
\r
129 name = name.trim().toLowerCase();
\r
130 if (name.startsWith(runnerName)) {
\r
137 Service getService(URL url, String sqname) {
\r
138 QName qname = new QName(sqname, this.toString());
\r
139 return Service.create(url, qname);
\r
142 public static String toString(Set<Services> services) {
\r
143 if (services == null || services.isEmpty()) {
\r
147 String delim = ", ";
\r
148 for (Services serv : services) {
\r
149 value += serv.toString() + delim;
\r
151 value = value.substring(0, value.length() - delim.length());
\r
155 Class<? extends JABAService> getServiceType() {
\r
157 // deliberate leaking
\r
163 return SequenceAnnotation.class;
\r
165 // deliberate leaking
\r
173 return MsaWS.class;
\r
175 throw new RuntimeException("Unrecognised Web Service Type "
\r
176 + this + " - Should never happened!");
\r
180 JABAService getInterface(Service service) {
\r
181 assert service != null;
\r
183 QName portName = new QName(service.getServiceName().getNamespaceURI(),
\r
184 this.toString() + "Port");
\r
185 return service.getPort(portName, this.getServiceType());
\r