package compbio.ws.server; import java.util.List; import javax.annotation.Resource; import javax.jws.WebService; import javax.xml.ws.WebServiceContext; import org.apache.log4j.Logger; import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.ScoreManager; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; import compbio.engine.client.ConfiguredExecutable; import compbio.metadata.ChunkHolder; import compbio.metadata.JobStatus; import compbio.metadata.JobSubmissionException; import compbio.metadata.Limit; import compbio.metadata.LimitExceededException; import compbio.metadata.LimitsManager; import compbio.metadata.Option; import compbio.metadata.Preset; import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.RunnerConfig; import compbio.metadata.UnsupportedRuntimeException; import compbio.metadata.WrongParameterException; import compbio.runner.Util; import compbio.runner.disorder.GlobPlot; @WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "GlobPlotWS") public class GlobPlotWS implements SequenceAnnotation { // Ask for resource injection @Resource WebServiceContext wsContext; private static Logger statLog = Logger.getLogger("GlobPlotWS-stats"); private static Logger log = Logger.getLogger(GlobPlotWS.class); private static final RunnerConfig globPlotOptions = Util .getSupportedOptions(GlobPlot.class); private static final PresetManager globPlotPresets = Util .getPresets(GlobPlot.class); private static final LimitsManager limitMan = compbio.engine.client.Util .getLimits(new GlobPlot().getType()); ConfiguredExecutable init(List sequences) throws JobSubmissionException { GlobPlot globPlot = new GlobPlot(); return Configurator.configureExecutable(globPlot, sequences); } @Override public ScoreManager getAnnotation(String jobId) throws ResultNotAvailableException { WSUtil.validateJobId(jobId); AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); ConfiguredExecutable globPlot = (ConfiguredExecutable) asyncEngine .getResults(jobId); ScoreManager mas = globPlot.getResults(); log.trace(jobId + " getConservation : " + mas); return mas; } @Override public Limit getLimit(String presetName) { if (limitMan == null) { // Limit is not defined return null; } return limitMan.getLimitByName(presetName); } @Override public LimitsManager getLimits() { return limitMan; } @Override public ChunkHolder pullExecStatistics(String jobId, long position) { // Execution stat is not supported return new ChunkHolder("", -1); } @Override public boolean cancelJob(String jobId) { WSUtil.validateJobId(jobId); return WSUtil.cancelJob(jobId); } @Override public JobStatus getJobStatus(String jobId) { WSUtil.validateJobId(jobId); return WSUtil.getJobStatus(jobId); } @Override public PresetManager getPresets() { return globPlotPresets; } @Override public RunnerConfig getRunnerOptions() { return globPlotOptions; } String analize(List sequences, ConfiguredExecutable confExec, Logger log, String method, Limit limit) throws JobSubmissionException { if (limit != null && limit.isExceeded(sequences)) { throw LimitExceededException.newLimitExceeded(limit, sequences); } compbio.runner.Util.writeInput(sequences, confExec); AsyncExecutor engine = Configurator.getAsyncEngine(confExec); String jobId = engine.submitJob(confExec); return jobId; } @Override public String analize(List sequences) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException { WSUtil.validateFastaInput(sequences); ConfiguredExecutable confGlobPlot = init(sequences); return analize(sequences, confGlobPlot, null, "analize", getLimit("")); } /* * No options are supported, thus the result of this call will be as simple * call to analize without parameters */ @Override public String customAnalize(List sequences, List> options) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException { return analize(sequences); } /* * No presets are supported, thus the result of this call will be as simple * call to analize without parameters */ @Override public String presetAnalize(List sequences, Preset preset) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException { return analize(sequences); } }