annotate pal_finder_wrapper.sh @ 1:771ebe02636f draft

Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
author pjbriggs
date Mon, 23 Mar 2015 07:01:37 -0400
parents 3f908e7fff4f
children b6ccc7dd7b02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
1 #!/bin/sh
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
2 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
3 # pal_finder_wrapper.sh: run pal_finder perl script as a Galaxy tool
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
4 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
5 # Usage: run_palfinder.sh FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY FILTERED_MICROSATS [OPTIONS]
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
6 # run_palfinder.sh --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
7 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
8 # Options:
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
9 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
10 # --primer-prefix PREFIX: prefix added to the beginning of all primer names (prPrefixName)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
11 # --2merMinReps N: miniumum number of 2-mer repeat units to detect (0=ignore units of this size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
12 # --3merMinReps N
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
13 # --4merMinReps N
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
14 # --5merMinReps N
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
15 # --6merMinReps N
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
16 # --primer-mispriming-library FASTA: specify a Fasta file with sequences to avoid amplifying
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
17 # --primer-opt-size VALUE: optimum primer length
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
18 # --primer-min-size VALUE: minimum acceptable primer length
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
19 # --primer-max-size VALUE: maximum acceptable primer length
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
20 # --primer-min-gc VALUE: minimum allowable percentage of Gs and Cs in any primer
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
21 # --primer-max-gc VALUE: maximum allowable percentage of Gs and Cs
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
22 # --primer-gc-clamp VALUE: number of consecutive Gs and Cs at 3' end of both left and right primer
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
23 # --primer-max-end-gc VALUE: max number of Gs or Cs in last five 3' bases of left or right primer
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
24 # --primer-min-tm VALUE: minimum acceptable melting temperature (Celsius) for a primer oligo
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
25 # --primer-max-tm VALUE: maximum acceptable melting temperature (Celsius)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
26 # --primer-opt-tm VALUE: optimum melting temperature (Celsius)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
27 # --primer-pair-max-diff-tm VALUE: max difference between melting temps of left & right primers
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
28 # --output_config_file FNAME: write a copy of the config.txt file to FNAME
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
29 # --filter_microsats FNAME: run Graeme Fox's Perl script to filter and sort the
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
30 # microsatellites from pal_finder and write to FNAME
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
31 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
32 # pal_finder is available from http://sourceforge.net/projects/palfinder/
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
33 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
34 # primer3 is available from http://primer3.sourceforge.net/releases.php
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
35 # (nb needs version 2.0.0-alpha)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
36 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
37 # Explicitly set the locations of the pal_finder script, data files and the primer3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
38 # executable by setting the following variables in the environment:
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
39 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
40 # * PALFINDER_SCRIPT_DIR: location of the pal_finder Perl script (defaults to
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
41 # /usr/bin)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
42 # * PALFINDER_DATA_DIR: location of the pal_finder data files (specifically
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
43 # config.txt and simple.ref; defaults to /usr/share/pal_finder_v0.02.04)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
44 # * PRIMER3_CORE_EXE: name of the primer3_core program, which should include the
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
45 # full path if it's not on the Galaxy user's PATH (defaults to primer3_core)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
46 #
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
47 echo "### $(basename $0) ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
48 echo $*
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
49 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
50 # Initialise locations of scripts, data and executables
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
51 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
52 # Set these in the environment to overide at execution time
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
53 : ${PALFINDER_SCRIPT_DIR:=/usr/bin}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
54 : ${PALFINDER_DATA_DIR:=/usr/share/pal_finder_v0.02.04}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
55 : ${PRIMER3_CORE_EXE:=primer3_core}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
56 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
57 # Filter script is in the same directory as this script
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
58 PALFINDER_FILTER_PL=$(dirname $0)/pal_finder_filter.pl
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
59 if [ ! -f $PALFINDER_FILTER_PL ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
60 echo No pal_finder_filter.pl script >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
61 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
62 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
63 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
64 # Check that we have all the components
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
65 function have_program() {
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
66 local program=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
67 local got_program=$(which $program 2>&1 | grep "no $(basename $program) in")
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
68 if [ -z "$got_program" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
69 echo yes
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
70 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
71 echo no
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
72 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
73 }
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
74 if [ "$(have_program $PRIMER3_CORE_EXE)" == "no" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
75 echo "ERROR primer3_core missing: ${PRIMER3_CORE_EXE} not found" >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
76 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
77 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
78 if [ ! -f "${PALFINDER_DATA_DIR}/config.txt" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
79 echo "ERROR pal_finder config.txt not found in ${PALFINDER_DATA_DIR}" >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
80 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
81 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
82 if [ ! -f "${PALFINDER_SCRIPT_DIR}/pal_finder_v0.02.04.pl" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
83 echo "ERROR pal_finder_v0.02.04.pl not found in ${PALFINDER_SCRIPT_DIR}" >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
84 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
85 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
86 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
87 # Initialise parameters used in the config.txt file
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
88 PRIMER_PREFIX="test"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
89 MIN_2_MER_REPS=6
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
90 MIN_3_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
91 MIN_4_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
92 MIN_5_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
93 MIN_6_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
94 PRIMER_MISPRIMING_LIBRARY=$PALFINDER_DATA_DIR/simple.ref
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
95 PRIMER_OPT_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
96 PRIMER_MAX_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
97 PRIMER_MIN_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
98 PRIMER_MAX_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
99 PRIMER_MIN_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
100 PRIMER_GC_CLAMP=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
101 PRIMER_MAX_END_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
102 PRIMER_OPT_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
103 PRIMER_MAX_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
104 PRIMER_MIN_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
105 PRIMER_PAIR_MAX_DIFF_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
106 OUTPUT_CONFIG_FILE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
107 FILTERED_MICROSATS=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
108 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
109 # Collect command line arguments
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
110 if [ $# -lt 2 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
111 echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
112 echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
113 exit
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
114 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
115 if [ "$1" == "--454" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
116 PLATFORM="454"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
117 FNA=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
118 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
119 PLATFORM="Illumina"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
120 FASTQ_R1=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
121 FASTQ_R2=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
122 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
123 MICROSAT_SUMMARY=$3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
124 PAL_SUMMARY=$4
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
125 shift; shift; shift; shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
126 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
127 # Collect command line options
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
128 while [ ! -z "$1" ] ; do
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
129 case "$1" in
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
130 --primer-prefix)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
131 shift
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
132 # Convert spaces to underscores in prefix
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
133 PRIMER_PREFIX=$(echo $1 | tr " " "_")
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
134 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
135 --2merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
136 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
137 MIN_2_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
138 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
139 --3merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
140 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
141 MIN_3_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
142 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
143 --4merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
144 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
145 MIN_4_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
146 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
147 --5merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
148 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
149 MIN_5_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
150 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
151 --6merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
152 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
153 MIN_6_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
154 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
155 --primer-mispriming-library)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
156 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
157 PRIMER_MISPRIMING_LIBRARY=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
158 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
159 --primer-opt-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
160 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
161 PRIMER_OPT_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
162 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
163 --primer-max-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
164 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
165 PRIMER_MAX_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
166 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
167 --primer-min-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
168 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
169 PRIMER_MIN_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
170 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
171 --primer-max-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
172 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
173 PRIMER_MAX_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
174 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
175 --primer-min-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
176 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
177 PRIMER_MIN_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
178 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
179 --primer-gc-clamp)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
180 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
181 PRIMER_GC_CLAMP=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
182 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
183 --primer-max-end-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
184 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
185 PRIMER_MAX_END_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
186 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
187 --primer-opt-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
188 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
189 PRIMER_OPT_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
190 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
191 --primer-max-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
192 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
193 PRIMER_MAX_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
194 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
195 --primer-min-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
196 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
197 PRIMER_MIN_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
198 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
199 --primer-pair-max-diff-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
200 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
201 PRIMER_PAIR_MAX_DIFF_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
202 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
203 --output_config_file)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
204 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
205 OUTPUT_CONFIG_FILE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
206 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
207 --filter_microsats)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
208 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
209 FILTERED_MICROSATS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
210 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
211 *)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
212 echo Unknown option: $1 >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
213 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
214 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
215 esac
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
216 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
217 done
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
218 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
219 # Check that primer3_core is available
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
220 got_primer3=`which $PRIMER3_CORE_EXE 2>&1 | grep -v "no primer3_core in"`
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
221 if [ -z "$got_primer3" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
222 echo ERROR primer3_core not found >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
223 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
224 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
225 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
226 # Set up the working dir
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
227 if [ "$PLATFORM" == "Illumina" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
228 # Paired end Illumina data as input
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
229 if [ $FASTQ_R1 == $FASTQ_R2 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
230 echo ERROR R1 and R2 fastqs are the same file >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
231 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
232 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
233 ln -s $FASTQ_R1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
234 ln -s $FASTQ_R2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
235 fastq_r1=$(basename $FASTQ_R1)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
236 fastq_r2=$(basename $FASTQ_R2)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
237 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
238 # 454 data as input
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
239 ln -s $FNA
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
240 fna=$(basename $FNA)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
241 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
242 ln -s $PRIMER_MISPRIMING_LIBRARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
243 PRIMER_MISPRIMING_LIBRARY=$(basename $PRIMER_MISPRIMING_LIBRARY)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
244 mkdir Output
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
245 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
246 # Copy in the default config.txt file
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
247 echo "### Creating config.txt file for pal_finder run ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
248 /bin/cp $PALFINDER_DATA_DIR/config.txt .
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
249 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
250 # Update the config.txt file with new values
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
251 function set_config_value() {
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
252 local key=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
253 local value=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
254 local config_txt=$3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
255 if [ -z "$value" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
256 echo "No value for $key, left as default"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
257 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
258 echo Setting "$key" to "$value"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
259 sed -i 's,^'"$key"' .*,'"$key"' '"$value"',' $config_txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
260 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
261 }
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
262 # Input files
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
263 set_config_value platform $PLATFORM config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
264 if [ "$PLATFORM" == "Illumina" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
265 set_config_value inputFormat fastq config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
266 set_config_value pairedEnd 1 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
267 set_config_value inputReadFile $fastq_r1 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
268 set_config_value pairedReadFile $fastq_r2 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
269 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
270 set_config_value inputFormat fasta config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
271 set_config_value pairedEnd 0 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
272 set_config_value input454reads $fna config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
273 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
274 # Output files
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
275 set_config_value MicrosatSumOut Output/microsat_summary.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
276 set_config_value PALsummaryOut Output/PAL_summary.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
277 # Microsat info
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
278 set_config_value 2merMinReps $MIN_2_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
279 set_config_value 3merMinReps $MIN_3_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
280 set_config_value 4merMinReps $MIN_4_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
281 set_config_value 5merMinReps $MIN_5_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
282 set_config_value 6merMinReps $MIN_6_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
283 # Primer3 settings
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
284 set_config_value primer3input Output/pr3in.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
285 set_config_value primer3output Output/pr3out.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
286 set_config_value primer3executable $PRIMER3_CORE_EXE config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
287 set_config_value prNamePrefix ${PRIMER_PREFIX}_ config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
288 set_config_value PRIMER_MISPRIMING_LIBRARY "$PRIMER_MISPRIMING_LIBRARY" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
289 set_config_value PRIMER_OPT_SIZE "$PRIMER_OPT_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
290 set_config_value PRIMER_MIN_SIZE "$PRIMER_MIN_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
291 set_config_value PRIMER_MAX_SIZE "$PRIMER_MAX_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
292 set_config_value PRIMER_MIN_GC "$PRIMER_MIN_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
293 set_config_value PRIMER_MAX_GC "$PRIMER_MAX_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
294 set_config_value PRIMER_GC_CLAMP "$PRIMER_GC_CLAMP" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
295 set_config_value PRIMER_MAX_END_GC "$PRIMER_MAX_END_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
296 set_config_value PRIMER_MIN_TM "$PRIMER_MIN_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
297 set_config_value PRIMER_MAX_TM "$PRIMER_MAX_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
298 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
299 set_config_value PRIMER_PAIR_MAX_DIFF_TM "$PRIMER_PAIR_MAX_DIFF_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
300 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
301 # Run pal_finder
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
302 echo "### Running pal_finder ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
303 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 2>&1 | tee pal_finder.log
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
304 echo "### pal_finder finised ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
305 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
306 # Check that log ends with "Done!!" message
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
307 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
308 echo ERROR pal_finder failed to complete successfully >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
309 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
310 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
311 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
312 # Run the pal_finder_filter.pl script from Graeme Fox
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
313 if [ ! -z "$FILTERED_MICROSATS" ] ; then
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
314 echo "### Running filtering script ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
315 perl $PALFINDER_FILTER_PL Output/PAL_summary.txt 2>&1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
316 if [ $? -ne 0 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
317 echo ERROR pal_finder_filter.pl exited with non-zero status >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
318 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
319 elif [ ! -f pal_finder_filter_output.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
320 echo ERROR no output from pal_finder_filter.pl >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
321 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
322 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
323 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
324 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
325 # Clean up
1
771ebe02636f Uploaded version 0.02.04.2: fix bug that causes tool to fail when prefix includes spaces; add explicit dependency on Perl 5.16.3.
pjbriggs
parents: 0
diff changeset
326 echo "### Handling output files ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
327 if [ -f Output/microsat_summary.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
328 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
329 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
330 if [ -f Output/PAL_summary.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
331 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
332 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
333 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f pal_finder_filter_output.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
334 /bin/mv pal_finder_filter_output.txt $FILTERED_MICROSATS
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
335 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
336 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
337 /bin/mv config.txt $OUTPUT_CONFIG_FILE
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
338 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
339 ##
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
340 #