\r
import org.apache.log4j.Logger;\r
\r
-import compbio.data.sequence.Alignment;\r
import compbio.data.sequence.FastaSequence;\r
import compbio.data.sequence.ScoreManager;\r
import compbio.engine.AsyncExecutor;\r
return jobId;\r
}\r
\r
- // Hardcoded gapchar '-' in this method\r
- \r
- public static <T> String fold(Alignment alignment,\r
- ConfiguredExecutable<T> confExec, Logger logger,\r
- String callingMethod, Limit<T> limit)\r
- throws LimitExceededException, JobSubmissionException {\r
- \r
- List<FastaSequence> sequences = alignment.getSequences();\r
- if (limit != null && limit.isExceeded(sequences)) {\r
- throw LimitExceededException.newLimitExceeded(limit, sequences);\r
- }\r
- compbio.runner.Util.writeClustalInput(sequences, confExec, '-');\r
- System.out.println("WSUtil-fold: Writing the clustal input file on the server: to file: "\r
- + confExec.getInput());\r
- System.out.println("WSUtil-fold: The executable is configured with parameters: " \r
- + confExec.getParameters());\r
-// System.out.println("WSUTil-fold: Dump the configured executable:\n" \r
-// + confExec.toString());\r
- AsyncExecutor engine = Configurator.getAsyncEngine(confExec);\r
- String jobId = engine.submitJob(confExec);\r
- reportUsage(confExec, logger);\r
- return jobId;\r
- }\r
\r
static <T> void reportUsage(ConfiguredExecutable<T> confExec, Logger logger) {\r
if (GAUtils.IS_GA_ENABLED) {\r
- Services service = ServicesUtil.getServiceByRunner(confExec\r
- .getExecutable().getClass());\r
+ Services service = ServicesUtil.getServiceByRunner(confExec.getExecutable().getClass());\r
GAUtils.reportUsage(service);\r
logger.info("Reporting GA usage for " + service);\r
}\r
if (limit != null && limit.isExceeded(sequences)) {\r
throw LimitExceededException.newLimitExceeded(limit, sequences);\r
}\r
- log.debug("Method: " + method + " with task: " + confExec.getTaskId());\r
-\r
compbio.runner.Util.writeInput(sequences, confExec);\r
AsyncExecutor engine = Configurator.getAsyncEngine(confExec);\r
String jobId = engine.submitJob(confExec);\r
return jobId;\r
}\r
\r
+ // Same as analize(...) but RNAalifold takes clustal input not fasta\r
+ // An if condition in the above method might be a better solution but \r
+ // you need a way of finding out the type of confExec at runtime\r
+ \r
+ public static <T> String fold(List<FastaSequence> sequences,\r
+ ConfiguredExecutable<T> confExec, Logger log, String method,\r
+ Limit<T> limit) throws JobSubmissionException {\r
+ if (limit != null && limit.isExceeded(sequences)) {\r
+ throw LimitExceededException.newLimitExceeded(limit, sequences);\r
+ }\r
+ compbio.runner.Util.writeClustalInput(sequences, confExec, '-');\r
+ AsyncExecutor engine = Configurator.getAsyncEngine(confExec);\r
+ String jobId = engine.submitJob(confExec);\r
+ reportUsage(confExec, log);\r
+ return jobId;\r
+ }\r
+\r
/*\r
* TODO Rewrite using purely CommandBuilder. This is breaking encapsulation\r
*/\r
}\r
if (fs.getLength() != len) {\r
throw new JobSubmissionException(\r
- "All sequences must be of the same length. Please align "\r
- + "the sequences prior to submission! The first sequence length is : "\r
- + len + " but the sequence '" + fs.getId()\r
- + "' length is " + fs.getLength());\r
+ "All sequences must be of the same length. Please align the sequences " + \r
+ " prior to submission! The first sequence length is : " + len + \r
+ " but the sequence '" + fs.getId() + "' length is " + fs.getLength());\r
+ }\r
+ }\r
+ }\r
+\r
+ public static void validateJpredInput(List<FastaSequence> sequences)\r
+ throws JobSubmissionException {\r
+ validateFastaInput(sequences);\r
+ int len = 0;\r
+ for (FastaSequence fs : sequences) {\r
+ if (len == 0) {\r
+ len = fs.getLength();\r
+ continue;\r
+ }\r
+ if (fs.getLength() != len) {\r
+ System.out.println("FASTA rec: id = " + fs.getId() + ": seq = " + fs.getSequence());\r
+ throw new JobSubmissionException(\r
+ "All sequences must be of the same length. Please align the sequences " + \r
+ " prior to submission! The first sequence length is : " + len + \r
+ " but the sequence '" + fs.getId() + "' length is " + fs.getLength());\r
}\r
}\r
}\r
throws ResultNotAvailableException {\r
WSUtil.validateJobId(jobId);\r
AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
- ConfiguredExecutable<T> aacon = (ConfiguredExecutable<T>) asyncEngine\r
- .getResults(jobId);\r
+ ConfiguredExecutable<T> aacon = (ConfiguredExecutable<T>) asyncEngine.getResults(jobId);\r
ScoreManager mas = aacon.getResults();\r
log.trace(jobId + " getConservation : " + mas);\r
return mas;\r
}\r
\r
- /*\r
- * UNUSED\r
- * \r
- * @SuppressWarnings("unchecked") static <T> LimitsManager<T>\r
- * getLimits(Class<? extends Executable<T>> clazz, WebServiceContext\r
- * wsContext) {\r
- * \r
- * String LIMIT_KEY = CACHE_KEY + clazz.getCanonicalName(); LimitsManager<T>\r
- * limit = (LimitsManager<T>) getObjectFromApplContext( LIMIT_KEY,\r
- * wsContext); if (limit == null) { synchronized (WSUtil.class) { limit =\r
- * (LimitsManager<T>) getObjectFromApplContext(LIMIT_KEY, wsContext); if\r
- * (limit == null) { limit = compbio.runner.Util\r
- * .getLimits((Class<Executable<T>>) clazz);\r
- * addObjectToApplContext(wsContext, LIMIT_KEY, limit); } } } return limit;\r
- * }\r
- * \r
- * static void addObjectToApplContext(WebServiceContext wsContext, String\r
- * objKey, Object obj) { assert !Util.isEmpty(objKey) :\r
- * "Key for the object must not be empty! "; assert wsContext != null;\r
- * \r
- * ServletContext ctx = ((javax.servlet.ServletContext) wsContext\r
- * .getMessageContext().get(MessageContext. SERVLET_CONTEXT)); assert ctx !=\r
- * null; log.debug("Adding object with key '" + objKey + "' and value '" +\r
- * obj + "' to the application context"); ctx.setAttribute(objKey, obj); }\r
- * static Object getObjectFromApplContext(String objKey, WebServiceContext\r
- * wsContext) { assert !Util.isEmpty(objKey) :\r
- * "Key for the object must not be empty! "; assert wsContext != null;\r
- * \r
- * ServletContext ctx = ((javax.servlet.ServletContext) wsContext\r
- * .getMessageContext().get(MessageContext. SERVLET_CONTEXT)); Object obj =\r
- * ctx.getAttribute(objKey); log.trace("Retrieving object with key '" +\r
- * objKey + "' and value '" + obj + "' from the application context");\r
- * return obj; }\r
- */\r
}\r