\r
package compbio.runner.disorder;\r
\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
import java.io.FileNotFoundException;\r
import java.io.IOException;\r
+import java.io.InputStream;\r
import java.util.Arrays;\r
import java.util.List;\r
\r
import org.apache.log4j.Logger;\r
\r
-import compbio.data.sequence.Alignment;\r
+import compbio.data.sequence.AnnotatedSequence;\r
+import compbio.data.sequence.SequenceUtil;\r
import compbio.data.sequence.UnknownFileFormatException;\r
import compbio.engine.client.Executable;\r
-import compbio.engine.client.PipedExecutable;\r
import compbio.engine.client.SkeletalExecutable;\r
import compbio.metadata.Limit;\r
import compbio.metadata.LimitsManager;\r
import compbio.metadata.ResultNotAvailableException;\r
import compbio.runner.Util;\r
\r
-public class RonnWrapper extends SkeletalExecutable<RonnWrapper> implements\r
- PipedExecutable<RonnWrapper> {\r
- /*\r
- * RONN does not accept stdin the file name must be defined as parameter It\r
- * can only analyse ONE sequence per run! (or may be not, but the results\r
- * gets overriden!) FASTA format is accepted.\r
- * \r
- * To run it do the following:\r
- * \r
- * 1) copy ronn executables and task file to work directory\r
- * \r
- * 2) execute run processes one by one for each sequence\r
- */\r
-\r
- private static final String command = "/homes/pvtroshin/soft/RONNv3_fasta/Ronn_runner.sh";\r
+/**\r
+ * Command line\r
+ * \r
+ * java -Xmx512 -jar jronn_v3.jar -i=test_seq.txt -n=1 -o=out.txt -s=stat.out\r
+ * \r
+ * @author pvtroshin\r
+ * \r
+ */\r
+public class Jronn extends SkeletalExecutable<Jronn> {\r
\r
- private static Logger log = Logger.getLogger(RonnWrapper.class);\r
+ private static Logger log = Logger.getLogger(Jronn.class);\r
\r
// Cache for Limits information\r
- private static LimitsManager<RonnWrapper> limits;\r
+ private static LimitsManager<Jronn> limits;\r
\r
public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
+ public static final String STAT_FILE = "stat.txt";\r
+\r
+ public Jronn() {\r
+ addParameters(Arrays.asList("-jar", getLibPath(), "-n=1", "-s="\r
+ + STAT_FILE, "-f=H"));\r
+ }\r
\r
@SuppressWarnings("unchecked")\r
@Override\r
- public Alignment getResults(String workDirectory)\r
+ public List<AnnotatedSequence> getResults(String workDirectory)\r
throws ResultNotAvailableException {\r
+ List<AnnotatedSequence> sequences = null;\r
try {\r
- return Util.readClustalFile(workDirectory, getOutput());\r
+ InputStream inStream = new FileInputStream(new File(workDirectory,\r
+ getOutput()));\r
+ sequences = SequenceUtil.readJRonn(inStream);\r
+ inStream.close();\r
} catch (FileNotFoundException e) {\r
log.error(e.getMessage(), e.getCause());\r
throw new ResultNotAvailableException(e);\r
log.error(e.getMessage(), e.getCause());\r
throw new ResultNotAvailableException(e);\r
}\r
+ return sequences;\r
+ }\r
+\r
+ private static String getLibPath() {\r
+\r
+ String settings = ph.getProperty("jronn.jar.file");\r
+ if (compbio.util.Util.isEmpty(settings)) {\r
+ throw new NullPointerException(\r
+ "Please define jronn.jar.file property in Executable.properties file"\r
+ + "and initialize it with the location of jronn jar file");\r
+ }\r
+ if (new File(settings).isAbsolute()) {\r
+ // Jronn jar can be found so no actions necessary\r
+ // no further actions is necessary\r
+ return settings;\r
+ }\r
+ return compbio.engine.client.Util.convertToAbsolute(settings);\r
}\r
\r
@Override\r
}\r
\r
@Override\r
- public RonnWrapper setInput(String inFile) {\r
- String input = getInput();\r
+ public Jronn setInput(String inFile) {\r
super.setInput(inFile);\r
+ cbuilder.setParam("-i=" + inFile);\r
return this;\r
}\r
\r
@Override\r
- public Limit<RonnWrapper> getLimit(String presetName) {\r
+ public Jronn setOutput(String outFile) {\r
+ super.setOutput(outFile);\r
+ cbuilder.setParam("-o=" + outFile);\r
+ return this;\r
+ }\r
+\r
+ @Override\r
+ public Limit<Jronn> getLimit(String presetName) {\r
if (limits == null) {\r
limits = getLimits();\r
}\r
- Limit<RonnWrapper> limit = null;\r
+ Limit<Jronn> limit = null;\r
if (limits != null) {\r
// this returns default limit if preset is undefined!\r
limit = limits.getLimitByName(presetName);\r
}\r
\r
@Override\r
- public LimitsManager<RonnWrapper> getLimits() {\r
+ public LimitsManager<Jronn> getLimits() {\r
// synchronise on static field\r
synchronized (log) {\r
if (limits == null) {\r
public Class<? extends Executable<?>> getType() {\r
return this.getClass();\r
}\r
+\r
+ public static String getStatFile() {\r
+ return STAT_FILE;\r
+ }\r
}\r