8a392d73adf7881f29b78fd2831d5f26c4bdd243
[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;\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 "";\r
62                 }\r
63                 String value = "";\r
64                 String delim = ", ";\r
65                 for (Services serv : services) {\r
66                         value += serv.toString() + delim;\r
67                 }\r
68                 value = value.substring(0, value.length() - delim.length());\r
69                 return value;\r
70         }\r
71 \r
72         Class<? extends JABAService> getServiceType() {\r
73                 switch (this) {\r
74                         case AAConWS :\r
75                         case JpredWS :\r
76                         case JronnWS :\r
77                         case DisemblWS :\r
78                         case GlobPlotWS :\r
79                         case IUPredWS :\r
80                                 return SequenceAnnotation.class;\r
81                         case ClustalWS :\r
82                         case ClustalOWS :\r
83                         case MafftWS :\r
84                         case MuscleWS :\r
85                         case ProbconsWS :\r
86                         case TcoffeeWS :\r
87                                 return MsaWS.class;\r
88                         default :\r
89                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
90                 }\r
91         }\r
92 \r
93         \r
94         String getServiceNamespace() {\r
95                 switch (this) {\r
96                         case JpredWS :\r
97                         case AAConWS :\r
98                         case JronnWS :\r
99                         case DisemblWS :\r
100                         case GlobPlotWS :\r
101                         case IUPredWS :\r
102                         case ClustalOWS :\r
103                                 return JABAService.V2_SERVICE_NAMESPACE;\r
104                         case ClustalWS :\r
105                         case MafftWS :\r
106                         case MuscleWS :\r
107                         case ProbconsWS :\r
108                         case TcoffeeWS :\r
109                                 return JABAService.SERVICE_NAMESPACE;\r
110                         default :\r
111                                 throw new RuntimeException("Unrecognised JABAWS Namespace for service " + this +"!");\r
112                 }\r
113         }\r
114         \r
115         JABAService getInterface(Service service) {\r
116                 assert service != null;\r
117 \r
118                 QName portName = new QName(service.getServiceName().getNamespaceURI(), this.toString() + "Port");\r
119                 return service.getPort(portName, this.getServiceType());\r
120         }\r
121 \r
122         public String getServiceInfo() {\r
123                 switch (this) {\r
124                         case AAConWS :\r
125                                 return AACON_INFO;\r
126                         case JpredWS :\r
127                                 return JPRED_INFO;\r
128                         case ClustalOWS :\r
129                                 return CLUSTAL_OMEGA_INFO;\r
130                         case ClustalWS :\r
131                                 return CLUSTAL_INFO;\r
132                         case DisemblWS :\r
133                                 return DISEMBL_INFO;\r
134                         case GlobPlotWS :\r
135                                 return GLOBPLOT_INFO;\r
136                         case IUPredWS :\r
137                                 return IUPRED_INFO;\r
138                         case JronnWS :\r
139                                 return JRONN_INFO;\r
140                         case MafftWS :\r
141                                 return MAFFT_INFO;\r
142                         case MuscleWS :\r
143                                 return MUSCLE_INFO;\r
144                         case ProbconsWS :\r
145                                 return PROBCONS_INFO;\r
146                         case TcoffeeWS :\r
147                                 return TCOFFEE_INFO;\r
148                         default :\r
149                                 throw new RuntimeException("Unrecognised Web Service Type " + this + " - Should never happen!");\r
150                 }\r
151         }\r
152 \r
153         public static final String AACON_INFO = new ServiceInfo(AAConWS,\r
154                         "in preparation", "1.0", "http://www.compbio.dundee.ac.uk/aacon").toString();\r
155 \r
156         public static final String JPRED_INFO = new ServiceInfo(JpredWS,\r
157                         "Cole C, Barber JD, Barton GJ.reparation" + \r
158                         "The Jpred 3 secondary structure prediction server\n" +\r
159                         "Nucl. Acids Res. (2008) 36 (suppl 2): W197-W201., doi: 10.1093/nar/gkn238", \r
160                         "3.0", "http://www.compbio.dundee.ac.uk/www-jpred").toString();\r
161         \r
162         public static final String CLUSTAL_INFO = new ServiceInfo(ClustalWS,\r
163                         "Larkin MA, Blackshields G, Brown NP, Chenna R, McGettigan PA, McWilliam H, Valentin F, " + \r
164                         "Wallace IM, Wilm A, Lopez R, Thompson JD, Gibson TJ, Higgins DG.\n" +\r
165                         "(2007). Clustal W and Clustal X version 2.0. Bioinformatics, 23, 2947-2948.",\r
166                         "2.0.12", "http://www.clustal.org/clustal2/").toString();\r
167 \r
168         public static final String CLUSTAL_OMEGA_INFO = new ServiceInfo(ClustalOWS,\r
169                         "Fast, scalable generation of high quality protein multiple sequence alignments using Clustal Omega\r\n"\r
170                         + "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
171                         "1.0.2", "http://www.clustal.org/omega").toString();\r
172 \r
173         public static final String DISEMBL_INFO = new ServiceInfo(DisemblWS,\r
174                         "R. Linding, L.J. Jensen, F. Diella, P. Bork, T.J. Gibson and R.B. Russell\r\n"\r
175                         + "Protein disorder prediction: implications for structural proteomics\r\n"\r
176                         + "Structure Vol 11, Issue 11, 4 November 2003", "1.5",\r
177                         "http://dis.embl.de/").toString();\r
178 \r
179         public static final String GLOBPLOT_INFO = new ServiceInfo(GlobPlotWS,\r
180                         "Rune Linding, Robert B. Russell, Victor Neduva and Toby J. Gibson " +\r
181                         "'GlobPlot: exploring protein sequences for globularity and disorder.' " + \r
182                         "Nucl. Acids Res. (2003) 31 (13): 3701-3708. doi: 10.1093/nar/gkg519\r\n",\r
183                         "2.3", "http://globplot.embl.de/").toString();\r
184 \r
185         public static final String IUPRED_INFO = new ServiceInfo(IUPredWS,\r
186                         "The Pairwise Energy Content Estimated from Amino Acid Composition Discriminates between Folded and Intrinsically Unstructured Proteins\r\n"\r
187                         + "Zsuzsanna Dosztányi, Veronika Csizmók, Péter Tompa and István Simon\r\n"\r
188                         + "J. Mol. Biol. (2005) 347, 827-839.", "1.0",\r
189                         "http://iupred.enzim.hu/").toString();\r
190 \r
191         public static final String TCOFFEE_INFO = new ServiceInfo(TcoffeeWS,\r
192                         "T-Coffee: A novel method for multiple sequence alignments  "\r
193                         + "Notredame, Higgins, Heringa, JMB, 302 (205-217) 2000",\r
194                         "8.99", "http://tcoffee.crg.cat/apps/tcoffee/index.html").toString();\r
195 \r
196         public static final String MUSCLE_INFO = new ServiceInfo(\r
197                         MuscleWS,\r
198                         "Edgar, R.C. (2004) MUSCLE: multiple sequence alignment with high accuracy and high throughput.Nucleic Acids Res. 32(5):1792-1797.\r\n"\r
199                         + "doi:10.1093/nar/gkh340", "3.8.31",\r
200                         "http://www.drive5.com/muscle/").toString();\r
201 \r
202         public static final String PROBCONS_INFO = new ServiceInfo(\r
203                         ProbconsWS,\r
204                         "Do, C.B., Mahabhashyam, M.S.P., Brudno, M., and Batzoglou, S. 2005. PROBCONS: "\r
205                         + "Probabilistic Consistency-based Multiple Sequence Alignment. Genome Research 15: 330-340. ",\r
206                         "1.12", "http://probcons.stanford.edu/").toString();\r
207 \r
208         public static final String JRONN_INFO = new ServiceInfo(\r
209                         JronnWS,\r
210                         "unpublished, original algorithm Yang,Z.R., Thomson,R., McMeil,P. and Esnouf,R.M. (2005) "\r
211                                         + "RONN: the bio-basis function neural network technique applied to the "\r
212                                         + "dectection of natively disordered regions in proteins Bioinformatics 21: 3369-3376\r\n",\r
213                         "1.0", "http://www.compbio.dundee.ac.uk/jabaws/").toString();\r
214 \r
215         public static final String MAFFT_INFO = new ServiceInfo(\r
216                         MafftWS,\r
217                         "Katoh, Toh 2010 (Bioinformatics 26:1899-1900)\r\n"\r
218                                         + "Parallelization of the MAFFT multiple sequence alignment program. ",\r
219                         "6.8.57", "http://mafft.cbrc.jp/alignment/software/").toString();\r
220 \r
221         @XmlAccessorType(XmlAccessType.FIELD)\r
222         static class ServiceInfo {\r
223                 Services service;\r
224                 String reference;\r
225                 String version;\r
226                 String moreinfo;\r
227                 final static String jabaws_version = "2.5";\r
228                 final static String line_delimiter = "\n";\r
229 \r
230                 private ServiceInfo() {\r
231                         // Default constructor for JAXB\r
232                 }\r
233                 private ServiceInfo(Services service, String reference, String version,\r
234                                 String moreinfo) {\r
235                         this.service = service;\r
236                         this.reference = reference;\r
237                         this.version = version;\r
238                         this.moreinfo = moreinfo;\r
239                 }\r
240 \r
241                 @Override\r
242                 public String toString() {\r
243                         String value = "SERVICE: " + service + " version " + version + line_delimiter;\r
244                         value += "JABAWS v. " + jabaws_version + line_delimiter;\r
245                         value += "REFERENCES: " + reference + line_delimiter;\r
246                         value += "MORE INFORMATION: " + moreinfo + line_delimiter;\r
247                         return value;\r
248                 }\r
249         }\r
250 \r
251         public static void main(String[] args) {\r
252                 System.out.println(MUSCLE_INFO);\r
253         }\r
254 }