Add an implementation for Services.getServiceInfo method and categorization for services.
[jabaws.git] / webservices / compbio / ws / client / Services.java
index a0c1f56..3616e1b 100644 (file)
@@ -1,6 +1,6 @@
-/* Copyright (c) 2009 Peter Troshin\r
+/* Copyright (c) 2011 Peter Troshin\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
  * \r
  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
  *  Apache License version 2 as published by the Apache Software Foundation\r
@@ -19,6 +19,7 @@
 package compbio.ws.client;\r
 \r
 import java.net.URL;\r
+import java.util.Set;\r
 \r
 import javax.xml.namespace.QName;\r
 import javax.xml.ws.Service;\r
@@ -32,36 +33,18 @@ import compbio.data.msa.SequenceAnnotation;
  * \r
  */\r
 public enum Services {\r
-       MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS;\r
+       /*\r
+        * Make sure this class has NO references to runners or engines as it is a\r
+        * part of minimal client package. Such things should go into ServicesUtil\r
+        */\r
+       MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS;\r
 \r
        public static Services getService(String servName) {\r
                servName = servName.trim().toLowerCase();\r
-               if (servName.equalsIgnoreCase(MafftWS.toString())) {\r
-                       return MafftWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(ClustalWS.toString())) {\r
-                       return ClustalWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(TcoffeeWS.toString())) {\r
-                       return TcoffeeWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(MuscleWS.toString())) {\r
-                       return MuscleWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(ProbconsWS.toString())) {\r
-                       return ProbconsWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(AAConWS.toString())) {\r
-                       return AAConWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(JronnWS.toString())) {\r
-                       return JronnWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(DisemblWS.toString())) {\r
-                       return DisemblWS;\r
-               }\r
-               if (servName.equalsIgnoreCase(GlobPlotWS.toString())) {\r
-                       return GlobPlotWS;\r
+               for (Services service : Services.values()) {\r
+                       if (service.toString().equalsIgnoreCase(servName)) {\r
+                               return service;\r
+                       }\r
                }\r
                return null;\r
        }\r
@@ -71,6 +54,19 @@ public enum Services {
                return Service.create(url, qname);\r
        }\r
 \r
+       public static String toString(Set<Services> services) {\r
+               if (services == null || services.isEmpty()) {\r
+                       return "";\r
+               }\r
+               String value = "";\r
+               String delim = ", ";\r
+               for (Services serv : services) {\r
+                       value += serv.toString() + delim;\r
+               }\r
+               value = value.substring(0, value.length() - delim.length());\r
+               return value;\r
+       }\r
+\r
        Class<? extends JABAService> getServiceType() {\r
                switch (this) {\r
                        // deliberate leaking\r
@@ -78,11 +74,12 @@ public enum Services {
                        case JronnWS :\r
                        case DisemblWS :\r
                        case GlobPlotWS :\r
-\r
+                       case IUPredWS :\r
                                return SequenceAnnotation.class;\r
 \r
                                // deliberate leaking\r
                        case ClustalWS :\r
+                       case ClustalOWS :\r
                        case MafftWS :\r
                        case MuscleWS :\r
                        case ProbconsWS :\r
@@ -102,4 +99,122 @@ public enum Services {
                                this.toString() + "Port");\r
                return service.getPort(portName, this.getServiceType());\r
        }\r
+\r
+       public String getServiceInfo() {\r
+               switch (this) {\r
+                       case AAConWS :\r
+                               return AACON_INFO;\r
+                       case ClustalOWS :\r
+                               return CLUSTAL_OMEGA_INFO;\r
+                       case ClustalWS :\r
+                               return CLUSTAL_INFO;\r
+                       case DisemblWS :\r
+                               return DISEMBL_INFO;\r
+                       case GlobPlotWS :\r
+                               return GLOBPLOT_INFO;\r
+                       case IUPredWS :\r
+                               return IUPRED_INFO;\r
+                       case JronnWS :\r
+                               return JRONN_INFO;\r
+                       case MafftWS :\r
+                               return MAFFT_INFO;\r
+                       case MuscleWS :\r
+                               return MUSCLE_INFO;\r
+                       case ProbconsWS :\r
+                               return PROBCONS_INFO;\r
+                       case TcoffeeWS :\r
+                               return TCOFFEE_INFO;\r
+                       default :\r
+                               throw new RuntimeException("Unrecognised Web Service Type "\r
+                                               + this + " - Should never happened!");\r
+               }\r
+       }\r
+\r
+       public static final String AACON_INFO = new ServiceInfo(AAConWS,\r
+                       "in preparation", "1.0", "http://www.compbio.dundee.ac.uk/aacon")\r
+                       .toString();\r
+       public static final String CLUSTAL_INFO = new ServiceInfo(\r
+                       ClustalWS,\r
+                       "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
+                                       + "(2007). Clustal W and Clustal X version 2.0. Bioinformatics, 23, 2947-2948. ",\r
+                       "2.0.12", "http://www.clustal.org/clustal2/").toString();\r
+       public static final String CLUSTAL_OMEGA_INFO = new ServiceInfo(\r
+                       ClustalOWS,\r
+                       "Fast, scalable generation of high quality protein multiple sequence alignments using Clustal Omega\r\n"\r
+                                       + "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
+                       "1.0.2", "http://www.clustal.org/omega").toString();\r
+       public static final String DISEMBL_INFO = new ServiceInfo(\r
+                       DisemblWS,\r
+                       "R. Linding, L.J. Jensen, F. Diella, P. Bork, T.J. Gibson and R.B. Russell\r\n"\r
+                                       + "Protein disorder prediction: implications for structural proteomics\r\n"\r
+                                       + "Structure Vol 11, Issue 11, 4 November 2003", "1.5",\r
+                       "http://dis.embl.de/").toString();\r
+       public static final String GLOBPLOT_INFO = new ServiceInfo(\r
+                       GlobPlotWS,\r
+                       "Rune Linding, Robert B. Russell, Victor Neduva and Toby J. Gibson "\r
+                                       + "'GlobPlot: exploring protein sequences for globularity and disorder.' Nucl. Acids Res. (2003) 31 (13): 3701-3708. doi: 10.1093/nar/gkg519\r\n",\r
+                       "2.3", "http://globplot.embl.de/").toString();\r
+       public static final String IUPRED_INFO = new ServiceInfo(\r
+                       IUPredWS,\r
+                       "The Pairwise Energy Content Estimated from Amino Acid Composition Discriminates between Folded and Intrinsically Unstructured Proteins\r\n"\r
+                                       + "Zsuzsanna Dosztányi, Veronika Csizmók, Péter Tompa and István Simon\r\n"\r
+                                       + "J. Mol. Biol. (2005) 347, 827-839.", "1.0",\r
+                       "http://iupred.enzim.hu/").toString();\r
+       public static final String TCOFFEE_INFO = new ServiceInfo(TcoffeeWS,\r
+                       "T-Coffee: A novel method for multiple sequence alignments  "\r
+                                       + "Notredame, Higgins, Heringa, JMB, 302 (205-217) 2000",\r
+                       "8.99", "http://tcoffee.crg.cat/apps/tcoffee/index.html")\r
+                       .toString();\r
+       public static final String MUSCLE_INFO = new ServiceInfo(\r
+                       MuscleWS,\r
+                       "Edgar, R.C. (2004) MUSCLE: multiple sequence alignment with high accuracy and high throughput.Nucleic Acids Res. 32(5):1792-1797.\r\n"\r
+                                       + "doi:10.1093/nar/gkh340", "3.8.31",\r
+                       "http://www.drive5.com/muscle/").toString();\r
+       public static final String PROBCONS_INFO = new ServiceInfo(\r
+                       ProbconsWS,\r
+                       "Do, C.B., Mahabhashyam, M.S.P., Brudno, M., and Batzoglou, S. 2005. PROBCONS: "\r
+                                       + "Probabilistic Consistency-based Multiple Sequence Alignment. Genome Research 15: 330-340. ",\r
+                       "1.12", "http://probcons.stanford.edu/").toString();;\r
+       public static final String JRONN_INFO = new ServiceInfo(\r
+                       JronnWS,\r
+                       "unpublished, original algorithm Yang,Z.R., Thomson,R., McMeil,P. and Esnouf,R.M. (2005) "\r
+                                       + "RONN: the bio-basis function neural network technique applied to the "\r
+                                       + "dectection of natively disordered regions in proteins Bioinformatics 21: 3369-3376\r\n",\r
+                       "1.0", "http://www.compbio.dundee.ac.uk/jabaws/").toString();;\r
+       public static final String MAFFT_INFO = new ServiceInfo(\r
+                       MafftWS,\r
+                       "Katoh, Toh 2010 (Bioinformatics 26:1899-1900)\r\n"\r
+                                       + "Parallelization of the MAFFT multiple sequence alignment program. ",\r
+                       "6.8.57", "http://mafft.cbrc.jp/alignment/software/").toString();;\r
+\r
+       static class ServiceInfo {\r
+               Services service;\r
+               String reference;\r
+               String version;\r
+               String moreinfo;\r
+               final static String jabaws_version = "2.0";\r
+               final static String line_delimiter = "\n";\r
+\r
+               private ServiceInfo(Services service, String reference, String version,\r
+                               String moreinfo) {\r
+                       this.service = service;\r
+                       this.reference = reference;\r
+                       this.version = version;\r
+                       this.moreinfo = moreinfo;\r
+               }\r
+\r
+               @Override\r
+               public String toString() {\r
+                       String value = "SERVICE: " + service + " version " + version\r
+                                       + line_delimiter;\r
+                       value += "JABAWS v. " + jabaws_version + line_delimiter;\r
+                       value += "REFERENCES: " + reference + line_delimiter;\r
+                       value += "MORE INFORMATION: " + moreinfo + line_delimiter;\r
+                       return value;\r
+               }\r
+       }\r
+\r
+       public static void main(String[] args) {\r
+               System.out.println(MUSCLE_INFO);\r
+       }\r
 }
\ No newline at end of file