1 package compbio.ws.server;
\r
3 import java.util.List;
\r
5 import javax.annotation.Resource;
\r
6 import javax.jws.WebService;
\r
7 import javax.xml.ws.WebServiceContext;
\r
9 import org.apache.log4j.Logger;
\r
11 import compbio.data.msa.SequenceAnnotation;
\r
12 import compbio.data.sequence.FastaSequence;
\r
13 import compbio.data.sequence.ScoreManager;
\r
14 import compbio.engine.AsyncExecutor;
\r
15 import compbio.engine.Configurator;
\r
16 import compbio.engine.client.ConfiguredExecutable;
\r
17 import compbio.metadata.ChunkHolder;
\r
18 import compbio.metadata.JobStatus;
\r
19 import compbio.metadata.JobSubmissionException;
\r
20 import compbio.metadata.Limit;
\r
21 import compbio.metadata.LimitExceededException;
\r
22 import compbio.metadata.LimitsManager;
\r
23 import compbio.metadata.Option;
\r
24 import compbio.metadata.Preset;
\r
25 import compbio.metadata.PresetManager;
\r
26 import compbio.metadata.ResultNotAvailableException;
\r
27 import compbio.metadata.RunnerConfig;
\r
28 import compbio.metadata.UnsupportedRuntimeException;
\r
29 import compbio.metadata.WrongParameterException;
\r
30 import compbio.runner.Util;
\r
31 import compbio.runner.disorder.GlobPlot;
\r
33 @WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "GlobPlotWS")
\r
34 public class GlobPlotWS implements SequenceAnnotation<GlobPlot> {
\r
36 // Ask for resource injection
\r
38 WebServiceContext wsContext;
\r
40 private static Logger statLog = Logger.getLogger("GlobPlotWS-stats");
\r
42 private static Logger log = Logger.getLogger(GlobPlotWS.class);
\r
44 private static final RunnerConfig<GlobPlot> globPlotOptions = Util
\r
45 .getSupportedOptions(GlobPlot.class);
\r
47 private static final PresetManager<GlobPlot> globPlotPresets = Util
\r
48 .getPresets(GlobPlot.class);
\r
50 private static final LimitsManager<GlobPlot> limitMan = compbio.runner.Util
\r
51 .getLimits(new GlobPlot().getType());
\r
53 ConfiguredExecutable<GlobPlot> init(List<FastaSequence> sequences)
\r
54 throws JobSubmissionException {
\r
55 GlobPlot globPlot = new GlobPlot();
\r
56 return Configurator.configureExecutable(globPlot, sequences);
\r
60 public ScoreManager getAnnotation(String jobId)
\r
61 throws ResultNotAvailableException {
\r
62 WSUtil.validateJobId(jobId);
\r
63 AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);
\r
64 ConfiguredExecutable<GlobPlot> globPlot = (ConfiguredExecutable<GlobPlot>) asyncEngine
\r
66 ScoreManager mas = globPlot.getResults();
\r
67 log.trace(jobId + " getConservation : " + mas);
\r
72 public Limit<GlobPlot> getLimit(String presetName) {
\r
73 if (limitMan == null) {
\r
74 // Limit is not defined
\r
77 return limitMan.getLimitByName(presetName);
\r
81 public LimitsManager<GlobPlot> getLimits() {
\r
86 public ChunkHolder pullExecStatistics(String jobId, long position) {
\r
87 // Execution stat is not supported
\r
88 return new ChunkHolder("", -1);
\r
92 public boolean cancelJob(String jobId) {
\r
93 WSUtil.validateJobId(jobId);
\r
94 return WSUtil.cancelJob(jobId);
\r
98 public JobStatus getJobStatus(String jobId) {
\r
99 WSUtil.validateJobId(jobId);
\r
100 return WSUtil.getJobStatus(jobId);
\r
104 public PresetManager<GlobPlot> getPresets() {
\r
105 return globPlotPresets;
\r
109 public RunnerConfig<GlobPlot> getRunnerOptions() {
\r
110 return globPlotOptions;
\r
113 String analize(List<FastaSequence> sequences,
\r
114 ConfiguredExecutable<GlobPlot> confExec, Logger log, String method,
\r
115 Limit<GlobPlot> limit) throws JobSubmissionException {
\r
116 if (limit != null && limit.isExceeded(sequences)) {
\r
117 throw LimitExceededException.newLimitExceeded(limit, sequences);
\r
120 compbio.runner.Util.writeInput(sequences, confExec);
\r
121 AsyncExecutor engine = Configurator.getAsyncEngine(confExec);
\r
122 String jobId = engine.submitJob(confExec);
\r
127 public String analize(List<FastaSequence> sequences)
\r
128 throws UnsupportedRuntimeException, LimitExceededException,
\r
129 JobSubmissionException {
\r
130 WSUtil.validateFastaInput(sequences);
\r
131 ConfiguredExecutable<GlobPlot> confGlobPlot = init(sequences);
\r
133 return analize(sequences, confGlobPlot, null, "analize", getLimit(""));
\r
137 * No options are supported, thus the result of this call will be as simple
\r
138 * call to analize without parameters
\r
141 public String customAnalize(List<FastaSequence> sequences,
\r
142 List<Option<GlobPlot>> options) throws UnsupportedRuntimeException,
\r
143 LimitExceededException, JobSubmissionException,
\r
144 WrongParameterException {
\r
145 return analize(sequences);
\r
149 * No presets are supported, thus the result of this call will be as simple
\r
150 * call to analize without parameters
\r
153 public String presetAnalize(List<FastaSequence> sequences,
\r
154 Preset<GlobPlot> preset) throws UnsupportedRuntimeException,
\r
155 LimitExceededException, JobSubmissionException,
\r
156 WrongParameterException {
\r
158 return analize(sequences);
\r