Refactoring: rename duplicated Util classes
[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\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, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS, JpredWS, RNAalifoldWS;\r
43 \r
44         public static Services getService(String servName) {\r
45                 servName = servName.trim().toLowerCase();\r
46                 for (Services service : Services.values()) {\r
47                         if (service.toString().equalsIgnoreCase(servName)) {\r
48                                 return service;\r
49                         }\r
50                 }\r
51                 return null;\r
52         }\r
53 \r
54         Service getService(URL url, String sqname) {\r
55                 QName qname = new QName(sqname, this.toString());\r
56                 return Service.create(url, qname);\r
57         }\r
58 \r
59         public static String toString(Set<Services> services) {\r
60                 if (services == null || services.isEmpty()) {\r
61                         return "No known services...\n";\r
62                 }\r
63                 String value = "";\r
64                 for (Services serv : services) {\r
65                         if (null != serv) {\r
66                                 value += serv + "\n";\r
67                         } else {\r
68                                 value += "Unknown Service\n";\r
69                         }\r
70                 }\r
71                 return value;\r
72         }\r
73 \r
74         Class<? extends JABAService> getServiceType() {\r
75                 switch (this) {\r
76                         case AAConWS :\r
77                         case JronnWS :\r
78                         case DisemblWS :\r
79                         case GlobPlotWS :\r
80                         case IUPredWS :\r
81                         case RNAalifoldWS :\r
82                                 return SequenceAnnotation.class;\r
83                         case JpredWS :\r
84                         case ClustalWS :\r
85                         case ClustalOWS :\r
86                         case MafftWS :\r
87                         case MuscleWS :\r
88                         case ProbconsWS :\r
89                         case TcoffeeWS :\r
90                                 return MsaWS.class;\r
91 \r
92                         default :\r
93                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
94                 }\r
95         }\r
96 \r
97         \r
98         String getServiceNamespace() {\r
99                 switch (this) {\r
100                         case RNAalifoldWS :\r
101                         case AAConWS :\r
102                         case JronnWS :\r
103                         case DisemblWS :\r
104                         case GlobPlotWS :\r
105                         case IUPredWS :\r
106                                 return JABAService.V2_SERVICE_NAMESPACE;\r
107                         case ClustalOWS :\r
108                         case JpredWS :\r
109                         case ClustalWS :\r
110                         case MafftWS :\r
111                         case MuscleWS :\r
112                         case ProbconsWS :\r
113                         case TcoffeeWS :\r
114                                 return JABAService.SERVICE_NAMESPACE;\r
115                         default :\r
116                                 throw new RuntimeException("Unrecognised JABAWS Namespace for service " + this +"!");\r
117                 }\r
118         }\r
119         \r
120         JABAService getInterface(Service service) {\r
121                 assert service != null;\r
122 \r
123                 QName portName = new QName(service.getServiceName().getNamespaceURI(), this.toString() + "Port");\r
124                 return service.getPort(portName, this.getServiceType());\r
125         }\r
126 \r
127         public String getServiceInfo() {\r
128                 switch (this) {\r
129                         case AAConWS :\r
130                                 return AACON_INFO.toString();\r
131                         case JpredWS :\r
132                                 return JPRED_INFO.toString();\r
133                         case ClustalOWS :\r
134                                 return CLUSTAL_OMEGA_INFO.toString();\r
135                         case ClustalWS :\r
136                                 return CLUSTAL_INFO.toString();\r
137                         case DisemblWS :\r
138                                 return DISEMBL_INFO.toString();\r
139                         case GlobPlotWS :\r
140                                 return GLOBPLOT_INFO.toString();\r
141                         case IUPredWS :\r
142                                 return IUPRED_INFO.toString();\r
143                         case JronnWS :\r
144                                 return JRONN_INFO.toString();\r
145                         case MafftWS :\r
146                                 return MAFFT_INFO.toString();\r
147                         case MuscleWS :\r
148                                 return MUSCLE_INFO.toString();\r
149                         case ProbconsWS :\r
150                                 return PROBCONS_INFO.toString();\r
151                         case TcoffeeWS :\r
152                                 return TCOFFEE_INFO.toString();\r
153                         case RNAalifoldWS :\r
154                                 return RNAALIFOLD_INFO.toString();\r
155                         default :\r
156                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
157                 }\r
158         }\r
159 \r
160         public String getServiceReference() {\r
161                 switch (this) {\r
162                         case AAConWS :\r
163                                 return AACON_INFO.getReference();\r
164                         case JpredWS :\r
165                                 return JPRED_INFO.getReference();\r
166                         case ClustalOWS :\r
167                                 return CLUSTAL_OMEGA_INFO.getReference();\r
168                         case ClustalWS :\r
169                                 return CLUSTAL_INFO.getReference();\r
170                         case DisemblWS :\r
171                                 return DISEMBL_INFO.getReference();\r
172                         case GlobPlotWS :\r
173                                 return GLOBPLOT_INFO.getReference();\r
174                         case IUPredWS :\r
175                                 return IUPRED_INFO.getReference();\r
176                         case JronnWS :\r
177                                 return JRONN_INFO.getReference();\r
178                         case MafftWS :\r
179                                 return MAFFT_INFO.getReference();\r
180                         case MuscleWS :\r
181                                 return MUSCLE_INFO.getReference();\r
182                         case ProbconsWS :\r
183                                 return PROBCONS_INFO.getReference();\r
184                         case TcoffeeWS :\r
185                                 return TCOFFEE_INFO.getReference();\r
186                         case RNAalifoldWS :\r
187                                 return RNAALIFOLD_INFO.getReference();\r
188                         default :\r
189                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
190                 }\r
191         }\r
192 \r
193         public String getServiceVersion() {\r
194                 switch (this) {\r
195                         case AAConWS :\r
196                                 return AACON_INFO.getVersion();\r
197                         case JpredWS :\r
198                                 return JPRED_INFO.getVersion();\r
199                         case ClustalOWS :\r
200                                 return CLUSTAL_OMEGA_INFO.getVersion();\r
201                         case ClustalWS :\r
202                                 return CLUSTAL_INFO.getVersion();\r
203                         case DisemblWS :\r
204                                 return DISEMBL_INFO.getVersion();\r
205                         case GlobPlotWS :\r
206                                 return GLOBPLOT_INFO.getVersion();\r
207                         case IUPredWS :\r
208                                 return IUPRED_INFO.getVersion();\r
209                         case JronnWS :\r
210                                 return JRONN_INFO.getVersion();\r
211                         case MafftWS :\r
212                                 return MAFFT_INFO.getVersion();\r
213                         case MuscleWS :\r
214                                 return MUSCLE_INFO.getVersion();\r
215                         case ProbconsWS :\r
216                                 return PROBCONS_INFO.getVersion();\r
217                         case TcoffeeWS :\r
218                                 return TCOFFEE_INFO.getVersion();\r
219                         case RNAalifoldWS :\r
220                                 return RNAALIFOLD_INFO.getVersion();\r
221                         default :\r
222                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
223                 }\r
224         }\r
225 \r
226         public String getServiceGroup() {\r
227                 switch (this) {\r
228                         case AAConWS :\r
229                                 return "annotation";\r
230                         case JpredWS :\r
231                                 return "annotation";\r
232                         case ClustalOWS :\r
233                                 return "alignment";\r
234                         case ClustalWS :\r
235                                 return "alignment";\r
236                         case DisemblWS :\r
237                                 return "disorder";\r
238                         case GlobPlotWS :\r
239                                 return "disorder";\r
240                         case IUPredWS :\r
241                                 return "disorder";\r
242                         case JronnWS :\r
243                                 return "disorder";\r
244                         case MafftWS :\r
245                                 return "alignment";\r
246                         case MuscleWS :\r
247                                 return "alignment";\r
248                         case ProbconsWS :\r
249                                 return "alignment";\r
250                         case TcoffeeWS :\r
251                                 return "alignment";\r
252                         case RNAalifoldWS :\r
253                                 return "annotation";\r
254                         default :\r
255                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
256                 }\r
257         }\r
258         \r
259         static ServiceInfo AACON_INFO = new ServiceInfo(AAConWS,\r
260                         "in preparation", "1.0", "http://www.compbio.dundee.ac.uk/aacon");\r
261 \r
262         static ServiceInfo JPRED_INFO = new ServiceInfo(JpredWS,\r
263                         "Cole C, Barber JD, Barton GJ.reparation" + \r
264                         "The Jpred 3 secondary structure prediction server\n" +\r
265                         "Nucl. Acids Res. (2008) 36 (suppl 2): W197-W201., doi: 10.1093/nar/gkn238", \r
266                         "3.0.3", "http://www.compbio.dundee.ac.uk/www-jpred");\r
267         \r
268         static ServiceInfo CLUSTAL_INFO = new ServiceInfo(ClustalWS,\r
269                         "Larkin MA, Blackshields G, Brown NP, Chenna R, McGettigan PA, McWilliam H, Valentin F, " + \r
270                         "Wallace IM, Wilm A, Lopez R, Thompson JD, Gibson TJ, Higgins DG.\n" +\r
271                         "(2007). Clustal W and Clustal X version 2.0. Bioinformatics, 23, 2947-2948.",\r
272                         "2.0.12", "http://www.clustal.org/clustal2/");\r
273 \r
274         static ServiceInfo CLUSTAL_OMEGA_INFO = new ServiceInfo(ClustalOWS,\r
275                         "Fast, scalable generation of high quality protein multiple sequence alignments using Clustal Omega\r\n"\r
276                         + "Fabian Sievers, Andreas Wilm, David Dineen, Toby J. Gibson, Kevin Karplus, Weizhong Li, Rodrigo Lopez, Hamish McWilliam, Michael Remmert, Johannes Söding, Julie D. Thompson, Desmond G. Higgins",\r
277                         "1.0.2", "http://www.clustal.org/omega");\r
278 \r
279         static ServiceInfo DISEMBL_INFO = new ServiceInfo(DisemblWS,\r
280                         "R. Linding, L.J. Jensen, F. Diella, P. Bork, T.J. Gibson and R.B. Russell\r\n"\r
281                         + "Protein disorder prediction: implications for structural proteomics\r\n"\r
282                         + "Structure Vol 11, Issue 11, 4 November 2003", "1.5",\r
283                         "http://dis.embl.de/");\r
284 \r
285         static ServiceInfo GLOBPLOT_INFO = new ServiceInfo(GlobPlotWS,\r
286                         "Rune Linding, Robert B. Russell, Victor Neduva and Toby J. Gibson " +\r
287                         "'GlobPlot: exploring protein sequences for globularity and disorder.' " + \r
288                         "Nucl. Acids Res. (2003) 31 (13): 3701-3708. doi: 10.1093/nar/gkg519\r\n",\r
289                         "2.3", "http://globplot.embl.de/");\r
290 \r
291         static ServiceInfo IUPRED_INFO = new ServiceInfo(IUPredWS,\r
292                         "The Pairwise Energy Content Estimated from Amino Acid Composition Discriminates between Folded and Intrinsically Unstructured Proteins\r\n"\r
293                         + "Zsuzsanna Dosztányi, Veronika Csizmók, Péter Tompa and István Simon\r\n"\r
294                         + "J. Mol. Biol. (2005) 347, 827-839.", "1.0",\r
295                         "http://iupred.enzim.hu/");\r
296 \r
297         static ServiceInfo TCOFFEE_INFO = new ServiceInfo(TcoffeeWS,\r
298                         "T-Coffee: A novel method for multiple sequence alignments  "\r
299                         + "Notredame, Higgins, Heringa, JMB, 302 (205-217) 2000",\r
300                         "8.99", "http://tcoffee.crg.cat/apps/tcoffee/index.html");\r
301 \r
302         static ServiceInfo MUSCLE_INFO = new ServiceInfo(MuscleWS,\r
303                         "Edgar, R.C. (2004) MUSCLE: multiple sequence alignment with high accuracy and high throughput.Nucleic Acids Res. 32(5):1792-1797.\r\n"\r
304                         + "doi:10.1093/nar/gkh340", "3.8.31",\r
305                         "http://www.drive5.com/muscle/");\r
306 \r
307         static ServiceInfo PROBCONS_INFO = new ServiceInfo(ProbconsWS,\r
308                         "Do, C.B., Mahabhashyam, M.S.P., Brudno, M., and Batzoglou, S. 2005. PROBCONS: "\r
309                         + "Probabilistic Consistency-based Multiple Sequence Alignment. Genome Research 15: 330-340. ",\r
310                         "1.12", "http://probcons.stanford.edu/");\r
311 \r
312         static ServiceInfo JRONN_INFO = new ServiceInfo(JronnWS,\r
313                         "unpublished, original algorithm Yang,Z.R., Thomson,R., McMeil,P. and Esnouf,R.M. (2005) "\r
314                                         + "RONN: the bio-basis function neural network technique applied to the "\r
315                                         + "dectection of natively disordered regions in proteins Bioinformatics 21: 3369-3376\r\n",\r
316                         "1.0", "http://www.compbio.dundee.ac.uk/jabaws/");\r
317 \r
318         static ServiceInfo MAFFT_INFO = new ServiceInfo(MafftWS,\r
319                         "Katoh, Toh 2010 (Bioinformatics 26:1899-1900)\r\n"\r
320                                         + "Parallelization of the MAFFT multiple sequence alignment program. ",\r
321                         "6.8.57", "http://mafft.cbrc.jp/alignment/software/");\r
322 \r
323         static ServiceInfo RNAALIFOLD_INFO = new ServiceInfo(RNAalifoldWS,\r
324                         "Ivo L. Hofacker, Martin Fekete, and Peter F. Stadler 'Secondary Structure Prediction"\r
325                         + " for Aligned RNA Sequences'. J.Mol.Biol. 319: 1059-1066, 2002. Stephan H. Bernhart,"\r
326                         + " Ivo L. Hofacker, Sebastian Will, Andreas R. Gruber, and Peter F. Stadler. "\r
327                         + "'RNAalifold: Improved consensus structure prediction for RNA alignments'. BMC Bioinformatics, 9:474, 2008.\r\n",\r
328                         "2.1.2", "http://www.tbi.univie.ac.at/RNA/");\r
329 \r
330         @XmlAccessorType(XmlAccessType.FIELD)\r
331         static class ServiceInfo {\r
332                 Services service;\r
333                 String reference;\r
334                 String version;\r
335                 String moreinfo;\r
336                 final static String jabaws_version = "2.5";\r
337                 final static String line_delimiter = "\n";\r
338 \r
339                 private ServiceInfo() {\r
340                         // Default constructor for JAXB\r
341                 }\r
342                 private ServiceInfo(Services service, String reference, String version,\r
343                                 String moreinfo) {\r
344                         this.service = service;\r
345                         this.reference = reference;\r
346                         this.version = version;\r
347                         this.moreinfo = moreinfo;\r
348                 }\r
349 \r
350                 @Override\r
351                 public String toString() {\r
352                         String value = "SERVICE: " + service + " version " + version + line_delimiter + "\n";\r
353                         value += "JABAWS v. " + jabaws_version + line_delimiter;\r
354                         value += "REFERENCE: " + reference + line_delimiter + "\n";\r
355                         value += "MORE INFORMATION: " + moreinfo + line_delimiter;\r
356                         return value;\r
357                 }\r
358 \r
359                 public String getReference() {\r
360                         return "REFERENCE: " + reference + line_delimiter + "<br>MORE INFORMATION: " + moreinfo + line_delimiter;\r
361                 }\r
362 \r
363                 public String getVersion() {\r
364                         return version;\r
365                 }\r
366         }\r
367 \r
368         public static void main(String[] args) {\r
369                 System.out.println(MUSCLE_INFO);\r
370         }\r
371 }\r