annotate weeder2_wrapper.sh @ 2:3c5f10f7dd40 draft

Updated to tool version 2.0.1 (use data table to locate freqfiles).
author pjbriggs
date Fri, 27 Nov 2015 11:06:28 -0500
parents 496bc4eff47e
children 89315bdc1a8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
1 #!/bin/sh -e
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
2 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
3 # Wrapper script to run weeder2 as a Galaxy tool
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
4 #
2
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
5 # Usage: weeder_wrapper.sh FASTA_IN SPECIES_CODE FREQFILES_DIR MOTIFS_OUT MATRIX_OUT [ ARGS... ]
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
6 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
7 # ARGS: one or more arguments to supply directly to weeder2
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
8 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
9 # Process command line
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
10 FASTA_IN=$1
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
11 SPECIES_CODE=$2
2
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
12 FREQFILES_DIR=$3
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
13 MOTIFS_OUT=$4
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
14 MATRIX_OUT=$5
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
15 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
16 # Other arguments
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
17 ARGS=""
2
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
18 while [ ! -z "$6" ] ; do
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
19 ARGS="$ARGS $6"
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
20 shift
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
21 done
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
22 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
23 # Link to input file
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
24 ln -s $FASTA_IN
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
25 #
2
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
26 # Locate the FreqFiles directory
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
27 if [ $FREQFILES_DIR == "." ] ; then
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
28 # Use the files in the Weeder2 distribution
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
29 freqfiles_dir=$WEEDER_FREQFILES_DIR
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
30 else
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
31 # Alternative location
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
32 freqfiles_dir=$FREQFILES_DIR
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
33 fi
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
34 #
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
35 # Link to the FreqFiles directory as weeder2 executable
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
36 # expects it to be the same directory
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
37 if [ -d $freqfiles_dir ] ; then
2
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
38 echo "Linking to FreqFiles directory: $freqfiles_dir"
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
39 ln -s $freqfiles_dir FreqFiles
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
40 else
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
41 echo "ERROR FreqFiles directory not found" >&2
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
42 exit 1
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
43 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
44 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
45 # Construct names of input and output files
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
46 fasta=`basename $FASTA_IN`
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
47 motifs_out=$fasta.w2
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
48 matrix_out=$fasta.matrix.w2
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
49 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
50 # Construct and run weeder command
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
51 # NB weeder logs output to stderr so redirect to stdout
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
52 # to prevent the Galaxy tool reporting failure
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
53 weeder_cmd="weeder2 -f $fasta -O $SPECIES_CODE $ARGS"
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
54 echo "Running $weeder_cmd"
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
55 $weeder_cmd 2>&1
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
56 status=$?
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
57 if [ $status -ne 0 ] ; then
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
58 echo weeder2 command finished with nonzero exit code $status >&2
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
59 echo Command was: $weeder_cmd
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
60 exit $status
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
61 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
62 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
63 # Move outputs to final destinations
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
64 if [ -e $motifs_out ] ; then
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
65 /bin/mv $motifs_out $MOTIFS_OUT
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
66 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
67 if [ -e $matrix_out ] ; then
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
68 /bin/mv $matrix_out $MATRIX_OUT
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
69 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
70 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
71 # Done