JWS-113 Commented Jpred entries in the datamodel, runner and webservices java source...
[jabaws.git] / webservices / compbio / ws / client / ServicesUtil.java
1 package compbio.ws.client;\r
2 \r
3 import java.io.File;\r
4 \r
5 import compbio.engine.client.ConfExecutable;\r
6 import compbio.engine.client.Executable;\r
7 import compbio.runner.conservation.AACon;\r
8 //import compbio.runner.predictors.Jpred;\r
9 import compbio.runner.disorder.Disembl;\r
10 import compbio.runner.disorder.GlobPlot;\r
11 import compbio.runner.disorder.IUPred;\r
12 import compbio.runner.disorder.Jronn;\r
13 import compbio.runner.msa.ClustalO;\r
14 import compbio.runner.msa.ClustalW;\r
15 import compbio.runner.msa.Mafft;\r
16 import compbio.runner.msa.Muscle;\r
17 import compbio.runner.msa.Probcons;\r
18 import compbio.runner.msa.MSAprobs;\r
19 import compbio.runner.msa.GLprobs;\r
20 import compbio.runner.msa.Tcoffee;\r
21 import compbio.runner.structure.RNAalifold;\r
22 \r
23 public class ServicesUtil {\r
24 \r
25         public static Services getServiceByRunner(Class<? extends Executable> class1) {\r
26                 assert class1 != null;\r
27                 String sname = class1.getSimpleName().toLowerCase();\r
28                 for (Services service : Services.values()) {\r
29                         if (service.toString().toLowerCase().contains(sname)) {\r
30                                 return service;\r
31                         }\r
32                 }\r
33                 return null;\r
34         }\r
35 \r
36         private static Class<? extends Executable<?>> getServiceImpl(Services service) {\r
37                 switch (service) {\r
38                         case AAConWS :\r
39                                 return AACon.class;\r
40 //                      case JpredWS :\r
41 //                              return Jpred.class;\r
42                         case ClustalOWS :\r
43                                 return ClustalO.class;\r
44                         case ClustalWS :\r
45                                 return ClustalW.class;\r
46                         case MafftWS :\r
47                                 return Mafft.class;\r
48                         case MuscleWS :\r
49                                 return Muscle.class;\r
50                         case TcoffeeWS :\r
51                                 return Tcoffee.class;\r
52                         case ProbconsWS :\r
53                                 return Probcons.class;\r
54                         case MSAprobsWS :\r
55                                 return MSAprobs.class;\r
56                         case GLprobsWS :\r
57                                 return GLprobs.class;\r
58                         case DisemblWS :\r
59                                 return Disembl.class;\r
60                         case GlobPlotWS :\r
61                                 return GlobPlot.class;\r
62                         case JronnWS :\r
63                                 return Jronn.class;\r
64                         case IUPredWS :\r
65                                 return IUPred.class;\r
66                         case RNAalifoldWS :\r
67                                 return RNAalifold.class;\r
68                         default :\r
69                                 throw new RuntimeException("Unknown web service implementation class for service: " + service);\r
70                 }\r
71         }\r
72 \r
73         public static Class<? extends Executable<?>> getRunnerByJobDirectory(File jobdir) {\r
74                 Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));\r
75                 return getServiceImpl(service);\r
76         }\r
77 \r
78         private static String getRunnerNameByJobDirectory(File jobdir) {\r
79                 String name = jobdir.getName().split("#")[0];\r
80 \r
81                 if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) {\r
82                         assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1;\r
83                         name = name.substring(1);\r
84                 }\r
85                 return name;\r
86         }\r
87 \r
88         public static Services getServiceByJobDirectory(File jobdir) {\r
89                 return getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));\r
90         }\r
91 \r
92         private static Services getServiceByRunnerName(String name) {\r
93                 for (Services service : Services.values()) {\r
94                         String runnerName = getServiceImpl(service).getSimpleName().toLowerCase();\r
95                         name = name.trim().toLowerCase();\r
96                         if (name.startsWith(runnerName)) {\r
97                                 return service;\r
98                         }\r
99                 }\r
100                 return null;\r
101         }\r
102 \r
103 }\r