changeset 3:deccc074dbfb

Uploaded
author bgruening
date Fri, 12 Apr 2013 18:14:31 -0400
parents abe9670bfc44
children 3b50c1d0d1e5
files osra.py osra.xml tool_dependencies.xml
diffstat 3 files changed, 34 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/osra.py	Fri Apr 12 18:14:31 2013 -0400
@@ -0,0 +1,25 @@
+#!usr/bin/env python
+
+import os, sys
+import subprocess
+
+"""
+    OSRA_DATA_FILES is set during the toolshed Installation
+    if it is not set, use the standard configuration of OSRA and hope the best.
+    That script is a hack, because we do not know the content of OSRA_DATA_FILES at xml evaluation time.
+
+    osra -f $oformat $infile 
+        -l \$OSRA_DATA_FILES/spelling.txt -a \$OSRA_DATA_FILES/superatom.txt
+        > $outfile
+"""
+
+if not os.path.exists(sys.argv[6]):
+    # OSRA_DATA_FILES path is not set or the spelling file is not existent
+    sys.argv.pop(7) # superatom.txt path
+    sys.argv.pop(6) # -a
+    sys.argv.pop(5) # speling.txt path
+    sys.argv.pop(4) # -l
+
+subprocess.call(sys.argv[1:], stdout=sys.stdout)
+
+
--- a/osra.xml	Fri Apr 12 16:25:32 2013 -0400
+++ b/osra.xml	Fri Apr 12 18:14:31 2013 -0400
@@ -1,16 +1,17 @@
 <tool id="osra" name="Molecule recognition" version="0.2">
-    <description>in Images or PDF documents</description>
+    <description>in Images or PDF documents (OSRA)</description>
     <requirements>
         <requirement type="package" version="1.4.0">osra</requirement>
     </requirements>
-    <command>
+    <command interpreter='python'>
         ## OSRA_DATA_FILES is set during the toolshed Installation
         ## if it is not set, use the standard configuration and hope the best
-        osra -f $oformat $infile 
-        #import os
-        #if os.environ.get('OSRA_DATA_FILES', None):
-            -l \$OSRA_DATA_FILES/spelling.txt -a \$OSRA_DATA_FILES/superatom.txt
-        #end if
+        osra.py -f $oformat $infile 
+        -l \$OSRA_DATA_FILES/spelling.txt -a \$OSRA_DATA_FILES/superatom.txt
+        
+        ## further additions of OSRA parameter should go after -l and -a
+        ## because -l and -a can be removed by the python wrapper
+        
         > $outfile
     </command>
     <inputs>
--- a/tool_dependencies.xml	Fri Apr 12 16:25:32 2013 -0400
+++ b/tool_dependencies.xml	Fri Apr 12 18:14:31 2013 -0400
@@ -52,7 +52,7 @@
                     <environment_variable name="LD_LIBRARY_PATH" action="prepend_to">$INSTALL_DIR/potrace/build/lib/</environment_variable>
                     <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR/bin</environment_variable>
                     <!-- OSRA_DATA_FILES is only used by the galaxy wrapper and is not part of OSRA -->
-                    <environment_variable name="OSRA_DATA_FILES" action="prepend_to">$INSTALL_DIR/share</environment_variable>
+                    <environment_variable name="OSRA_DATA_FILES" action="set_to">$INSTALL_DIR/share</environment_variable>
                 </action>
             </actions>
         </install>