X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FWSUtil.java;h=07d005d3452c581a2174036095615a24e0d2b5d2;hb=bd6c0919476cff487ea479588d5ad9f3bdd5af1e;hp=9d81a6aa5b98c6c2509d8ad2bd0fe0d2d6d4fbe9;hpb=fa61eaad52ffe5ee0db449c3dd9ec5fa67aec43f;p=jabaws.git diff --git a/webservices/compbio/ws/server/WSUtil.java b/webservices/compbio/ws/server/WSUtil.java index 9d81a6a..07d005d 100644 --- a/webservices/compbio/ws/server/WSUtil.java +++ b/webservices/compbio/ws/server/WSUtil.java @@ -25,7 +25,6 @@ import java.util.Set; import org.apache.log4j.Logger; -import compbio.data.sequence.Alignment; import compbio.data.sequence.FastaSequence; import compbio.data.sequence.ScoreManager; import compbio.engine.AsyncExecutor; @@ -113,29 +112,6 @@ public final class WSUtil { return jobId; } - // Hardcoded gapchar '-' in this method - - public static String fold(Alignment alignment, - ConfiguredExecutable confExec, Logger logger, - String callingMethod, Limit limit) - throws LimitExceededException, JobSubmissionException { - - List sequences = alignment.getSequences(); - if (limit != null && limit.isExceeded(sequences)) { - throw LimitExceededException.newLimitExceeded(limit, sequences); - } - compbio.runner.Util.writeClustalInput(sequences, confExec, '-'); - System.out.println("WSUtil-fold: Writing the clustal input file on the server: to file: " - + confExec.getInput()); - System.out.println("WSUtil-fold: The executable is configured with parameters: " - + confExec.getParameters()); -// System.out.println("WSUTil-fold: Dump the configured executable:\n" -// + confExec.toString()); - AsyncExecutor engine = Configurator.getAsyncEngine(confExec); - String jobId = engine.submitJob(confExec); - reportUsage(confExec, logger); - return jobId; - } static void reportUsage(ConfiguredExecutable confExec, Logger logger) { if (GAUtils.IS_GA_ENABLED) { @@ -153,13 +129,31 @@ public final class WSUtil { throw LimitExceededException.newLimitExceeded(limit, sequences); } log.debug("Method: " + method + " with task: " + confExec.getTaskId()); - compbio.runner.Util.writeInput(sequences, confExec); AsyncExecutor engine = Configurator.getAsyncEngine(confExec); String jobId = engine.submitJob(confExec); reportUsage(confExec, log); return jobId; } + + // Same as analize but Alifold takes clustal input not fasta + // An if condition in the above method might be a better solution but + // you need a way of finding out the type of confExec at runtime + + public static String fold(List sequences, + ConfiguredExecutable confExec, Logger log, String method, + Limit limit) throws JobSubmissionException { + if (limit != null && limit.isExceeded(sequences)) { + throw LimitExceededException.newLimitExceeded(limit, sequences); + } + log.debug("Method: " + method + " with task: " + confExec.getTaskId()); + // This line is different from the above method + compbio.runner.Util.writeClustalInput(sequences, confExec, '-'); + AsyncExecutor engine = Configurator.getAsyncEngine(confExec); + String jobId = engine.submitJob(confExec); + reportUsage(confExec, log); + return jobId; + } /* * TODO Rewrite using purely CommandBuilder. This is breaking encapsulation @@ -184,10 +178,28 @@ public final class WSUtil { } if (fs.getLength() != len) { throw new JobSubmissionException( - "All sequences must be of the same length. Please align " - + "the sequences prior to submission! The first sequence length is : " - + len + " but the sequence '" + fs.getId() - + "' length is " + fs.getLength()); + "All sequences must be of the same length. Please align the sequences " + + " prior to submission! The first sequence length is : " + len + + " but the sequence '" + fs.getId() + "' length is " + fs.getLength()); + } + } + } + + public static void validateJpredInput(List sequences) + throws JobSubmissionException { + validateFastaInput(sequences); + int len = 0; + for (FastaSequence fs : sequences) { + if (len == 0) { + len = fs.getLength(); + continue; + } + if (fs.getLength() != len) { + System.out.println("FASTA rec: id = " + fs.getId() + ": seq = " + fs.getSequence()); + throw new JobSubmissionException( + "All sequences must be of the same length. Please align the sequences " + + " prior to submission! The first sequence length is : " + len + + " but the sequence '" + fs.getId() + "' length is " + fs.getLength()); } } } @@ -196,12 +208,13 @@ public final class WSUtil { throws ResultNotAvailableException { WSUtil.validateJobId(jobId); AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId); - ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine - .getResults(jobId); + ConfiguredExecutable aacon = (ConfiguredExecutable) asyncEngine.getResults(jobId); ScoreManager mas = aacon.getResults(); + log.trace(jobId + " getConservation : " + mas); return mas; } + /* * UNUSED