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