X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fserver%2FWSUtil.java;h=07d005d3452c581a2174036095615a24e0d2b5d2;hb=bd6c0919476cff487ea479588d5ad9f3bdd5af1e;hp=fb96de8adab902ac20b6af10466683a7c9f51872;hpb=1e1c3681ba25ee1797a46f871b8c80f259afe2ca;p=jabaws.git diff --git a/webservices/compbio/ws/server/WSUtil.java b/webservices/compbio/ws/server/WSUtil.java index fb96de8..07d005d 100644 --- a/webservices/compbio/ws/server/WSUtil.java +++ b/webservices/compbio/ws/server/WSUtil.java @@ -38,6 +38,8 @@ import compbio.metadata.Limit; import compbio.metadata.LimitExceededException; import compbio.metadata.Option; import compbio.metadata.ResultNotAvailableException; +import compbio.ws.client.Services; +import compbio.ws.client.ServicesUtil; public final class WSUtil { @@ -106,8 +108,19 @@ public final class WSUtil { compbio.runner.Util.writeInput(sequences, confExec); 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) { + Services service = ServicesUtil.getServiceByRunner(confExec + .getExecutable().getClass()); + GAUtils.reportUsage(service); + logger.info("Reporting GA usage for " + service); + } + } public static String analize(List sequences, ConfiguredExecutable confExec, Logger log, String method, @@ -116,11 +129,29 @@ 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; } @@ -147,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()); } } } @@ -159,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