import java.util.Arrays;
import java.util.List;
+//imports for filereader method
+import java.io.FileReader;
+import java.io.BufferedReader;
+import java.io.File;
+
import org.apache.log4j.Logger;
import compbio.data.sequence.Alignment;
import compbio.metadata.ResultNotAvailableException;
import compbio.runner.Util;
+
+import compbio.engine.client.CommandBuilder;
+
public class RNAalifold extends SkeletalExecutable<RNAalifold>
implements PipedExecutable<RNAalifold> {
-
private static Logger log = Logger.getLogger(RNAalifold.class);
- @SuppressWarnings("unchecked")
- @Override
- // PlaceHolder method
- public String getResults(String resultFile)
- throws ResultNotAvailableException {
- return "null";
- }
-
-
@Override
public RNAalifold setOutput(String outFile) {
log.info("Set ouput file: " + outFile.toString());
return (Class<RNAalifold>) this.getClass();
}
+ @SuppressWarnings("unchecked")
+ @Override
+ // PlaceHolder method
+ public String getResults(String workDirectory)
+ throws ResultNotAvailableException {
+ try {
+ // System.out.print(readRNAStruct(workDirectory, getOutput()));
+ return readRNAStruct(workDirectory, getOutput());
+ } catch (FileNotFoundException e) {
+ log.error(e.getMessage(), e.getCause());
+ throw new ResultNotAvailableException(e);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e.getCause());
+ throw new ResultNotAvailableException(e);
+ }
+ }
+
+
+ // Simple and generic methods for reading a whole file
+ // Should surfice until a more detailed datamodel and parser are developed
+ private static String readRNAStruct(String workDirectory,
+ String structFile) throws IOException, FileNotFoundException {
+ assert !compbio.util.Util.isEmpty(workDirectory);
+ assert !compbio.util.Util.isEmpty(structFile);
+ File sfile = new File(compbio.engine.client.Util.getFullPath(
+ workDirectory, structFile));
+ log.trace("RNAALIFOLD OUTPUT FILE PATH: " + sfile.getAbsolutePath());
+ if(!(sfile.exists() && sfile.length() > 0)) {
+ throw new FileNotFoundException("Result for the jobId "
+ + workDirectory + "with file name " + structFile
+ + " is not found!");
+ }
+ return readFile(sfile);
+ }
+
+ private static BufferedReader input;
+ public static String readFile(File inputFile) throws
+ FileNotFoundException, IOException {
+
+ input = new BufferedReader(new FileReader(inputFile));
+
+ String file = new String();
+ String line = new String();
+
+ while (true) {
+ line = input.readLine();
+
+ if (line != null) {
+ file = file + line + "\r\n";
+ } else break;
+ }
+ // Close file
+ input.close();
+ return file;
+ }
}
new RunnerConfigMarshaller<RNAalifold>(RunnerConfig.class);
rnaalifoldConfig = rnaalifoldmarsh.read(new FileInputStream(new File(
rnaalifoldConfigFile)), RunnerConfig.class);
+ // set Name value separator
+ rnaalifoldConfig.setPrmSeparator(" ");
+ log.info("prmSeparator: " + rnaalifoldConfig.getPrmSeparator());
rnaalifoldOpc = new OptionCombinator(rnaalifoldConfig);
log.info("Num options: " + rnaalifoldOpc.getAllOptions().size());
public void testOptions() {
test(rnaalifoldOpc.getAllOptions());
}
+
+ @Test(groups = { AllTestSuit.test_group_runner })
+ public void testOptionPairs() throws ResultNotAvailableException {
+ List<Option<?>> pair = new ArrayList<Option<?>>();
+ List<Option<?>> options = rnaalifoldOpc.getAllOptions();
+ int numpairs = 0;
+ for (int i = 0; i<options.size(); i++) {
+ for (int j = i; j<options.size(); j++) {
+ if (i != j) {
+ //System.out.println("special numOptions: " + options.size());
+ //System.out.println("special loop varaibles:- (i,j): (" + i + "," + j +")");
+ pair.clear();
+ pair.add(options.get(i)); pair.add(options.get(j));
+ log.info("option pair to test: " + pair);
+ // I want to catch ResultNotAvailableException here so
+ // I can return a list of imcompatable options but
+ // singleTest calls a fail() method...
+ // can i fail the test and continue running?
+ test(pair);
+
+ //System.out.println("special numpairstested: " + ++numpairs);
+ }
+ }
+ }
+ }
@Test(groups = { AllTestSuit.test_group_runner })
public void testParameters() {
test(options);
}
+ /*
void test(Map<Parameter<?>, String> paramValue) {
List<Parameter<?>> paramList = new ArrayList<Parameter<?>>(paramValue
.keySet());
}
log.info("NUMBER OF COMBINATION TESTED: " + paramValue.size());
}
+ */
void test(List<? extends Option<?>> params) {
for (int i = 0; i < params.size(); i++) {
log.info("NUMBER OF COMBINATION TESTED: " + params.size());
}
+ @Test
+ void singleParamTest() {
+ //List<Parameter<?>> params = rnaalifoldOpc.getAllParameters();
+ //System.out.println("special: params: " + params);
+
+ //List<String> args = rnaalifoldOpc.argumentsToCommandString(params);
+ List<String> args = new ArrayList<String>();
+ args.add("-T 37"); args.add("-S 1.07"); args.add("--stochBT_en=10");
+ args.add("--MEA=1");
+ System.out.println("special: args: " + args);
+ singleTest(args);
+
+ }
+
void singleTest(List<String> params) {
try {
log.info("Using arguments: " + params);
@Test(groups = { AllTestSuit.test_group_runner })
public void testRunLocally() {
RNAalifold rnaalifold = new RNAalifold();
- rnaalifold.setInput(AllTestSuit.test_input).setOutput(test_outfile);
+ rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);
try{
ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
LocalRunner lr = new LocalRunner(confRNAalifold);
lr.executeJob();
confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();
- // getResults method still to come
assertNotNull(confRNAalifold.getResults());
} catch (JobSubmissionException e) {
e.printStackTrace();
</parameters>
<!-- ?Will Jabaws recognize that arguments for the following params must
be of the form -s INT and &dash-stochBT=INT -->
- <parameters isRequired='false'>
- <name>Stochastic Backtrack</name>
- <description>Compute a number of random structures</description>
- <optionNames>-s</optionNames>
+<!-- <parameters isRequired='false'> -->
+<!-- <name>Stochastic Backtrack</name> -->
+<!-- <description>Compute a number of random structures</description> -->
+<!-- <optionNames>-s</optionNames> -->
<!-- Having multiple optionNames requires a default value but
in a parameter defaultValue refers to the argument -->
<!-- <optionNames>-stochBT</optionNames> -->
- <defaultValue>5</defaultValue> <!-- arbitrary -->
- <validValue>
- <type>Int</type>
- </validValue>
- </parameters>
+<!-- <defaultValue>5</defaultValue> arbitrary -->
+<!-- <validValue> -->
+<!-- <type>Int</type> -->
+<!-- </validValue> -->
+<!-- </parameters> -->
<parameters isRequired='false'>
<name>stochBT_en</name>
<description>Print Backtrack structures</description>
<type>String</type>
</validValue>
</parameters>
- <parameters isRequired='false'>
- <name>betaScale</name>
- <description>Set scaling of Boltzmann factors</description>
- <optionNames>--betaScale</optionNames>
- <defaultValue>1.0</defaultValue>
- <validValue>
- <type>Double</type>
- </validValue>
- </parameters>
+ <!-- Is dependant on -p (partfunc) -->
+<!-- <parameters isRequired='false'> -->
+<!-- <name>betaScale</name> -->
+<!-- <description>Set scaling of Boltzmann factors</description> -->
+<!-- <optionNames>-betaScale</optionNames> -->
+<!-- <defaultValue>1.0</defaultValue> -->
+<!-- <validValue> -->
+<!-- <type>Double</type> -->
+<!-- </validValue> -->
+<!-- </parameters> -->
</runnerConfig>
\ No newline at end of file
--- /dev/null
+package compbio.ws.server;
+
+import java.io.File;
+import java.util.List;
+
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+import org.apache.log4j.Logger;
+
+import compbio.data.msa.JABAService;
+import compbio.data.msa.JManagement;
+import compbio.data.msa.Metadata;
+import compbio.data.msa.MsaWS;
+import compbio.data.sequence.Alignment;
+import compbio.data.sequence.FastaSequence;
+import compbio.engine.AsyncExecutor;
+import compbio.engine.Configurator;
+import compbio.engine.client.ConfiguredExecutable;
+import compbio.engine.client.SkeletalExecutable;
+import compbio.metadata.ChunkHolder;
+import compbio.metadata.JobStatus;
+import compbio.metadata.JobSubmissionException;
+import compbio.metadata.Limit;
+import compbio.metadata.LimitsManager;
+import compbio.metadata.Option;
+import compbio.metadata.Preset;
+import compbio.metadata.PresetManager;
+import compbio.metadata.ResultNotAvailableException;
+import compbio.metadata.RunnerConfig;
+import compbio.metadata.WrongParameterException;
+import compbio.runner.Util;
+import compbio.runner.msa.ClustalW;
+import compbio.runner.structure.RNAalifold;
+
+@WebService(targetNamespace = JABAService.SERVICE_NAMESPACE, serviceName = "RNAalifoldWS")
+public class RNAalifoldWS implements JABAService, JManagement, Metadata<RNAalifold> {
+
+ private static Logger log = Logger.getLogger(ClustalWS.class);
+
+ private static final RunnerConfig<RNAalifold> rnaalifoldOptions = Util.
+ getSupportedOptions(RNAalifold.class);
+
+ private static final PresetManager<RNAalifold> rnaalifoldPresets = Util
+ .getPresets(RNAalifold.class);
+
+ private static final LimitsManager<RNAalifold> limitMan = compbio.engine.client.Util
+ .getLimits(new RNAalifold().getType());
+
+ ConfiguredExecutable<RNAalifold> init() throws JobSubmissionException {
+ RNAalifold rnaalifold = new RNAalifold();
+ rnaalifold.setInput(SkeletalExecutable.INPUT)
+ .setOutput(SkeletalExecutable.OUTPUT)
+ .setError(SkeletalExecutable.ERROR);
+ ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
+ .configureExecutable(rnaalifold);
+ return confRNAalifold;
+ }
+
+ @Override
+ public RunnerConfig<RNAalifold> getRunnerOptions() {
+ return rnaalifoldOptions;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getResult(@WebParam(name = "jobId") String jobId) throws ResultNotAvailableException {
+
+ WSUtil.validateJobId(jobId);
+ AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);
+ ConfiguredExecutable<RNAalifold> rnaalifold = (ConfiguredExecutable<RNAalifold>) asyncEngine
+ .getResults(jobId);
+ return rnaalifold.getResults();
+ }
+
+ @Override
+ public boolean cancelJob(String jobId) {
+ WSUtil.validateJobId(jobId);
+ boolean result = WSUtil.cancelJob(jobId);
+ return result;
+ }
+
+ @Override
+ public JobStatus getJobStatus(String jobId) {
+ WSUtil.validateJobId(jobId);
+ JobStatus status = WSUtil.getJobStatus(jobId);
+ return status;
+ }
+
+ @Override
+ public Limit<RNAalifold> getLimit(String presetName) {
+ if (limitMan == null) {
+ // No limit is configured
+ return null;
+ }
+ Limit<RNAalifold> limit = limitMan.getLimitByName(presetName);
+ return limit;
+ }
+
+ @Override
+ public LimitsManager<RNAalifold> getLimits() {
+ return limitMan;
+ }
+
+ @Override
+ // PlaceHolder
+ public PresetManager<RNAalifold> getPresets() {
+ if (rnaalifoldPresets == null) {
+ // No presets are configured
+ return null;
+ }
+ return rnaalifoldPresets;
+ }
+
+ @Override
+ // PlaceHolder
+ public ChunkHolder pullExecStatistics(String jobId, long position) {
+
+ WSUtil.validateJobId(jobId);
+// String file = Configurator.getWorkDirectory(jobId) + File.separator
+// + RNAalifold.getStatFile();
+// ChunkHolder cholder = WSUtil.pullFile(file, position);
+// return cholder;
+ return null;
+ }
+}
+
+