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 if (limitMan == null) {
\r
75 // Limit is not defined
\r
78 return limitMan.getLimitByName(presetName);
\r
82 public LimitsManager<GlobPlot> getLimits() {
\r
87 public ChunkHolder pullExecStatistics(String jobId, long position) {
\r
88 // Execution stat is not supported
\r
89 return new ChunkHolder("", -1);
\r
93 public boolean cancelJob(String jobId) {
\r
94 WSUtil.validateJobId(jobId);
\r
95 return WSUtil.cancelJob(jobId);
\r
99 public JobStatus getJobStatus(String jobId) {
\r
100 WSUtil.validateJobId(jobId);
\r
101 return WSUtil.getJobStatus(jobId);
\r
105 public PresetManager<GlobPlot> getPresets() {
\r
106 return globPlotPresets;
\r
110 public RunnerConfig<GlobPlot> getRunnerOptions() {
\r
111 return globPlotOptions;
\r
114 String analize(List<FastaSequence> sequences,
\r
115 ConfiguredExecutable<GlobPlot> confExec, Logger log, String method,
\r
116 Limit<GlobPlot> limit) throws JobSubmissionException {
\r
117 if (limit != null && limit.isExceeded(sequences)) {
\r
118 throw LimitExceededException.newLimitExceeded(limit, sequences);
\r
121 compbio.runner.Util.writeInput(sequences, confExec);
\r
122 AsyncExecutor engine = Configurator.getAsyncEngine(confExec);
\r
123 String jobId = engine.submitJob(confExec);
\r
128 public String analize(List<FastaSequence> sequences)
\r
129 throws UnsupportedRuntimeException, LimitExceededException,
\r
130 JobSubmissionException {
\r
131 WSUtil.validateFastaInput(sequences);
\r
132 ConfiguredExecutable<GlobPlot> confGlobPlot = init(sequences);
\r
134 return analize(sequences, confGlobPlot, null, "analize", getLimit(""));
\r
138 * No options are supported, thus the result of this call will be as simple
\r
139 * call to analize without parameters
\r
142 public String customAnalize(List<FastaSequence> sequences,
\r
143 List<Option<GlobPlot>> options) throws UnsupportedRuntimeException,
\r
144 LimitExceededException, JobSubmissionException,
\r
145 WrongParameterException {
\r
146 return analize(sequences);
\r
150 * No presets are supported, thus the result of this call will be as simple
\r
151 * call to analize without parameters
\r
154 public String presetAnalize(List<FastaSequence> sequences,
\r
155 Preset<GlobPlot> preset) throws UnsupportedRuntimeException,
\r
156 LimitExceededException, JobSubmissionException,
\r
157 WrongParameterException {
\r
159 return analize(sequences);
\r