X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FTcoffeeWS.java;h=086d870bf9594a18c931aa194f96bb36ed0cfd85;hb=d92ac5284d2c918deda443f89e60cab6f0f8667e;hp=afe2caec0158616cf053914a83213275511f2933;hpb=535359a3d592ee41bda72e7356f0181f6cee9d07;p=jabaws.git diff --git a/webservices/compbio/ws/server/TcoffeeWS.java b/webservices/compbio/ws/server/TcoffeeWS.java index afe2cae..086d870 100644 --- a/webservices/compbio/ws/server/TcoffeeWS.java +++ b/webservices/compbio/ws/server/TcoffeeWS.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,12 +21,11 @@ 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; @@ -34,6 +33,7 @@ import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; import compbio.engine.client.ConfiguredExecutable; import compbio.engine.client.Executable; +import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ChunkHolder; import compbio.metadata.JobStatus; import compbio.metadata.JobSubmissionException; @@ -48,126 +48,130 @@ import compbio.metadata.WrongParameterException; import compbio.runner.Util; import compbio.runner.msa.Tcoffee; -@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = "http://msa.data.compbio/01/01/2010/", serviceName = "TcoffeeWS") +@WebService(endpointInterface = "compbio.data.msa.MsaWS", targetNamespace = JABAService.SERVICE_NAMESPACE, serviceName = "TcoffeeWS") public class TcoffeeWS implements MsaWS { - // Ask for resource injection - @Resource - WebServiceContext wsContext; - - private static Logger statLog = Logger.getLogger("TcoffeeWS-stats"); - - private static Logger log = Logger.getLogger(TcoffeeWS.class); - - private static final RunnerConfig tcoffeeOptions = Util - .getSupportedOptions(Tcoffee.class); - - private static final PresetManager tcoffeePresets = Util - .getPresets(Tcoffee.class); - - @Override - public String align(List sequences) - throws JobSubmissionException { - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confTcoffee = init(sequences); - return WSUtil - .align(sequences, confTcoffee, null, "align", getLimit("")); - } - - ConfiguredExecutable init(List sequences) - throws JobSubmissionException { - Tcoffee tcoffee = new Tcoffee(); - tcoffee.setInput("fasta.in").setOutput("fasta.out"); - ConfiguredExecutable confCoffee = Configurator - .configureExecutable(tcoffee, sequences); - if (confCoffee.getExecProvider() == Executable.ExecProvider.Cluster) { - int clusterCpuNum = Tcoffee.getClusterCpuNum(); - if (clusterCpuNum != 0) { - tcoffee.setNCore(clusterCpuNum); - } + private static Logger log = Logger.getLogger(TcoffeeWS.class); + + private static final RunnerConfig tcoffeeOptions = Util + .getSupportedOptions(Tcoffee.class); + + private static final PresetManager tcoffeePresets = Util + .getPresets(Tcoffee.class); + + private static final LimitsManager limitMan = compbio.engine.client.Util + .getLimits(new Tcoffee().getType()); + + @Override + public String align(List sequences) + throws JobSubmissionException { + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confTcoffee = init(sequences); + return WSUtil.align(sequences, confTcoffee, log, "align", getLimit("")); } - return confCoffee; - } - - @Override - public String customAlign(List sequences, - List> options) throws JobSubmissionException, - WrongParameterException { - - WSUtil.validateFastaInput(sequences); - ConfiguredExecutable confTcoffee = init(sequences); - List params = WSUtil.getCommands(options, - Tcoffee.KEY_VALUE_SEPARATOR); - log.info("Setting parameters:" + params); - confTcoffee.addParameters(params); - return WSUtil.align(sequences, confTcoffee, 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!"); + + ConfiguredExecutable init(List sequences) + throws JobSubmissionException { + Tcoffee tcoffee = new Tcoffee(); + tcoffee.setInput(SkeletalExecutable.INPUT) + .setOutput(SkeletalExecutable.OUTPUT) + .setError(SkeletalExecutable.ERROR); + + ConfiguredExecutable confCoffee = Configurator + .configureExecutable(tcoffee, sequences); + if (confCoffee.getExecProvider() == Executable.ExecProvider.Cluster) { + int clusterCpuNum = SkeletalExecutable + .getClusterCpuNum(Tcoffee.class); + if (clusterCpuNum != 0) { + tcoffee.setNCore(clusterCpuNum); + } + } + return confCoffee; + } + + @Override + public String customAlign(List sequences, + List> options) throws JobSubmissionException, + WrongParameterException { + + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confTcoffee = init(sequences); + List params = WSUtil.getCommands(options, + Tcoffee.KEY_VALUE_SEPARATOR); + log.info("Setting parameters:" + params); + confTcoffee.addParameters(params); + return WSUtil.align(sequences, confTcoffee, 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 confTcoffee = init(sequences); + confTcoffee.addParameters(preset.getOptions()); + Limit limit = getLimit(preset.getName()); + return WSUtil.align(sequences, confTcoffee, log, "presetAlign", limit); + } + + @SuppressWarnings("unchecked") + @Override + public Alignment getResult(String jobId) throws ResultNotAvailableException { + WSUtil.validateJobId(jobId); + AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); + ConfiguredExecutable tcoffee = (ConfiguredExecutable) asyncEngine + .getResults(jobId); + Alignment al = tcoffee.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); + String file = Configurator.getWorkDirectory(jobId) + File.separator + + new Tcoffee().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 tcoffeePresets; + } + + @Override + public RunnerConfig getRunnerOptions() { + return tcoffeeOptions; } - ConfiguredExecutable confTcoffee = init(sequences); - confTcoffee.addParameters(preset.getOptions()); - Limit limit = getLimit(preset.getName()); - return WSUtil.align(sequences, confTcoffee, null, "presetAlign", limit); - } - - @SuppressWarnings("unchecked") - @Override - public Alignment getResult(String jobId) throws ResultNotAvailableException { - WSUtil.validateJobId(jobId); - AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable tcoffee = (ConfiguredExecutable) asyncEngine - .getResults(jobId); - Alignment al = tcoffee.getResults(); - //log(jobId, "getResults"); - return al; - } - - @Override - public Limit getLimit(String presetName) { - return new Tcoffee().getLimit(presetName); - } - - @Override - public LimitsManager getLimits() { - return new Tcoffee().getLimits(); - } - - @Override - public ChunkHolder pullExecStatistics(String jobId, long position) { - WSUtil.validateJobId(jobId); - String file = Configurator.getWorkDirectory(jobId) + File.separator - + new Tcoffee().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 tcoffeePresets; - } - - @Override - public RunnerConfig getRunnerOptions() { - return tcoffeeOptions; - } }