annotate tools/unix_tools/sed_wrapper.sh @ 1:cdcb0ce84a1b

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:15 -0500
parents 9071e359b9a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #!/bin/sh
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 ##
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 ## Galaxy wrapper for SED command
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 ##
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 ##
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 ## command line arguments:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 ## input_file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 ## output_file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 ## sed-program
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 ## [other parameters passed on to sed]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 INPUT="$1"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 OUTPUT="$2"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 PROG="$3"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 shift 3
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 if [ -z "$PROG" ]; then
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 echo usage: $0 INPUTFILE OUTPUTFILE SED-PROGRAM [other sed patameters] >&2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 exit 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 fi
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 if [ ! -r "$INPUT" ]; then
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 echo "error: input file ($INPUT) not found!" >&2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 exit 1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 fi
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 # Messages printed to STDOUT will be displayed in the "INFO" field in the galaxy dataset.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 # This way the user can tell what was the command
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 echo "sed" "$@" "$PROG"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 sed -r --sandbox "$@" "$PROG" "$INPUT" > "$OUTPUT"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 if (( $? )); then exit; fi
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 exit 0