1
|
1 #!/bin/sh
|
|
2
|
|
3 DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
4 source $DIR/rtg-galaxy.cfg
|
|
5
|
|
6 # Temporary storage for STDERR
|
|
7 # Temporary storage for mapping output
|
|
8 TMP_STDERR=$(mktemp) || exit 1
|
|
9
|
|
10 #echo "$(date) START $@" >>~/galaxy-rtg-wrapper.log
|
|
11
|
|
12 snpfile=$1
|
|
13 shift
|
|
14 snpoutputdir=$1
|
|
15 shift
|
|
16
|
|
17 # Run the program, send STDERR to temporary file
|
|
18 mkdir $snpoutputdir
|
|
19 tmpout=$snpoutputdir/snps.vcf
|
|
20 $rtg "$@" -s $tmpout -Z 2> $TMP_STDERR
|
|
21
|
|
22 #check program's exit code
|
|
23 if (( $? )); then
|
|
24 #echo "$(date) FAIL $@" >>~/galaxy-rtg-wrapper.log
|
|
25 #cat $TMP_STDERR >>~/galaxy-rtg-wrapper.log
|
|
26 #Program failed, send STDERR to real STDERR
|
|
27 cat $TMP_STDERR >&2
|
|
28 rm $TMP_STDERR
|
|
29 rm -rf $tmpout
|
|
30 exit 1
|
|
31 fi
|
|
32
|
|
33 mv $tmpout $snpfile
|
|
34
|
|
35 #echo "$(date) DONE $@" >>~/galaxy-rtg-wrapper.log
|
|
36
|
|
37 #Program succeeded, delete STDERR file
|
|
38 rm $TMP_STDERR
|
|
39 rm -rf $snpoutputdir
|
|
40 exit 0
|