X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FAAConWS.java;h=8dce707d0cbbf8a6fb314fe083bc677b22b52656;hb=5578f2d3e8226bd931755da3feeecb91fdb26c3f;hp=095bc4ede36e4669182c60a20c8329cf1024c8d0;hpb=9d860c3793c6812f643caa01fc80a0036fa3fe2b;p=jabaws.git diff --git a/webservices/compbio/ws/server/AAConWS.java b/webservices/compbio/ws/server/AAConWS.java index 095bc4e..8dce707 100644 --- a/webservices/compbio/ws/server/AAConWS.java +++ b/webservices/compbio/ws/server/AAConWS.java @@ -1,77 +1,55 @@ +/* Copyright (c) 2011 Peter Troshin + * + * 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 + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache + * License for more details. + * + * A copy of the license is in apache_license.txt. It is also available here: + * @see: http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Any republication or derived work distributed in source code form + * must include this copyright and license notice. + */ package compbio.ws.server; import java.io.File; import java.util.Arrays; -import java.util.HashSet; 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.SequenceAnnotation; import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.Score; -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.conservation.AACon; -@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "AAConWS") -public class AAConWS implements SequenceAnnotation { - - // Ask for resource injection - @Resource - WebServiceContext wsContext; - - private static Logger statLog = Logger.getLogger("AAConWS-stats"); +@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "AAConWS") +public class AAConWS extends SequenceAnnotationService + implements + SequenceAnnotation { private static Logger log = Logger.getLogger(AAConWS.class); - private static final RunnerConfig aaconOptions = Util - .getSupportedOptions(AACon.class); - - private static final PresetManager aaconPresets = Util - .getPresets(AACon.class); - - ConfiguredExecutable init(List sequences) - throws JobSubmissionException { - AACon aacon = new AACon(); - aacon.setInput("fasta.in").setOutput("aacon.out"); - return Configurator.configureExecutable(aacon, sequences); + public AAConWS() { + super(new AACon(), log); } - @Override - public ScoreManager getAnnotation(String jobId) - throws ResultNotAvailableException { - WSUtil.validateJobId(jobId); - AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine - .getResults(jobId); - HashSet mas = aacon.getResults(); - // ScoreManager result = new HashMap>(); - // result.put("Alignment", mas); - log.trace(jobId + " getConservation : " + mas); - // FIXME - return null; - } /* * @SuppressWarnings("unchecked") public JalviewAnnotation * getJalviewAnnotation(String jobId) throws ResultNotAvailableException { @@ -80,70 +58,18 @@ public class AAConWS implements SequenceAnnotation { */ @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 - + AACon.getStatFile(); - 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 { - WSUtil.validateFastaInput(sequences); + WSUtil.validateAAConInput(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("")); + return WSUtil.analize(sequences, confAAcon, log, "AAConWS analize", + getLimit("")); } @Override @@ -151,16 +77,8 @@ public class AAConWS implements SequenceAnnotation { List> options) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException { - 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("")); + WSUtil.validateAAConInput(sequences); + return super.customAnalize(sequences, options); } @Override @@ -168,14 +86,16 @@ public class AAConWS implements SequenceAnnotation { Preset preset) throws UnsupportedRuntimeException, LimitExceededException, JobSubmissionException, WrongParameterException { - 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); + WSUtil.validateAAConInput(sequences); + return super.presetAnalize(sequences, preset); + } + + @Override + public ChunkHolder pullExecStatistics(String jobId, long position) { + WSUtil.validateJobId(jobId); + String file = Configurator.getWorkDirectory(jobId) + File.separator + + AACon.getStatFile(); + return WSUtil.pullFile(file, position); } }