| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | ## |
|---|
| 4 | ## Galaxy wrapper for SED command |
|---|
| 5 | ## |
|---|
| 6 | |
|---|
| 7 | ## |
|---|
| 8 | ## command line arguments: |
|---|
| 9 | ## input_file |
|---|
| 10 | ## output_file |
|---|
| 11 | ## sed-program |
|---|
| 12 | ## [other parameters passed on to sed] |
|---|
| 13 | |
|---|
| 14 | INPUT="$1" |
|---|
| 15 | OUTPUT="$2" |
|---|
| 16 | PROG="$3" |
|---|
| 17 | |
|---|
| 18 | shift 3 |
|---|
| 19 | |
|---|
| 20 | if [ -z "$PROG" ]; then |
|---|
| 21 | echo usage: $0 INPUTFILE OUTPUTFILE SED-PROGRAM [other sed patameters] >&2 |
|---|
| 22 | exit 1 |
|---|
| 23 | fi |
|---|
| 24 | |
|---|
| 25 | if [ ! -r "$INPUT" ]; then |
|---|
| 26 | echo "error: input file ($INPUT) not found!" >&2 |
|---|
| 27 | exit 1 |
|---|
| 28 | fi |
|---|
| 29 | |
|---|
| 30 | # Messages printed to STDOUT will be displayed in the "INFO" field in the galaxy dataset. |
|---|
| 31 | # This way the user can tell what was the command |
|---|
| 32 | echo "sed" "$@" "$PROG" |
|---|
| 33 | |
|---|
| 34 | sed -r --sandbox "$@" "$PROG" "$INPUT" > "$OUTPUT" |
|---|
| 35 | if (( $? )); then exit; fi |
|---|
| 36 | |
|---|
| 37 | exit 0 |
|---|