X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FJronnWS.java;h=cdc66ac24ef57e9cecaacb79e56e56560f10ac80;hb=68fe46f278b4ec408d6c68677bd56199aac749b3;hp=9f5be6363d28c31f3a40e578f0f52971ec3c0ec5;hpb=48a41a20fc325be91f8e6da1f42a75a983437b70;p=jabaws.git diff --git a/webservices/compbio/ws/server/JronnWS.java b/webservices/compbio/ws/server/JronnWS.java index 9f5be63..cdc66ac 100644 --- a/webservices/compbio/ws/server/JronnWS.java +++ b/webservices/compbio/ws/server/JronnWS.java @@ -1,168 +1,52 @@ +/* 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.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.Annotation; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.Score; -import compbio.engine.AsyncExecutor; +import compbio.data.msa.JABAService; +import compbio.data.msa.SequenceAnnotation; 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; import compbio.runner.disorder.Jronn; -@WebService(endpointInterface = "compbio.data.msa.Annotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "JronnWS") -public class JronnWS implements Annotation { - - // Ask for resource injection - @Resource - WebServiceContext wsContext; - - private static Logger statLog = Logger.getLogger("JronnWS-stats"); +@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "JronnWS") +public class JronnWS extends SequenceAnnotationService + implements + SequenceAnnotation { private static Logger log = Logger.getLogger(JronnWS.class); - private static final RunnerConfig aaconOptions = Util - .getSupportedOptions(Jronn.class); - - private static final PresetManager aaconPresets = Util - .getPresets(Jronn.class); - - ConfiguredExecutable init(List sequences) - throws JobSubmissionException { - Jronn jronn = new Jronn(); - jronn.setInput("fasta.in").setOutput("aacon.out"); - return Configurator.configureExecutable(jronn, sequences); - } - - @Override - public HashSet getAnnotation(String jobId) - throws ResultNotAvailableException { - WSUtil.validateJobId(jobId); - AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine - .getResults(jobId); - HashSet mas = aacon.getResults(); - log.trace(jobId + " getConservation : " + mas); - return mas; - } - - @Override - public Limit getLimit(String presetName) { - return new Jronn().getLimit(presetName); - } - - @Override - public LimitsManager getLimits() { - return new Jronn().getLimits(); + public JronnWS() { + super(new Jronn(), log); } @Override public ChunkHolder pullExecStatistics(String jobId, long position) { WSUtil.validateJobId(jobId); String file = Configurator.getWorkDirectory(jobId) + File.separator - + Jronn.getStatFile(); + + 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); - ConfiguredExecutable confAAcon = init(sequences); - - // set default conservation method to fastest - SHENKIN - return analize(sequences, confAAcon, null, "analize", getLimit("")); - } - - @Override - public String customAnalize(List sequences, - List> options) throws UnsupportedRuntimeException, - LimitExceededException, JobSubmissionException, - WrongParameterException { - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confJronn = 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); - confJronn.addParameters(params); - return analize(sequences, confJronn, null, "customAnalize", - getLimit("")); - } - - @Override - public String presetAnalize(List sequences, - Preset preset) throws UnsupportedRuntimeException, - LimitExceededException, JobSubmissionException, - WrongParameterException { - WSUtil.validateFastaInput(sequences); - if (preset == null) { - throw new WrongParameterException("Preset must be provided!"); - } - ConfiguredExecutable confJronn = init(sequences); - confJronn.addParameters(preset.getOptions()); - Limit limit = getLimit(preset.getName()); - return WSUtil.align(sequences, confJronn, null, "presetAnalize", limit); - } - }