diff tools/rtg/galaxy-rtg-sdf2fasta-wrapper.sh @ 1:8593828f91e7 default tip

Full galaxy wrapper
author diego
date Sat, 21 Apr 2012 21:36:15 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/rtg/galaxy-rtg-sdf2fasta-wrapper.sh	Sat Apr 21 21:36:15 2012 -0400
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+DIR="$( cd "$( dirname "$0" )" && pwd )"
+source $DIR/rtg-galaxy.cfg
+
+# Temporary storage for STDERR
+# Temporary storage for mapping output
+TMP_STDERR=$(mktemp) || exit 1
+
+#echo "$(date) START $@" >>~/galaxy-rtg-wrapper.log
+
+outputfile=$1
+shift
+outputid=$1
+shift
+outputdir=$1
+shift
+
+# Run the program, send STDERR to temporary file
+tmpout=$outputdir/tmpout$$
+$rtg sdf2fasta "$@" -o $tmpout 2> $TMP_STDERR
+
+#check program's exit code
+if (( $? ));  then
+    #echo "$(date) FAIL $@" >>~/galaxy-rtg-wrapper.log
+    #cat $TMP_STDERR >>~/galaxy-rtg-wrapper.log
+    #Program failed, send STDERR to real STDERR
+    cat $TMP_STDERR >&2
+    rm $TMP_STDERR
+    rm -rf $tmpout
+    exit 1
+fi
+
+if [ -f ${tmpout}_1.fasta ]; then
+    mv ${tmpout}_1.fasta $outputfile
+    mv ${tmpout}_2.fasta $outputdir/primary_${outputid}_output2_visible_fasta
+else
+    mv ${tmpout}.fasta $outputfile
+fi
+
+#echo "$(date) DONE $@" >>~/galaxy-rtg-wrapper.log
+
+#Program succeeded, delete STDERR file
+rm $TMP_STDERR
+rm -rf $tmpout
+exit 0