annotate tools/rtg/galaxy-rtg-sdf2fasta-wrapper.sh @ 1:8593828f91e7 default tip

Full galaxy wrapper
author diego
date Sat, 21 Apr 2012 21:36:15 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
1 #!/bin/sh
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
2
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
3 DIR="$( cd "$( dirname "$0" )" && pwd )"
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
4 source $DIR/rtg-galaxy.cfg
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
5
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
6 # Temporary storage for STDERR
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
7 # Temporary storage for mapping output
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
8 TMP_STDERR=$(mktemp) || exit 1
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
9
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
10 #echo "$(date) START $@" >>~/galaxy-rtg-wrapper.log
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
11
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
12 outputfile=$1
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
13 shift
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
14 outputid=$1
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
15 shift
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
16 outputdir=$1
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
17 shift
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
18
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
19 # Run the program, send STDERR to temporary file
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
20 tmpout=$outputdir/tmpout$$
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
21 $rtg sdf2fasta "$@" -o $tmpout 2> $TMP_STDERR
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
22
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
23 #check program's exit code
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
24 if (( $? )); then
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
25 #echo "$(date) FAIL $@" >>~/galaxy-rtg-wrapper.log
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
26 #cat $TMP_STDERR >>~/galaxy-rtg-wrapper.log
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
27 #Program failed, send STDERR to real STDERR
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
28 cat $TMP_STDERR >&2
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
29 rm $TMP_STDERR
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
30 rm -rf $tmpout
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
31 exit 1
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
32 fi
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
33
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
34 if [ -f ${tmpout}_1.fasta ]; then
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
35 mv ${tmpout}_1.fasta $outputfile
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
36 mv ${tmpout}_2.fasta $outputdir/primary_${outputid}_output2_visible_fasta
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
37 else
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
38 mv ${tmpout}.fasta $outputfile
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
39 fi
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
40
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
41 #echo "$(date) DONE $@" >>~/galaxy-rtg-wrapper.log
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
42
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
43 #Program succeeded, delete STDERR file
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
44 rm $TMP_STDERR
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
45 rm -rf $tmpout
8593828f91e7 Full galaxy wrapper
diego
parents:
diff changeset
46 exit 0