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 globPlot.setInput("fasta.in").setOutput("globPlot.out");
\r
57 return Configurator.configureExecutable(globPlot, sequences);
\r
61 public ScoreManager getAnnotation(String jobId)
\r
62 throws ResultNotAvailableException {
\r
63 WSUtil.validateJobId(jobId);
\r
64 AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);
\r
65 ConfiguredExecutable<GlobPlot> globPlot = (ConfiguredExecutable<GlobPlot>) asyncEngine
\r
67 ScoreManager mas = globPlot.getResults();
\r
68 log.trace(jobId + " getConservation : " + mas);
\r
73 public Limit<GlobPlot> getLimit(String presetName) {
\r
74 return limitMan.getLimitByName(presetName);
\r
78 public LimitsManager<GlobPlot> getLimits() {
\r
83 public ChunkHolder pullExecStatistics(String jobId, long position) {
\r
84 // Execution stat is not supported
\r
85 return new ChunkHolder("", -1);
\r
89 public boolean cancelJob(String jobId) {
\r
90 WSUtil.validateJobId(jobId);
\r
91 return WSUtil.cancelJob(jobId);
\r
95 public JobStatus getJobStatus(String jobId) {
\r
96 WSUtil.validateJobId(jobId);
\r
97 return WSUtil.getJobStatus(jobId);
\r
101 public PresetManager<GlobPlot> getPresets() {
\r
102 return globPlotPresets;
\r
106 public RunnerConfig<GlobPlot> getRunnerOptions() {
\r
107 return globPlotOptions;
\r
110 String analize(List<FastaSequence> sequences,
\r
111 ConfiguredExecutable<GlobPlot> confExec, Logger log, String method,
\r
112 Limit<GlobPlot> limit) throws JobSubmissionException {
\r
113 if (limit != null && limit.isExceeded(sequences)) {
\r
114 throw LimitExceededException.newLimitExceeded(limit, sequences);
\r
117 compbio.runner.Util.writeInput(sequences, confExec);
\r
118 AsyncExecutor engine = Configurator.getAsyncEngine(confExec);
\r
119 String jobId = engine.submitJob(confExec);
\r
124 public String analize(List<FastaSequence> sequences)
\r
125 throws UnsupportedRuntimeException, LimitExceededException,
\r
126 JobSubmissionException {
\r
127 WSUtil.validateFastaInput(sequences);
\r
128 ConfiguredExecutable<GlobPlot> confGlobPlot = init(sequences);
\r
130 return analize(sequences, confGlobPlot, null, "analize", getLimit(""));
\r
134 * No options are supported, thus the result of this call will be as simple
\r
135 * call to analize without parameters
\r
138 public String customAnalize(List<FastaSequence> sequences,
\r
139 List<Option<GlobPlot>> options) throws UnsupportedRuntimeException,
\r
140 LimitExceededException, JobSubmissionException,
\r
141 WrongParameterException {
\r
142 return analize(sequences);
\r
146 * No presets are supported, thus the result of this call will be as simple
\r
147 * call to analize without parameters
\r
150 public String presetAnalize(List<FastaSequence> sequences,
\r
151 Preset<GlobPlot> preset) throws UnsupportedRuntimeException,
\r
152 LimitExceededException, JobSubmissionException,
\r
153 WrongParameterException {
\r
155 return analize(sequences);
\r