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 outputfile=$1
|
|
13 shift
|
|
14 outputid=$1
|
|
15 shift
|
|
16 outputdir=$1
|
|
17 shift
|
|
18
|
|
19 # Run the program, send STDERR to temporary file
|
|
20 tmpout=$outputdir/tmpout$$
|
|
21 $rtg sdf2fasta "$@" -o $tmpout 2> $TMP_STDERR
|
|
22
|
|
23 #check program's exit code
|
|
24 if (( $? )); then
|
|
25 #echo "$(date) FAIL $@" >>~/galaxy-rtg-wrapper.log
|
|
26 #cat $TMP_STDERR >>~/galaxy-rtg-wrapper.log
|
|
27 #Program failed, send STDERR to real STDERR
|
|
28 cat $TMP_STDERR >&2
|
|
29 rm $TMP_STDERR
|
|
30 rm -rf $tmpout
|
|
31 exit 1
|
|
32 fi
|
|
33
|
|
34 if [ -f ${tmpout}_1.fasta ]; then
|
|
35 mv ${tmpout}_1.fasta $outputfile
|
|
36 mv ${tmpout}_2.fasta $outputdir/primary_${outputid}_output2_visible_fasta
|
|
37 else
|
|
38 mv ${tmpout}.fasta $outputfile
|
|
39 fi
|
|
40
|
|
41 #echo "$(date) DONE $@" >>~/galaxy-rtg-wrapper.log
|
|
42
|
|
43 #Program succeeded, delete STDERR file
|
|
44 rm $TMP_STDERR
|
|
45 rm -rf $tmpout
|
|
46 exit 0
|