Fix problem with the JpredWS service. Now Jws2Client is able to test the service
[jabaws.git] / webservices / compbio / ws / server / AAConWS.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 package compbio.ws.server;\r
19 \r
20 import java.io.File;\r
21 import java.util.Arrays;\r
22 import java.util.List;\r
23 \r
24 import javax.jws.WebService;\r
25 \r
26 import org.apache.log4j.Logger;\r
27 \r
28 import compbio.data.msa.JABAService;\r
29 import compbio.data.msa.SequenceAnnotation;\r
30 import compbio.data.sequence.FastaSequence;\r
31 import compbio.engine.Configurator;\r
32 import compbio.engine.client.ConfiguredExecutable;\r
33 import compbio.metadata.ChunkHolder;\r
34 import compbio.metadata.JobSubmissionException;\r
35 import compbio.metadata.LimitExceededException;\r
36 import compbio.metadata.Option;\r
37 import compbio.metadata.Preset;\r
38 import compbio.metadata.UnsupportedRuntimeException;\r
39 import compbio.metadata.WrongParameterException;\r
40 import compbio.runner.conservation.AACon;\r
41 \r
42 @WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "AAConWS")\r
43 public class AAConWS extends SequenceAnnotationService<AACon>\r
44                 implements\r
45                         SequenceAnnotation<AACon> {\r
46 \r
47         private static Logger log = Logger.getLogger(AAConWS.class);\r
48 \r
49         public AAConWS() {\r
50                 super(new AACon(), log);\r
51         }\r
52 \r
53         /*\r
54          * @SuppressWarnings("unchecked") public JalviewAnnotation\r
55          * getJalviewAnnotation(String jobId) throws ResultNotAvailableException {\r
56          * MultiAnnotatedSequence<Method> result = getResult(jobId); // TODO //\r
57          * log(jobId, "getResults"); return result.toJalviewAnnotation(); }\r
58          */\r
59 \r
60         @Override\r
61         public String analize(List<FastaSequence> sequences)\r
62                         throws UnsupportedRuntimeException, LimitExceededException,\r
63                         JobSubmissionException {\r
64                 WSUtil.validateAAConInput(sequences);\r
65                 ConfiguredExecutable<AACon> confAAcon = init(sequences);\r
66 \r
67                 // set default conservation method to fastest - SHENKIN\r
68                 // TODO: This violates encapsulation, should be moved to the runners\r
69                 // level.\r
70                 confAAcon.addParameters(Arrays.asList("-m=SHENKIN"));\r
71                 return WSUtil.analize(sequences, confAAcon, log, "AAConWS analize",\r
72                                 getLimit(""));\r
73         }\r
74 \r
75         @Override\r
76         public String customAnalize(List<FastaSequence> sequences,\r
77                         List<Option<AACon>> options) throws UnsupportedRuntimeException,\r
78                         LimitExceededException, JobSubmissionException,\r
79                         WrongParameterException {\r
80                 WSUtil.validateAAConInput(sequences);\r
81                 return super.customAnalize(sequences, options);\r
82         }\r
83 \r
84         @Override\r
85         public String presetAnalize(List<FastaSequence> sequences,\r
86                         Preset<AACon> preset) throws UnsupportedRuntimeException,\r
87                         LimitExceededException, JobSubmissionException,\r
88                         WrongParameterException {\r
89                 WSUtil.validateAAConInput(sequences);\r
90                 return super.presetAnalize(sequences, preset);\r
91         }\r
92 \r
93         @Override\r
94         public ChunkHolder pullExecStatistics(String jobId, long position) {\r
95                 WSUtil.validateJobId(jobId);\r
96                 String file = Configurator.getWorkDirectory(jobId) + File.separator\r
97                                 + AACon.getStatFile();\r
98                 return WSUtil.pullFile(file, position);\r
99         }\r
100 \r
101 }\r