Mercurial > repos > pjbriggs > weeder2
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 |
| rev | line source |
|---|---|
| 0 | 1 #!/bin/sh -e |
| 2 # | |
| 3 # Wrapper script to run weeder2 as a Galaxy tool | |
| 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 | 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 | |
|
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 | 15 # |
| 16 # Other arguments | |
| 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 | 20 shift |
| 21 done | |
| 22 # | |
| 23 # Link to input file | |
| 24 ln -s $FASTA_IN | |
| 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 | 28 # Don't explicitly set the location - Weeder2 from |
| 29 # bioconda handles this automatically | |
| 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 | 36 # Link to the FreqFiles directory as weeder2 executable |
| 37 # expects it to be the same directory | |
| 4 | 38 if [ ! -z "$freqfiles_dir" ] ; then |
| 39 if [ -d $freqfiles_dir ] ; then | |
| 40 echo "Linking to FreqFiles directory: $freqfiles_dir" | |
| 41 ln -s $freqfiles_dir FreqFiles | |
| 42 else | |
| 43 echo "ERROR FreqFiles directory not found" >&2 | |
| 44 exit 1 | |
| 45 fi | |
| 0 | 46 else |
| 4 | 47 echo "WARNING FreqFiles directory not set" >&2 |
| 0 | 48 fi |
| 49 # | |
| 50 # Construct names of input and output files | |
| 4 | 51 fasta=$(basename $FASTA_IN) |
| 52 motifs_out=${fasta}.w2 | |
| 53 matrix_out=${fasta}.matrix.w2 | |
| 0 | 54 # |
| 55 # Construct and run weeder command | |
| 56 # NB weeder logs output to stderr so redirect to stdout | |
| 57 # to prevent the Galaxy tool reporting failure | |
| 58 weeder_cmd="weeder2 -f $fasta -O $SPECIES_CODE $ARGS" | |
| 59 echo "Running $weeder_cmd" | |
| 60 $weeder_cmd 2>&1 | |
| 61 status=$? | |
| 62 if [ $status -ne 0 ] ; then | |
| 63 echo weeder2 command finished with nonzero exit code $status >&2 | |
| 64 echo Command was: $weeder_cmd | |
| 65 exit $status | |
| 66 fi | |
| 67 # | |
| 68 # Move outputs to final destinations | |
| 69 if [ -e $motifs_out ] ; then | |
| 70 /bin/mv $motifs_out $MOTIFS_OUT | |
| 4 | 71 else |
| 72 echo ERROR missing output file: $motifs_out >&2 | |
| 73 status=1 | |
| 0 | 74 fi |
| 75 if [ -e $matrix_out ] ; then | |
| 76 /bin/mv $matrix_out $MATRIX_OUT | |
| 4 | 77 else |
| 78 echo ERROR missing output file: $matrix_out >&2 | |
| 79 status=1 | |
| 0 | 80 fi |
| 81 # | |
| 82 # Done | |
| 4 | 83 exit $status |
