diff tools/unix_tools/sed_wrapper.sh @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/unix_tools/sed_wrapper.sh	Fri Mar 09 19:37:19 2012 -0500
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+##
+## Galaxy wrapper for SED command
+##
+
+##
+## command line arguments:
+##   input_file
+##   output_file
+##   sed-program
+##   [other parameters passed on to sed]
+
+INPUT="$1"
+OUTPUT="$2"
+PROG="$3"
+
+shift 3
+
+if [ -z "$PROG" ]; then
+	echo usage: $0 INPUTFILE OUTPUTFILE SED-PROGRAM [other sed patameters] >&2
+	exit 1
+fi
+
+if [ ! -r "$INPUT" ]; then
+	echo "error: input file ($INPUT) not found!" >&2
+	exit 1
+fi
+
+# Messages printed to STDOUT will be displayed in the "INFO" field in the galaxy dataset.
+# This way the user can tell what was the command
+echo "sed" "$@" "$PROG"
+
+sed -r --sandbox "$@" "$PROG" "$INPUT" > "$OUTPUT"
+if (( $? ));  then exit; fi
+
+exit 0