3616e1b5a97a95a775ac5297c3c478e057ca1831
[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.namespace.QName;\r
25 import javax.xml.ws.Service;\r
26 \r
27 import compbio.data.msa.JABAService;\r
28 import compbio.data.msa.MsaWS;\r
29 import compbio.data.msa.SequenceAnnotation;\r
30 \r
31 /**\r
32  * List of web services currently supported by JABAWS version 2\r
33  * \r
34  */\r
35 public enum Services {\r
36         /*\r
37          * Make sure this class has NO references to runners or engines as it is a\r
38          * part of minimal client package. Such things should go into ServicesUtil\r
39          */\r
40         MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS;\r
41 \r
42         public static Services getService(String servName) {\r
43                 servName = servName.trim().toLowerCase();\r
44                 for (Services service : Services.values()) {\r
45                         if (service.toString().equalsIgnoreCase(servName)) {\r
46                                 return service;\r
47                         }\r
48                 }\r
49                 return null;\r
50         }\r
51 \r
52         Service getService(URL url, String sqname) {\r
53                 QName qname = new QName(sqname, this.toString());\r
54                 return Service.create(url, qname);\r
55         }\r
56 \r
57         public static String toString(Set<Services> services) {\r
58                 if (services == null || services.isEmpty()) {\r
59                         return "";\r
60                 }\r
61                 String value = "";\r
62                 String delim = ", ";\r
63                 for (Services serv : services) {\r
64                         value += serv.toString() + delim;\r
65                 }\r
66                 value = value.substring(0, value.length() - delim.length());\r
67                 return value;\r
68         }\r
69 \r
70         Class<? extends JABAService> getServiceType() {\r
71                 switch (this) {\r
72                         // deliberate leaking\r
73                         case AAConWS :\r
74                         case JronnWS :\r
75                         case DisemblWS :\r
76                         case GlobPlotWS :\r
77                         case IUPredWS :\r
78                                 return SequenceAnnotation.class;\r
79 \r
80                                 // deliberate leaking\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 \r
88                                 return MsaWS.class;\r
89                         default :\r
90                                 throw new RuntimeException("Unrecognised Web Service Type "\r
91                                                 + this + " - Should never happened!");\r
92                 }\r
93         }\r
94 \r
95         JABAService getInterface(Service service) {\r
96                 assert service != null;\r
97 \r
98                 QName portName = new QName(service.getServiceName().getNamespaceURI(),\r
99                                 this.toString() + "Port");\r
100                 return service.getPort(portName, this.getServiceType());\r
101         }\r
102 \r
103         public String getServiceInfo() {\r
104                 switch (this) {\r
105                         case AAConWS :\r
106                                 return AACON_INFO;\r
107                         case ClustalOWS :\r
108                                 return CLUSTAL_OMEGA_INFO;\r
109                         case ClustalWS :\r
110                                 return CLUSTAL_INFO;\r
111                         case DisemblWS :\r
112                                 return DISEMBL_INFO;\r
113                         case GlobPlotWS :\r
114                                 return GLOBPLOT_INFO;\r
115                         case IUPredWS :\r
116                                 return IUPRED_INFO;\r
117                         case JronnWS :\r
118                                 return JRONN_INFO;\r
119                         case MafftWS :\r
120                                 return MAFFT_INFO;\r
121                         case MuscleWS :\r
122                                 return MUSCLE_INFO;\r
123                         case ProbconsWS :\r
124                                 return PROBCONS_INFO;\r
125                         case TcoffeeWS :\r
126                                 return TCOFFEE_INFO;\r
127                         default :\r
128                                 throw new RuntimeException("Unrecognised Web Service Type "\r
129                                                 + this + " - Should never happened!");\r
130                 }\r
131         }\r
132 \r
133         public static final String AACON_INFO = new ServiceInfo(AAConWS,\r
134                         "in preparation", "1.0", "http://www.compbio.dundee.ac.uk/aacon")\r
135                         .toString();\r
136         public static final String CLUSTAL_INFO = new ServiceInfo(\r
137                         ClustalWS,\r
138                         "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
139                                         + "(2007). Clustal W and Clustal X version 2.0. Bioinformatics, 23, 2947-2948. ",\r
140                         "2.0.12", "http://www.clustal.org/clustal2/").toString();\r
141         public static final String CLUSTAL_OMEGA_INFO = new ServiceInfo(\r
142                         ClustalOWS,\r
143                         "Fast, scalable generation of high quality protein multiple sequence alignments using Clustal Omega\r\n"\r
144                                         + "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
145                         "1.0.2", "http://www.clustal.org/omega").toString();\r
146         public static final String DISEMBL_INFO = new ServiceInfo(\r
147                         DisemblWS,\r
148                         "R. Linding, L.J. Jensen, F. Diella, P. Bork, T.J. Gibson and R.B. Russell\r\n"\r
149                                         + "Protein disorder prediction: implications for structural proteomics\r\n"\r
150                                         + "Structure Vol 11, Issue 11, 4 November 2003", "1.5",\r
151                         "http://dis.embl.de/").toString();\r
152         public static final String GLOBPLOT_INFO = new ServiceInfo(\r
153                         GlobPlotWS,\r
154                         "Rune Linding, Robert B. Russell, Victor Neduva and Toby J. Gibson "\r
155                                         + "'GlobPlot: exploring protein sequences for globularity and disorder.' Nucl. Acids Res. (2003) 31 (13): 3701-3708. doi: 10.1093/nar/gkg519\r\n",\r
156                         "2.3", "http://globplot.embl.de/").toString();\r
157         public static final String IUPRED_INFO = new ServiceInfo(\r
158                         IUPredWS,\r
159                         "The Pairwise Energy Content Estimated from Amino Acid Composition Discriminates between Folded and Intrinsically Unstructured Proteins\r\n"\r
160                                         + "Zsuzsanna Dosztányi, Veronika Csizmók, Péter Tompa and István Simon\r\n"\r
161                                         + "J. Mol. Biol. (2005) 347, 827-839.", "1.0",\r
162                         "http://iupred.enzim.hu/").toString();\r
163         public static final String TCOFFEE_INFO = new ServiceInfo(TcoffeeWS,\r
164                         "T-Coffee: A novel method for multiple sequence alignments  "\r
165                                         + "Notredame, Higgins, Heringa, JMB, 302 (205-217) 2000",\r
166                         "8.99", "http://tcoffee.crg.cat/apps/tcoffee/index.html")\r
167                         .toString();\r
168         public static final String MUSCLE_INFO = new ServiceInfo(\r
169                         MuscleWS,\r
170                         "Edgar, R.C. (2004) MUSCLE: multiple sequence alignment with high accuracy and high throughput.Nucleic Acids Res. 32(5):1792-1797.\r\n"\r
171                                         + "doi:10.1093/nar/gkh340", "3.8.31",\r
172                         "http://www.drive5.com/muscle/").toString();\r
173         public static final String PROBCONS_INFO = new ServiceInfo(\r
174                         ProbconsWS,\r
175                         "Do, C.B., Mahabhashyam, M.S.P., Brudno, M., and Batzoglou, S. 2005. PROBCONS: "\r
176                                         + "Probabilistic Consistency-based Multiple Sequence Alignment. Genome Research 15: 330-340. ",\r
177                         "1.12", "http://probcons.stanford.edu/").toString();;\r
178         public static final String JRONN_INFO = new ServiceInfo(\r
179                         JronnWS,\r
180                         "unpublished, original algorithm Yang,Z.R., Thomson,R., McMeil,P. and Esnouf,R.M. (2005) "\r
181                                         + "RONN: the bio-basis function neural network technique applied to the "\r
182                                         + "dectection of natively disordered regions in proteins Bioinformatics 21: 3369-3376\r\n",\r
183                         "1.0", "http://www.compbio.dundee.ac.uk/jabaws/").toString();;\r
184         public static final String MAFFT_INFO = new ServiceInfo(\r
185                         MafftWS,\r
186                         "Katoh, Toh 2010 (Bioinformatics 26:1899-1900)\r\n"\r
187                                         + "Parallelization of the MAFFT multiple sequence alignment program. ",\r
188                         "6.8.57", "http://mafft.cbrc.jp/alignment/software/").toString();;\r
189 \r
190         static class ServiceInfo {\r
191                 Services service;\r
192                 String reference;\r
193                 String version;\r
194                 String moreinfo;\r
195                 final static String jabaws_version = "2.0";\r
196                 final static String line_delimiter = "\n";\r
197 \r
198                 private ServiceInfo(Services service, String reference, String version,\r
199                                 String moreinfo) {\r
200                         this.service = service;\r
201                         this.reference = reference;\r
202                         this.version = version;\r
203                         this.moreinfo = moreinfo;\r
204                 }\r
205 \r
206                 @Override\r
207                 public String toString() {\r
208                         String value = "SERVICE: " + service + " version " + version\r
209                                         + line_delimiter;\r
210                         value += "JABAWS v. " + jabaws_version + line_delimiter;\r
211                         value += "REFERENCES: " + reference + line_delimiter;\r
212                         value += "MORE INFORMATION: " + moreinfo + line_delimiter;\r
213                         return value;\r
214                 }\r
215         }\r
216 \r
217         public static void main(String[] args) {\r
218                 System.out.println(MUSCLE_INFO);\r
219         }\r
220 }