| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | ## |
|---|
| 4 | ## Galaxy wrapper for AWK command |
|---|
| 5 | ## |
|---|
| 6 | |
|---|
| 7 | ## |
|---|
| 8 | ## command line arguments: |
|---|
| 9 | ## input_file |
|---|
| 10 | ## output_file |
|---|
| 11 | ## awk-program |
|---|
| 12 | ## input-field-separator |
|---|
| 13 | ## output-field-separator |
|---|
| 14 | |
|---|
| 15 | INPUT="$1" |
|---|
| 16 | OUTPUT="$2" |
|---|
| 17 | PROG="$3" |
|---|
| 18 | FS="$4" |
|---|
| 19 | OFS="$5" |
|---|
| 20 | |
|---|
| 21 | shift 5 |
|---|
| 22 | |
|---|
| 23 | if [ -z "$OFS" ]; then |
|---|
| 24 | echo usage: $0 INPUTFILE OUTPUTFILE AWK-PROGRAM FS OFS>&2 |
|---|
| 25 | exit 1 |
|---|
| 26 | fi |
|---|
| 27 | |
|---|
| 28 | if [ ! -r "$INPUT" ]; then |
|---|
| 29 | echo "error: input file ($INPUT) not found!" >&2 |
|---|
| 30 | exit 1 |
|---|
| 31 | fi |
|---|
| 32 | |
|---|
| 33 | if [ "$FS" == "tab" ]; then |
|---|
| 34 | FS="\t" |
|---|
| 35 | fi |
|---|
| 36 | if [ "$OFS" == "tab" ]; then |
|---|
| 37 | OFS="\t" |
|---|
| 38 | fi |
|---|
| 39 | |
|---|
| 40 | # Messages printed to STDOUT will be displayed in the "INFO" field in the galaxy dataset. |
|---|
| 41 | # This way the user can tell what was the command |
|---|
| 42 | echo "awk" "$PROG" |
|---|
| 43 | |
|---|
| 44 | awk --sandbox -v OFS="$OFS" -v FS="$FS" --re-interval "$PROG" "$INPUT" > "$OUTPUT" |
|---|
| 45 | if (( $? )); then exit; fi |
|---|
| 46 | |
|---|
| 47 | exit 0 |
|---|