X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=webservices%2Fcompbio%2Fws%2Fserver%2FAAConWS.java;h=e77c878f092f9d26347b46aa976c970d6c702b2e;hb=6e1c873d0879f462b1fb1a1efa444cf993a9e76a;hp=cf382df632fe821d0fb7f3cbab7bef245bc848b8;hpb=fab6bab770b548a0c99ed6f5dfb46f5aa99f67c7;p=jabaws.git diff --git a/webservices/compbio/ws/server/AAConWS.java b/webservices/compbio/ws/server/AAConWS.java index cf382df..e77c878 100644 --- a/webservices/compbio/ws/server/AAConWS.java +++ b/webservices/compbio/ws/server/AAConWS.java @@ -1,6 +1,8 @@ package compbio.ws.server; import java.io.File; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; import javax.annotation.Resource; @@ -9,11 +11,9 @@ import javax.xml.ws.WebServiceContext; import org.apache.log4j.Logger; -import compbio.conservation.Method; import compbio.data.msa.Annotation; import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.JalviewAnnotation; -import compbio.data.sequence.MultiAnnotatedSequence; +import compbio.data.sequence.Score; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; import compbio.engine.client.ConfiguredExecutable; @@ -33,7 +33,7 @@ import compbio.metadata.WrongParameterException; import compbio.runner.Util; import compbio.runner.conservation.AACon; -@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = "http://msa.data.compbio/01/01/2010/", serviceName = "MuscleWS") +@WebService(endpointInterface = "compbio.data.msa.Annotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "AAConWS") public class AAConWS implements Annotation { // Ask for resource injection @@ -53,39 +53,39 @@ public class AAConWS implements Annotation { ConfiguredExecutable init(List sequences) throws JobSubmissionException { AACon aacon = new AACon(); - aacon.setInput("fasta.in").setOutput("fasta.out"); + aacon.setInput("fasta.in").setOutput("aacon.out"); return Configurator.configureExecutable(aacon, sequences); } - @SuppressWarnings("unchecked") - public MultiAnnotatedSequence getResult(String jobId) + @Override + public HashSet getConservation(String jobId) throws ResultNotAvailableException { WSUtil.validateJobId(jobId); AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine .getResults(jobId); - MultiAnnotatedSequence mas = aacon.getResults(); - // log(jobId, "getResults"); + HashSet mas = aacon.getResults(); + log.trace(jobId + " getConservation : " + mas); return mas; } + /* + * @SuppressWarnings("unchecked") public JalviewAnnotation + * getJalviewAnnotation(String jobId) throws ResultNotAvailableException { + * MultiAnnotatedSequence result = getResult(jobId); // TODO // + * log(jobId, "getResults"); return result.toJalviewAnnotation(); } + */ - @SuppressWarnings("unchecked") - public JalviewAnnotation getJalviewAnnotation(String jobId) - throws ResultNotAvailableException { - MultiAnnotatedSequence result = getResult(jobId); - - // log(jobId, "getResults"); - return result.toJalviewAnnotation(); - } - + @Override public Limit getLimit(String presetName) { return new AACon().getLimit(presetName); } + @Override public LimitsManager getLimits() { return new AACon().getLimits(); } + @Override public ChunkHolder pullExecStatistics(String jobId, long position) { WSUtil.validateJobId(jobId); String file = Configurator.getWorkDirectory(jobId) + File.separator @@ -93,30 +93,53 @@ public class AAConWS implements Annotation { 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 aaconPresets; } + @Override public RunnerConfig getRunnerOptions() { return aaconOptions; } + 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 { - // TODO Auto-generated method stub - return null; + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confAAcon = init(sequences); + + // set default conservation method to fastest - SHENKIN + // TODO: This violates encapsulation, should be moved to the runners + // level. + confAAcon.addParameters(Arrays.asList("-m=SHENKIN")); + return analize(sequences, confAAcon, null, "analize", getLimit("")); } @Override @@ -124,8 +147,16 @@ public class AAConWS implements Annotation { List> options) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException { - // TODO Auto-generated method stub - return null; + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confAACon = init(sequences); + // Could not do that! Space separated values + // will all be treated as keys! thus duplicates removed + // String params = cbuilder.getCommand(); + List params = WSUtil.getCommands(options, + AACon.KEY_VALUE_SEPARATOR); + confAACon.addParameters(params); + return analize(sequences, confAACon, null, "customAnalize", + getLimit("")); } @Override @@ -133,8 +164,14 @@ public class AAConWS implements Annotation { Preset preset) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException { - // TODO Auto-generated method stub - return null; + WSUtil.validateFastaInput(sequences); + if (preset == null) { + throw new WrongParameterException("Preset must be provided!"); + } + ConfiguredExecutable confAAcon = init(sequences); + confAAcon.addParameters(preset.getOptions()); + Limit limit = getLimit(preset.getName()); + return WSUtil.align(sequences, confAAcon, null, "presetAnalize", limit); } }