annotate weeder2_wrapper.sh @ 4:89315bdc1a8c draft default tip

Uploaded tool version 2.0.3.
author pjbriggs
date Wed, 26 Sep 2018 10:12:56 -0400
parents 3c5f10f7dd40
children
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
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
28 # Don't explicitly set the location - Weeder2 from
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
29 # bioconda handles this automatically
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
30 freqfiles_dir=
2
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
31 else
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
32 # Alternative location
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
33 freqfiles_dir=$FREQFILES_DIR
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
34 fi
3c5f10f7dd40 Updated to tool version 2.0.1 (use data table to locate freqfiles).
pjbriggs
parents: 0
diff changeset
35 #
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
36 # Link to the FreqFiles directory as weeder2 executable
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
37 # expects it to be the same directory
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
38 if [ ! -z "$freqfiles_dir" ] ; then
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
39 if [ -d $freqfiles_dir ] ; then
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
40 echo "Linking to FreqFiles directory: $freqfiles_dir"
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
41 ln -s $freqfiles_dir FreqFiles
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
42 else
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
43 echo "ERROR FreqFiles directory not found" >&2
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
44 exit 1
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
45 fi
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
46 else
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
47 echo "WARNING FreqFiles directory not set" >&2
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
48 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
49 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
50 # Construct names of input and output files
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
51 fasta=$(basename $FASTA_IN)
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
52 motifs_out=${fasta}.w2
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
53 matrix_out=${fasta}.matrix.w2
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
54 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
55 # Construct and run weeder command
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
56 # NB weeder logs output to stderr so redirect to stdout
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
57 # to prevent the Galaxy tool reporting failure
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
58 weeder_cmd="weeder2 -f $fasta -O $SPECIES_CODE $ARGS"
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
59 echo "Running $weeder_cmd"
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
60 $weeder_cmd 2>&1
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
61 status=$?
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
62 if [ $status -ne 0 ] ; then
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
63 echo weeder2 command finished with nonzero exit code $status >&2
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
64 echo Command was: $weeder_cmd
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
65 exit $status
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
66 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
67 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
68 # Move outputs to final destinations
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
69 if [ -e $motifs_out ] ; then
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
70 /bin/mv $motifs_out $MOTIFS_OUT
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
71 else
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
72 echo ERROR missing output file: $motifs_out >&2
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
73 status=1
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
74 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
75 if [ -e $matrix_out ] ; then
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
76 /bin/mv $matrix_out $MATRIX_OUT
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
77 else
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
78 echo ERROR missing output file: $matrix_out >&2
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
79 status=1
0
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
80 fi
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
81 #
496bc4eff47e Initial version.
pjbriggs
parents:
diff changeset
82 # Done
4
89315bdc1a8c Uploaded tool version 2.0.3.
pjbriggs
parents: 2
diff changeset
83 exit $status