0
|
1 #!/bin/sh -e
|
|
2 #
|
|
3 # Wrapper script to run weeder2 as a Galaxy tool
|
|
4 #
|
|
5 # Usage: weeder_wrapper.sh FASTA_IN SPECIES_CODE MOTIFS_OUT MATRIX_OUT [ ARGS... ]
|
|
6 #
|
|
7 # ARGS: one or more arguments to supply directly to weeder2
|
|
8 #
|
|
9 # Process command line
|
|
10 FASTA_IN=$1
|
|
11 SPECIES_CODE=$2
|
|
12 MOTIFS_OUT=$3
|
|
13 MATRIX_OUT=$4
|
|
14 #
|
|
15 # Other arguments
|
|
16 ARGS=""
|
|
17 while [ ! -z "$5" ] ; do
|
|
18 ARGS="$ARGS $5"
|
|
19 shift
|
|
20 done
|
|
21 #
|
|
22 # Link to input file
|
|
23 ln -s $FASTA_IN
|
|
24 #
|
|
25 # Link to the FreqFiles directory as weeder2 executable
|
|
26 # expects it to be the same directory
|
|
27 freqfiles_dir=$WEEDER_FREQFILES_DIR
|
|
28 if [ -d $freqfiles_dir ] ; then
|
|
29 echo "Linking to FreqFiles directory"
|
|
30 ln -s $freqfiles_dir FreqFiles
|
|
31 else
|
|
32 echo "ERROR FreqFiles directory not found" >&2
|
|
33 exit 1
|
|
34 fi
|
|
35 #
|
|
36 # Construct names of input and output files
|
|
37 fasta=`basename $FASTA_IN`
|
|
38 motifs_out=$fasta.w2
|
|
39 matrix_out=$fasta.matrix.w2
|
|
40 #
|
|
41 # Construct and run weeder command
|
|
42 # NB weeder logs output to stderr so redirect to stdout
|
|
43 # to prevent the Galaxy tool reporting failure
|
|
44 weeder_cmd="weeder2 -f $fasta -O $SPECIES_CODE $ARGS"
|
|
45 echo "Running $weeder_cmd"
|
|
46 $weeder_cmd 2>&1
|
|
47 status=$?
|
|
48 if [ $status -ne 0 ] ; then
|
|
49 echo weeder2 command finished with nonzero exit code $status >&2
|
|
50 echo Command was: $weeder_cmd
|
|
51 exit $status
|
|
52 fi
|
|
53 #
|
|
54 # Move outputs to final destinations
|
|
55 if [ -e $motifs_out ] ; then
|
|
56 /bin/mv $motifs_out $MOTIFS_OUT
|
|
57 fi
|
|
58 if [ -e $matrix_out ] ; then
|
|
59 /bin/mv $matrix_out $MATRIX_OUT
|
|
60 fi
|
|
61 #
|
|
62 # Done
|