87ef1d2269f71b5fffd46c705e6832bc5f8e91ec
[jabaws.git] / webservices / compbio / ws / client / Services.java
1 /* Copyright (c) 2011 Peter Troshin\r
2  *  \r
3  *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
4  * \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
7  * \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
11  * \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
14  * \r
15  * Any republication or derived work distributed in source code form\r
16  * must include this copyright and license notice.\r
17  */\r
18 \r
19 package compbio.ws.client;\r
20 \r
21 import java.net.URL;\r
22 import java.util.Set;\r
23 \r
24 import javax.xml.bind.annotation.XmlAccessType;\r
25 import javax.xml.bind.annotation.XmlAccessorType;\r
26 import javax.xml.namespace.QName;\r
27 import javax.xml.ws.Service;\r
28 \r
29 import compbio.data.msa.JABAService;\r
30 import compbio.data.msa.MsaWS;\r
31 import compbio.data.msa.SequenceAnnotation;\r
32 \r
33 /**\r
34  * List of web services currently supported by JABAWS version 2.1\r
35  * \r
36  */\r
37 public enum Services {\r
38         /*\r
39          * Make sure this class has NO references to runners or engines as it is a\r
40          * part of minimal client package. Such things should go into ServicesUtil\r
41          */\r
42         MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, MSAprobsWS, GLprobsWS,\r
43         AAConWS, \r
44         JronnWS, DisemblWS, GlobPlotWS, IUPredWS, \r
45         JpredWS, \r
46         RNAalifoldWS;\r
47 \r
48         public static Services getService(String servName) {\r
49                 servName = servName.trim().toLowerCase();\r
50                 for (Services service : Services.values()) {\r
51                         if (service.toString().equalsIgnoreCase(servName)) {\r
52                                 return service;\r
53                         }\r
54                 }\r
55                 return null;\r
56         }\r
57 \r
58         Service getService(URL url, String sqname) {\r
59                 QName qname = new QName(sqname, this.toString());\r
60                 return Service.create(url, qname);\r
61         }\r
62 \r
63         public static String toString(Set<Services> services) {\r
64                 if (services == null || services.isEmpty()) {\r
65                         return "No known services...\n";\r
66                 }\r
67                 String value = "";\r
68                 for (Services serv : services) {\r
69                         if (null != serv) {\r
70                                 value += serv + "\n";\r
71                         } else {\r
72                                 value += "Unknown Service\n";\r
73                         }\r
74                 }\r
75                 return value;\r
76         }\r
77 \r
78         Class<? extends JABAService> getServiceType() {\r
79                 switch (this) {\r
80                         case AAConWS :\r
81                         case JronnWS :\r
82                         case DisemblWS :\r
83                         case GlobPlotWS :\r
84                         case IUPredWS :\r
85                         case RNAalifoldWS :\r
86                                 return SequenceAnnotation.class;\r
87                         case JpredWS :\r
88                         case ClustalWS :\r
89                         case ClustalOWS :\r
90                         case MafftWS :\r
91                         case MuscleWS :\r
92                         case ProbconsWS :\r
93                         case MSAprobsWS :\r
94                         case GLprobsWS :\r
95                         case TcoffeeWS :\r
96                                 return MsaWS.class;\r
97                         default :\r
98                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
99                 }\r
100         }\r
101 \r
102         \r
103         String getServiceNamespace() {\r
104                 switch (this) {\r
105                         case RNAalifoldWS :\r
106                         case AAConWS :\r
107                         case JronnWS :\r
108                         case DisemblWS :\r
109                         case GlobPlotWS :\r
110                         case IUPredWS :\r
111                         case MSAprobsWS :\r
112                         case GLprobsWS :\r
113                         case JpredWS :\r
114                         case ClustalOWS :\r
115                                 return JABAService.V2_SERVICE_NAMESPACE;\r
116                         case ClustalWS :\r
117                         case MafftWS :\r
118                         case MuscleWS :\r
119                         case ProbconsWS :\r
120                         case TcoffeeWS :\r
121                                 return JABAService.SERVICE_NAMESPACE;\r
122                         default :\r
123                                 throw new RuntimeException("Unrecognised JABAWS Namespace for service " + this +"!");\r
124                 }\r
125         }\r
126         \r
127         JABAService getInterface(Service service) {\r
128                 assert service != null;\r
129 \r
130                 QName portName = new QName(service.getServiceName().getNamespaceURI(), this.toString() + "Port");\r
131                 return service.getPort(portName, this.getServiceType());\r
132         }\r
133 \r
134         public String getServiceInfo() {\r
135                 switch (this) {\r
136                         case AAConWS :\r
137                                 return AACON_INFO.toString();\r
138                         case JpredWS :\r
139                                 return JPRED_INFO.toString();\r
140                         case ClustalOWS :\r
141                                 return CLUSTAL_OMEGA_INFO.toString();\r
142                         case ClustalWS :\r
143                                 return CLUSTAL_INFO.toString();\r
144                         case DisemblWS :\r
145                                 return DISEMBL_INFO.toString();\r
146                         case GlobPlotWS :\r
147                                 return GLOBPLOT_INFO.toString();\r
148                         case IUPredWS :\r
149                                 return IUPRED_INFO.toString();\r
150                         case JronnWS :\r
151                                 return JRONN_INFO.toString();\r
152                         case MafftWS :\r
153                                 return MAFFT_INFO.toString();\r
154                         case MuscleWS :\r
155                                 return MUSCLE_INFO.toString();\r
156                         case ProbconsWS :\r
157                                 return PROBCONS_INFO.toString();\r
158                         case MSAprobsWS :\r
159                                 return MSAPROBS_INFO.toString();\r
160                         case GLprobsWS :\r
161                                 return GLPROBS_INFO.toString();\r
162                         case TcoffeeWS :\r
163                                 return TCOFFEE_INFO.toString();\r
164                         case RNAalifoldWS :\r
165                                 return RNAALIFOLD_INFO.toString();\r
166                         default :\r
167                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
168                 }\r
169         }\r
170 \r
171         public String getServiceReference() {\r
172                 switch (this) {\r
173                         case AAConWS :\r
174                                 return AACON_INFO.getReference();\r
175                         case JpredWS :\r
176                                 return JPRED_INFO.getReference();\r
177                         case ClustalOWS :\r
178                                 return CLUSTAL_OMEGA_INFO.getReference();\r
179                         case ClustalWS :\r
180                                 return CLUSTAL_INFO.getReference();\r
181                         case DisemblWS :\r
182                                 return DISEMBL_INFO.getReference();\r
183                         case GlobPlotWS :\r
184                                 return GLOBPLOT_INFO.getReference();\r
185                         case IUPredWS :\r
186                                 return IUPRED_INFO.getReference();\r
187                         case JronnWS :\r
188                                 return JRONN_INFO.getReference();\r
189                         case MafftWS :\r
190                                 return MAFFT_INFO.getReference();\r
191                         case MuscleWS :\r
192                                 return MUSCLE_INFO.getReference();\r
193                         case ProbconsWS :\r
194                                 return PROBCONS_INFO.getReference();\r
195                         case MSAprobsWS :\r
196                                 return MSAPROBS_INFO.getReference();\r
197                         case GLprobsWS :\r
198                                 return GLPROBS_INFO.getReference();\r
199                         case TcoffeeWS :\r
200                                 return TCOFFEE_INFO.getReference();\r
201                         case RNAalifoldWS :\r
202                                 return RNAALIFOLD_INFO.getReference();\r
203                         default :\r
204                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
205                 }\r
206         }\r
207 \r
208         public String getServiceVersion() {\r
209                 switch (this) {\r
210                         case AAConWS :\r
211                                 return AACON_INFO.getVersion();\r
212                         case JpredWS :\r
213                                 return JPRED_INFO.getVersion();\r
214                         case ClustalOWS :\r
215                                 return CLUSTAL_OMEGA_INFO.getVersion();\r
216                         case ClustalWS :\r
217                                 return CLUSTAL_INFO.getVersion();\r
218                         case DisemblWS :\r
219                                 return DISEMBL_INFO.getVersion();\r
220                         case GlobPlotWS :\r
221                                 return GLOBPLOT_INFO.getVersion();\r
222                         case IUPredWS :\r
223                                 return IUPRED_INFO.getVersion();\r
224                         case JronnWS :\r
225                                 return JRONN_INFO.getVersion();\r
226                         case MafftWS :\r
227                                 return MAFFT_INFO.getVersion();\r
228                         case MuscleWS :\r
229                                 return MUSCLE_INFO.getVersion();\r
230                         case ProbconsWS :\r
231                                 return PROBCONS_INFO.getVersion();\r
232                         case MSAprobsWS :\r
233                                 return MSAPROBS_INFO.getVersion();\r
234                         case GLprobsWS :\r
235                                 return GLPROBS_INFO.getVersion();\r
236                         case TcoffeeWS :\r
237                                 return TCOFFEE_INFO.getVersion();\r
238                         case RNAalifoldWS :\r
239                                 return RNAALIFOLD_INFO.getVersion();\r
240                         default :\r
241                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
242                 }\r
243         }\r
244 \r
245         public String getServiceGroup() {\r
246                 switch (this) {\r
247                         case AAConWS :\r
248                                 return "annotation";\r
249                         case JpredWS :\r
250                                 return "annotation";\r
251                         case ClustalOWS :\r
252                                 return "alignment";\r
253                         case ClustalWS :\r
254                                 return "alignment";\r
255                         case DisemblWS :\r
256                                 return "disorder";\r
257                         case GlobPlotWS :\r
258                                 return "disorder";\r
259                         case IUPredWS :\r
260                                 return "disorder";\r
261                         case JronnWS :\r
262                                 return "disorder";\r
263                         case MafftWS :\r
264                                 return "alignment";\r
265                         case MuscleWS :\r
266                                 return "alignment";\r
267                         case ProbconsWS :\r
268                                 return "alignment";\r
269                         case GLprobsWS :\r
270                                 return "alignment";\r
271                         case MSAprobsWS :\r
272                                 return "alignment";\r
273                         case TcoffeeWS :\r
274                                 return "alignment";\r
275                         case RNAalifoldWS :\r
276                                 return "annotation";\r
277                         default :\r
278                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
279                 }\r
280         }\r
281         \r
282         static ServiceInfo AACON_INFO = new ServiceInfo(AAConWS,\r
283                         "in preparation", "1.0", "http://www.compbio.dundee.ac.uk/aacon");\r
284 \r
285         static ServiceInfo JPRED_INFO = new ServiceInfo(JpredWS,\r
286                         "Cole C, Barber JD, Barton GJ,\r\n" + \r
287                         "\"The Jpred 3 secondary structure prediction server\"\r\n" +\r
288                         "Nucl. Acids Res. 36 (suppl 2):W197 (2008)", \r
289                         "3.0.3", "http://www.compbio.dundee.ac.uk/www-jpred");\r
290         \r
291         static ServiceInfo CLUSTAL_INFO = new ServiceInfo(ClustalWS,\r
292                         "Larkin MA, Blackshields G, Brown NP, Chenna R, McGettigan PA, McWilliam H, Valentin F, Wallace IM, Wilm A, Lopez R, Thompson JD, Gibson TJ, Higgins DG,\r\n" +\r
293                         "\"Clustal W and Clustal X version 2.0\"\r\n" + \r
294                         "Bioinformatics, 23: 2947 (2007)",\r
295                         "2.0.12", "http://www.clustal.org/clustal2/");\r
296 \r
297         static ServiceInfo CLUSTAL_OMEGA_INFO = new ServiceInfo(ClustalOWS,\r
298                         "Sievers F, Wilm A, Dineen D, Gibson TJ, Karplus K, Li W, Lopez R, McWilliam H, Remmert M, Söding J, Thompson JD, Higgins DG,\r\n" +\r
299                         "\"Fast, scalable generation of high quality protein multiple sequence alignments using Clustal Omega\"\r\n" +\r
300                         "Mol Syst Biol. 7:539 (2011)",\r
301                         "1.0.2", "http://www.clustal.org/omega/");\r
302 \r
303         static ServiceInfo DISEMBL_INFO = new ServiceInfo(DisemblWS,\r
304                         "Linding R, Jensen LJ, Diella F, Bork P, Gibson TJ, and Russell RB,\r\n" +\r
305                         "\"Protein disorder prediction: implications for structural proteomics\"\r\n" +\r
306                         "Structure 11(11):1453 (2003)", \r
307                         "1.5", "http://dis.embl.de/");\r
308 \r
309         static ServiceInfo GLOBPLOT_INFO = new ServiceInfo(GlobPlotWS,\r
310                         "Linding R, Russell RB, Neduva V and Gibson TJ,\r\n" +\r
311                         "GlobPlot: exploring protein sequences for globularity and disorder\r\n" + \r
312                         "Nucl. Acids Res. 31 (13):3701 (2003)",\r
313                         "2.3", "http://globplot.embl.de/");\r
314 \r
315         static ServiceInfo IUPRED_INFO = new ServiceInfo(IUPredWS,\r
316                         "Dosztányi Z, Csizmók V, Tompa P, and Simon I,\r\n" +\r
317                         "\"The Pairwise Energy Content Estimated from Amino Acid Composition Discriminates between Folded and Intrinsically Unstructured Proteins\"\r\n" +\r
318                         "J. Mol. Biol. 347:827 (2005)", \r
319                         "1.0", "http://iupred.enzim.hu/");\r
320 \r
321         static ServiceInfo TCOFFEE_INFO = new ServiceInfo(TcoffeeWS,\r
322                         "Notredame C, Higgins DG, Heringa L,\r\n" +\r
323                         "\"T-Coffee: A novel method for multiple sequence alignments\"\r\n" + \r
324                         "JMB, 302(1):205 (2000)",\r
325                         "8.99", "http://tcoffee.crg.cat/apps/tcoffee/index.html");\r
326 \r
327         static ServiceInfo MUSCLE_INFO = new ServiceInfo(MuscleWS,\r
328                         "Edgar RC,\r\n"+ \r
329                         "\"MUSCLE: multiple sequence alignment with high accuracy and high throughput\"\r\n" + \r
330                         "Nucleic Acids Res. 32(5):1792 (2004)", \r
331                         "3.8.31", "http://www.drive5.com/muscle/");\r
332 \r
333         static ServiceInfo PROBCONS_INFO = new ServiceInfo(ProbconsWS,\r
334                         "Do CB, Mahabhashyam MSP, Brudno M, and Batzoglou S,\r\n" +\r
335                         "\"PROBCONS: Probabilistic Consistency-based Multiple Sequence Alignment\"\r\n" + \r
336                         "Genome Research 15:330 (2005)",\r
337                         "1.12", "http://probcons.stanford.edu/");\r
338 \r
339         static ServiceInfo MSAPROBS_INFO = new ServiceInfo(MSAprobsWS,\r
340                         "Liu Y, Schmidt B, and Maskell DL,\r\n" + \r
341                         "\"MSAProbs: multiple sequence alignment based on pair hidden Markov models and partition function posterior probabilities\"\r\n" +\r
342                         "Bioinformatics, 26 (16):1958 (2010)",\r
343                         "0.9.7", "http://msaprobs.sourceforge.net/");\r
344 \r
345         static ServiceInfo GLPROBS_INFO = new ServiceInfo(GLprobsWS,\r
346                         "Yongtao Ye, Siu-Ming Yiu, David W. Cheung, Qing Zhan, Hing-Fung Ting, Yadong Wang, Tak-Wah Lam,\r\n" +\r
347                         "\"GLProbs: Aligning multiple sequences adaptively\"\r\n" + \r
348                         "in progress (2013)",\r
349                         "1.0", "http://sourceforge.net/projects/glprobs/");\r
350 \r
351         static ServiceInfo JRONN_INFO = new ServiceInfo(JronnWS,\r
352                         "unpublished, original algorithm Yang ZR, Thomson R, McMeil P, and Esnouf RM,\r\n" + \r
353                         "\"RONN: the bio-basis function neural network technique applied to the dectection of natively disordered regions in proteins\"\r\n" +\r
354                         "Bioinformatics 21:3369 (2005)\r\n",\r
355                         "1.0", "http://www.compbio.dundee.ac.uk/jabaws/");\r
356 \r
357         static ServiceInfo MAFFT_INFO = new ServiceInfo(MafftWS,\r
358                         "Katoh K, Toh H,\r\n" +\r
359                         "\"Parallelization of the MAFFT multiple sequence alignment program\"\r\n" + \r
360                         "Bioinformatics 26:1899 (2010)",\r
361                         "6.8.57", "http://mafft.cbrc.jp/alignment/software/");\r
362 \r
363         static ServiceInfo RNAALIFOLD_INFO = new ServiceInfo(RNAalifoldWS,\r
364                         "Hofacker IL, Fekete M, and Stadler PV,\r\n"+ \r
365                         "\"Secondary Structure Prediction for Aligned RNA Sequences\"\r\n" + \r
366                         "J.Mol.Biol. 319:1059 (2002) and\r\n " + \r
367                         "Bernhart SH, Hofacker IL Will S, Gruber AR, and Stadler PF,\r\n" + \r
368                         "\"RNAalifold: Improved consensus structure prediction for RNA alignments\"\r\n" +\r
369                         "BMC Bioinformatics, 9:474 (2008)\r\n",\r
370                         "2.1.2", "http://www.tbi.univie.ac.at/RNA/");\r
371 \r
372         @XmlAccessorType(XmlAccessType.FIELD)\r
373         static class ServiceInfo {\r
374                 Services service;\r
375                 String reference;\r
376                 String version;\r
377                 String moreinfo;\r
378                 final static String jabaws_version = "2.1";\r
379                 final static String line_delimiter = "\n";\r
380 \r
381                 private ServiceInfo() {\r
382                         // Default constructor for JAXB\r
383                 }\r
384                 private ServiceInfo(Services service, String reference, String version,\r
385                                 String moreinfo) {\r
386                         this.service = service;\r
387                         this.reference = reference;\r
388                         this.version = version;\r
389                         this.moreinfo = moreinfo;\r
390                 }\r
391 \r
392                 @Override\r
393                 public String toString() {\r
394                         String value = "SERVICE: " + service + " version " + version + line_delimiter + "\n";\r
395                         value += "JABAWS v. " + jabaws_version + line_delimiter;\r
396                         value += "REFERENCE: " + reference + line_delimiter + "\n";\r
397                         value += "MORE INFORMATION: " + moreinfo + line_delimiter;\r
398                         return value;\r
399                 }\r
400 \r
401                 public String getReference() {\r
402                         return "REFERENCE: " + reference + line_delimiter + "<br>MORE INFORMATION: " + moreinfo + line_delimiter;\r
403                 }\r
404 \r
405                 public String getVersion() {\r
406                         return version;\r
407                 }\r
408         }\r
409 \r
410         public static void main(String[] args) {\r
411                 System.out.println(MUSCLE_INFO);\r
412         }\r
413 }\r