X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FProbconsWS.java;h=d4fa3df27be0b801740902f6de75f9474f5ae4de;hb=4c022b67a736b6f79dbe212d73016607cf298422;hp=8060be6273ef2d38a7dc387c7ff78caae375856f;hpb=535359a3d592ee41bda72e7356f0181f6cee9d07;p=jabaws.git diff --git a/webservices/compbio/ws/server/ProbconsWS.java b/webservices/compbio/ws/server/ProbconsWS.java index 8060be6..d4fa3df 100644 --- a/webservices/compbio/ws/server/ProbconsWS.java +++ b/webservices/compbio/ws/server/ProbconsWS.java @@ -1,6 +1,6 @@ -/* Copyright (c) 2009 Peter Troshin +/* Copyright (c) 2011 Peter Troshin * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 + * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -21,18 +21,18 @@ package compbio.ws.server; import java.io.File; 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.JABAService; import compbio.data.msa.MsaWS; import compbio.data.sequence.Alignment; import compbio.data.sequence.FastaSequence; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; import compbio.engine.client.ConfiguredExecutable; +import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ChunkHolder; import compbio.metadata.JobStatus; import compbio.metadata.JobSubmissionException; @@ -47,116 +47,110 @@ import compbio.metadata.WrongParameterException; import compbio.runner.Util; import compbio.runner.msa.Probcons; -@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = "http://msa.data.compbio/01/01/2010/", serviceName = "ProbconsWS") +@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = JABAService.SERVICE_NAMESPACE, serviceName = "ProbconsWS") public class ProbconsWS implements MsaWS { - // Ask for resource injection - @Resource - WebServiceContext wsContext; - - private static Logger statLog = Logger.getLogger("ProbconsWS-stats"); - - private static Logger log = Logger.getLogger(ProbconsWS.class); - - private static final RunnerConfig probconsOptions = Util - .getSupportedOptions(Probcons.class); - - @Override - public String align(List sequences) - throws JobSubmissionException { - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confProbcons = init(sequences); - return WSUtil.align(sequences, confProbcons, null, "align", - getLimit("")); - } - - ConfiguredExecutable init(List dataSet) - throws JobSubmissionException { - Probcons probcons = new Probcons(); - probcons.setInput("fasta.in").setOutput("alignment.out"); - return Configurator.configureExecutable(probcons, dataSet); - } - - @Override - public String customAlign(List sequences, - List> options) throws JobSubmissionException, - WrongParameterException { - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confProbcons = init(sequences); - List params = WSUtil.getCommands(options, - Probcons.KEY_VALUE_SEPARATOR); - log.info("Setting parameters:" + params); - confProbcons.addParameters(params); - return WSUtil.align(sequences, confProbcons, null, "customAlign", - getLimit("")); - } - - @Override - public String presetAlign(List sequences, - Preset preset) throws JobSubmissionException, - WrongParameterException { - WSUtil.validateFastaInput(sequences); - if (preset == null) { - throw new WrongParameterException("Preset must be provided!"); + private static Logger log = Logger.getLogger(ProbconsWS.class); + + private static final RunnerConfig probconsOptions = Util.getSupportedOptions(Probcons.class); + private static final LimitsManager limitMan = compbio.engine.client.Util.getLimits(new Probcons().getType()); + + @Override + public String align(List sequences) + throws JobSubmissionException { + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confProbcons = init(sequences); + return WSUtil.align(sequences, confProbcons, log, "align", getLimit("")); + } + + ConfiguredExecutable init(List dataSet) + throws JobSubmissionException { + Probcons probcons = new Probcons(); + probcons.setInput(SkeletalExecutable.INPUT); + probcons.setOutput(SkeletalExecutable.OUTPUT); + probcons.setError(SkeletalExecutable.ERROR); + return Configurator.configureExecutable(probcons, dataSet); + } + + @Override + public String customAlign(List sequences, + List> options) throws JobSubmissionException, + WrongParameterException { + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confProbcons = init(sequences); + List params = WSUtil.getCommands(options, Probcons.KEY_VALUE_SEPARATOR); + log.info("Setting parameters:" + params); + confProbcons.addParameters(params); + return WSUtil.align(sequences, confProbcons, log, "customAlign",getLimit("")); + } + + @Override + public String presetAlign(List sequences, + Preset preset) throws JobSubmissionException, + WrongParameterException { + WSUtil.validateFastaInput(sequences); + if (preset == null) { + throw new WrongParameterException("Preset must be provided!"); + } + ConfiguredExecutable confProbcons = init(sequences); + confProbcons.addParameters(preset.getOptions()); + Limit limit = getLimit(preset.getName()); + return WSUtil.align(sequences, confProbcons, log, "presetAlign", limit); + } + + @SuppressWarnings("unchecked") + @Override + public Alignment getResult(String jobId) throws ResultNotAvailableException { + WSUtil.validateJobId(jobId); + AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); + ConfiguredExecutable probcons = (ConfiguredExecutable) asyncEngine.getResults(jobId); + Alignment al = probcons.getResults(); + // log(jobId, "getResults"); + return al; + } + + @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) { + WSUtil.validateJobId(jobId); + // TODO check if output is the one to return + String file = Configurator.getWorkDirectory(jobId) + File.separator + new Probcons().getError(); + return WSUtil.pullFile(file, position); + } + + @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 null; + } + + @Override + public RunnerConfig getRunnerOptions() { + return probconsOptions; } - ConfiguredExecutable confProbcons = init(sequences); - confProbcons.addParameters(preset.getOptions()); - Limit limit = getLimit(preset.getName()); - return WSUtil - .align(sequences, confProbcons, null, "presetAlign", limit); - } - - @SuppressWarnings("unchecked") - @Override - public Alignment getResult(String jobId) throws ResultNotAvailableException { - WSUtil.validateJobId(jobId); - AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable probcons = (ConfiguredExecutable) asyncEngine - .getResults(jobId); - Alignment al = probcons.getResults(); - //log(jobId, "getResults"); - return al; - } - - @Override - public Limit getLimit(String presetName) { - return new Probcons().getLimit(presetName); - } - - @Override - public LimitsManager getLimits() { - return new Probcons().getLimits(); - } - - @Override - public ChunkHolder pullExecStatistics(String jobId, long position) { - WSUtil.validateJobId(jobId); - // TODO check if output is the one to return - String file = Configurator.getWorkDirectory(jobId) + File.separator - + new Probcons().getError(); - return WSUtil.pullFile(file, position); - } - - @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 null; - } - - @Override - public RunnerConfig getRunnerOptions() { - return probconsOptions; - } }