1 /* Copyright (c) 2011 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
18 package compbio.ws.server;
\r
20 import java.util.List;
\r
22 import org.apache.log4j.Logger;
\r
24 import compbio.data.sequence.FastaSequence;
\r
25 import compbio.data.sequence.ScoreManager;
\r
26 import compbio.engine.client.ConfiguredExecutable;
\r
27 import compbio.engine.client.SkeletalExecutable;
\r
28 import compbio.metadata.JobSubmissionException;
\r
29 import compbio.metadata.Limit;
\r
30 import compbio.metadata.LimitExceededException;
\r
31 import compbio.metadata.Option;
\r
32 import compbio.metadata.Preset;
\r
33 import compbio.metadata.ResultNotAvailableException;
\r
34 import compbio.metadata.UnsupportedRuntimeException;
\r
35 import compbio.metadata.WrongParameterException;
\r
36 import compbio.runner.conservation.AACon;
\r
39 * Common methods for all SequenceAnnotation web services
\r
45 * @version 1.0 June 2011
\r
48 public abstract class SequenceAnnotationService<T> extends GenericMetadataService {
\r
51 * FIXME - instances of the Runner (?) and their types should be defined in
\r
54 SequenceAnnotationService(SkeletalExecutable<T> exec, Logger log) {
\r
58 public ScoreManager getAnnotation(String jobId)
\r
59 throws ResultNotAvailableException {
\r
60 return WSUtil.getAnnotation(jobId, log);
\r
63 public String analize(List<FastaSequence> sequences)
\r
64 throws UnsupportedRuntimeException, LimitExceededException,
\r
65 JobSubmissionException {
\r
66 WSUtil.validateFastaInput(sequences);
\r
67 ConfiguredExecutable<T> confIUPred = init(sequences);
\r
68 return WSUtil.analize(sequences, confIUPred, log, "analize",
\r
72 public String customAnalize(List<FastaSequence> sequences,
\r
73 List<Option<T>> options) throws UnsupportedRuntimeException,
\r
74 LimitExceededException, JobSubmissionException,
\r
75 WrongParameterException {
\r
76 WSUtil.validateFastaInput(sequences);
\r
77 ConfiguredExecutable<T> confAACon = init(sequences);
\r
78 // Could not do that! Space separated values
\r
79 // will all be treated as keys! thus duplicates removed
\r
80 // String params = cbuilder.getCommand();
\r
81 List<String> params = WSUtil.getCommands(options,
\r
82 AACon.KEY_VALUE_SEPARATOR);
\r
83 confAACon.addParameters(params);
\r
84 return WSUtil.analize(sequences, confAACon, log, "customAnalize",
\r
88 public String presetAnalize(List<FastaSequence> sequences, Preset<T> preset)
\r
89 throws UnsupportedRuntimeException, LimitExceededException,
\r
90 JobSubmissionException, WrongParameterException {
\r
91 WSUtil.validateAAConInput(sequences);
\r
92 if (preset == null) {
\r
93 throw new WrongParameterException("Preset must be provided!");
\r
95 ConfiguredExecutable<T> confAAcon = init(sequences);
\r
96 confAAcon.addParameters(preset.getOptions());
\r
97 Limit<T> limit = getLimit(preset.getName());
\r
99 .analize(sequences, confAAcon, log, "presetAnalize", limit);
\r