Fix problem with path to the UNIREF database
[jabaws.git] / webservices / compbio / ws / server / JpredWS.java
1 /* Copyright (c) 2011 Peter Troshin\r
2  * Copyright (c) 2013 Alexander Sherstnev\r
3  *  \r
4  *  JAva Bioinformatics Analysis Web Services (JABAWS)\r
5  *  @version: 2.5     \r
6  * \r
7  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
8  *  Apache License version 2 as published by the Apache Software Foundation\r
9  * \r
10  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
11  *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
12  *  License for more details.\r
13  * \r
14  *  A copy of the license is in apache_license.txt. It is also available here:\r
15  * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
16  * \r
17  * Any republication or derived work distributed in source code form\r
18  * must include this copyright and license notice.\r
19  */\r
20 package compbio.ws.server;\r
21 \r
22 import java.io.File;\r
23 import java.util.List;\r
24 \r
25 import javax.jws.WebService;\r
26 \r
27 import org.apache.log4j.Logger;\r
28 \r
29 import compbio.data.msa.JABAService;\r
30 import compbio.data.msa.SequenceAnnotation;\r
31 import compbio.data.sequence.FastaSequence;\r
32 import compbio.engine.Configurator;\r
33 import compbio.engine.client.ConfiguredExecutable;\r
34 import compbio.metadata.ChunkHolder;\r
35 import compbio.metadata.JobSubmissionException;\r
36 import compbio.metadata.LimitExceededException;\r
37 import compbio.metadata.Option;\r
38 import compbio.metadata.Preset;\r
39 import compbio.metadata.UnsupportedRuntimeException;\r
40 import compbio.metadata.WrongParameterException;\r
41 import compbio.runner.predictors.Jpred;\r
42 \r
43 @WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "JpredWS")\r
44 public class JpredWS extends SequenceAnnotationService<Jpred>\r
45                 implements SequenceAnnotation<Jpred> {\r
46 \r
47         private static Logger log = Logger.getLogger(JpredWS.class);\r
48 \r
49         public JpredWS() {\r
50                 super(new Jpred(), log);\r
51         }\r
52 \r
53         @Override\r
54         public String analize(List<FastaSequence> sequences)\r
55                         throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException {\r
56                 WSUtil.validateJpredInput(sequences);\r
57                 ConfiguredExecutable<Jpred> confpred = init(sequences);\r
58 \r
59                 // set default conservation method to fastest - SHENKIN\r
60                 // TODO: This violates encapsulation, should be moved to the runners\r
61                 // level.\r
62                 //confpred.addParameters(Arrays.asList("-m=SHENKIN"));\r
63                 return WSUtil.analize(sequences, confpred, log, "JpredWS analize", getLimit(""));\r
64         }\r
65 \r
66         @Override\r
67         public String customAnalize(List<FastaSequence> sequences, List<Option<Jpred>> options) \r
68                                         throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException {\r
69                 WSUtil.validateJpredInput(sequences);\r
70                 return super.customAnalize(sequences, options);\r
71         }\r
72 \r
73         @Override\r
74         public String presetAnalize(List<FastaSequence> sequences, Preset<Jpred> preset)\r
75                         throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException {\r
76                 WSUtil.validateJpredInput(sequences);\r
77                 return super.presetAnalize(sequences, preset);\r
78         }\r
79 \r
80         @Override\r
81         public ChunkHolder pullExecStatistics(String jobId, long position) {\r
82                 WSUtil.validateJobId(jobId);\r
83                 String file = Configurator.getWorkDirectory(jobId) + File.separator + Jpred.getStatFile();\r
84                 return WSUtil.pullFile(file, position);\r
85         }\r
86 \r
87 }\r