Mercurial > repos > pjbriggs > weeder2
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 |
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 |
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 | 35 # Link to the FreqFiles directory as weeder2 executable |
36 # expects it to be the same directory | |
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 | 39 ln -s $freqfiles_dir FreqFiles |
40 else | |
41 echo "ERROR FreqFiles directory not found" >&2 | |
42 exit 1 | |
43 fi | |
44 # | |
45 # Construct names of input and output files | |
46 fasta=`basename $FASTA_IN` | |
47 motifs_out=$fasta.w2 | |
48 matrix_out=$fasta.matrix.w2 | |
49 # | |
50 # Construct and run weeder command | |
51 # NB weeder logs output to stderr so redirect to stdout | |
52 # to prevent the Galaxy tool reporting failure | |
53 weeder_cmd="weeder2 -f $fasta -O $SPECIES_CODE $ARGS" | |
54 echo "Running $weeder_cmd" | |
55 $weeder_cmd 2>&1 | |
56 status=$? | |
57 if [ $status -ne 0 ] ; then | |
58 echo weeder2 command finished with nonzero exit code $status >&2 | |
59 echo Command was: $weeder_cmd | |
60 exit $status | |
61 fi | |
62 # | |
63 # Move outputs to final destinations | |
64 if [ -e $motifs_out ] ; then | |
65 /bin/mv $motifs_out $MOTIFS_OUT | |
66 fi | |
67 if [ -e $matrix_out ] ; then | |
68 /bin/mv $matrix_out $MATRIX_OUT | |
69 fi | |
70 # | |
71 # Done |