+++ /dev/null
-/* Copyright (c) 2011 Peter Troshin\r
- * \r
- * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 \r
- * \r
- * This library is free software; you can redistribute it and/or modify it under the terms of the\r
- * Apache License version 2 as published by the Apache Software Foundation\r
- * \r
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
- * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
- * License for more details.\r
- * \r
- * A copy of the license is in apache_license.txt. It is also available here:\r
- * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
- * \r
- * Any republication or derived work distributed in source code form\r
- * must include this copyright and license notice.\r
- */\r
-package compbio.ws.server;\r
-\r
-import java.io.File;\r
-import java.util.List;\r
-\r
-import org.apache.log4j.Logger;\r
-\r
-import compbio.data.sequence.Alignment;\r
-import compbio.data.sequence.FastaSequence;\r
-import compbio.engine.AsyncExecutor;\r
-import compbio.engine.Configurator;\r
-import compbio.engine.client.ConfiguredExecutable;\r
-import compbio.engine.client.SkeletalExecutable;\r
-import compbio.metadata.ChunkHolder;\r
-import compbio.metadata.JobSubmissionException;\r
-import compbio.metadata.Limit;\r
-import compbio.metadata.Option;\r
-import compbio.metadata.Preset;\r
-import compbio.metadata.ResultNotAvailableException;\r
-import compbio.metadata.WrongParameterException;\r
-import compbio.runner.msa.ClustalW;\r
-\r
-/**\r
- * \r
- * TODO to complete after the approach is tested with SequenceAnnotation!\r
- * \r
- * Common methods for all SequenceAnnotation web services\r
- * \r
- * @author pvtroshin\r
- * \r
- * @param <T>\r
- * \r
- * @version 1.0 June 2011\r
- * @since 2.0\r
- */\r
-public abstract class _MsaService<T> extends GenericMetadataService {\r
-\r
- /*\r
- * FIXME - instances of the Runner (?) and their types should be defined in\r
- * Executable IF\r
- */\r
- _MsaService(SkeletalExecutable<T> exec, Logger log) {\r
- super(exec, log);\r
- }\r
-\r
- public String align(List<FastaSequence> sequences)\r
- throws JobSubmissionException {\r
-\r
- WSUtil.validateFastaInput(sequences);\r
- ConfiguredExecutable<T> confClust = init(sequences);\r
- return WSUtil.align(sequences, confClust, log, "align", getLimit(""));\r
- }\r
-\r
- public String presetAlign(List<FastaSequence> sequences, Preset<T> preset)\r
- throws JobSubmissionException, WrongParameterException {\r
- WSUtil.validateFastaInput(sequences);\r
- if (preset == null) {\r
- throw new WrongParameterException("Preset must be provided!");\r
- }\r
- Limit<T> limit = getLimit(preset.getName());\r
- ConfiguredExecutable<T> confClust = init(sequences);\r
- confClust.addParameters(preset.getOptions());\r
- return WSUtil.align(sequences, confClust, log, "presetAlign", limit);\r
- }\r
-\r
- public String customAlign(List<FastaSequence> sequences,\r
- List<Option<T>> options) throws JobSubmissionException,\r
- WrongParameterException {\r
- WSUtil.validateFastaInput(sequences);\r
- ConfiguredExecutable<T> confClust = init(sequences);\r
- List<String> params = WSUtil.getCommands(options,\r
- ClustalW.KEY_VALUE_SEPARATOR);\r
- confClust.addParameters(params);\r
- log.info("Setting parameters: " + params);\r
- return WSUtil.align(sequences, confClust, log, "customAlign",\r
- getLimit(""));\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public Alignment getResult(String jobId) throws ResultNotAvailableException {\r
-\r
- WSUtil.validateJobId(jobId);\r
- AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
- ConfiguredExecutable<T> clustal = (ConfiguredExecutable<T>) asyncEngine\r
- .getResults(jobId);\r
- Alignment al = clustal.getResults();\r
- return al;\r
- }\r
-\r
- @Override\r
- public ChunkHolder pullExecStatistics(String jobId, long position) {\r
- WSUtil.validateJobId(jobId);\r
- String file = Configurator.getWorkDirectory(jobId) + File.separator\r
- + ClustalW.getStatFile();\r
- ChunkHolder cholder = WSUtil.pullFile(file, position);\r
- return cholder;\r
- }\r
-\r
-}\r