annotate pal_finder_wrapper.sh @ 0:3f908e7fff4f draft

Uploaded first version to toolshed.
author pjbriggs
date Thu, 11 Dec 2014 09:23:24 -0500
parents
children 771ebe02636f
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 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
47 echo $*
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
48 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
49 # Initialise locations of scripts, data and executables
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
50 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
51 # Set these in the environment to overide at execution time
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
52 : ${PALFINDER_SCRIPT_DIR:=/usr/bin}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
53 : ${PALFINDER_DATA_DIR:=/usr/share/pal_finder_v0.02.04}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
54 : ${PRIMER3_CORE_EXE:=primer3_core}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
55 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
56 # Filter script is in the same directory as this script
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
57 PALFINDER_FILTER_PL=$(dirname $0)/pal_finder_filter.pl
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
58 if [ ! -f $PALFINDER_FILTER_PL ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
59 echo No pal_finder_filter.pl script >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
60 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
61 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
62 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
63 # Check that we have all the components
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
64 function have_program() {
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
65 local program=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
66 local got_program=$(which $program 2>&1 | grep "no $(basename $program) in")
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
67 if [ -z "$got_program" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
68 echo yes
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
69 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
70 echo no
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
71 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
72 }
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
73 if [ "$(have_program $PRIMER3_CORE_EXE)" == "no" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
74 echo "ERROR primer3_core missing: ${PRIMER3_CORE_EXE} not found" >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
75 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
76 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
77 if [ ! -f "${PALFINDER_DATA_DIR}/config.txt" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
78 echo "ERROR pal_finder config.txt not found in ${PALFINDER_DATA_DIR}" >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
79 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
80 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
81 if [ ! -f "${PALFINDER_SCRIPT_DIR}/pal_finder_v0.02.04.pl" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
82 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
83 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
84 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
85 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
86 # Initialise parameters used in the config.txt file
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
87 PRIMER_PREFIX="test"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
88 MIN_2_MER_REPS=6
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
89 MIN_3_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
90 MIN_4_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
91 MIN_5_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
92 MIN_6_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
93 PRIMER_MISPRIMING_LIBRARY=$PALFINDER_DATA_DIR/simple.ref
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
94 PRIMER_OPT_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
95 PRIMER_MAX_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
96 PRIMER_MIN_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
97 PRIMER_MAX_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
98 PRIMER_MIN_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
99 PRIMER_GC_CLAMP=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
100 PRIMER_MAX_END_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
101 PRIMER_OPT_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
102 PRIMER_MAX_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
103 PRIMER_MIN_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
104 PRIMER_PAIR_MAX_DIFF_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
105 OUTPUT_CONFIG_FILE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
106 FILTERED_MICROSATS=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
107 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
108 # Collect command line arguments
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
109 if [ $# -lt 2 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
110 echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
111 echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
112 exit
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
113 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
114 if [ "$1" == "--454" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
115 PLATFORM="454"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
116 FNA=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
117 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
118 PLATFORM="Illumina"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
119 FASTQ_R1=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
120 FASTQ_R2=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
121 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
122 MICROSAT_SUMMARY=$3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
123 PAL_SUMMARY=$4
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
124 shift; shift; shift; shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
125 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
126 # Collect command line options
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
127 while [ ! -z "$1" ] ; do
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
128 case "$1" in
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
129 --primer-prefix)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
130 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
131 PRIMER_PREFIX=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
132 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
133 --2merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
134 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
135 MIN_2_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
136 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
137 --3merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
138 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
139 MIN_3_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
140 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
141 --4merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
142 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
143 MIN_4_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
144 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
145 --5merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
146 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
147 MIN_5_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
148 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
149 --6merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
150 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
151 MIN_6_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
152 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
153 --primer-mispriming-library)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
154 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
155 PRIMER_MISPRIMING_LIBRARY=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
156 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
157 --primer-opt-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
158 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
159 PRIMER_OPT_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
160 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
161 --primer-max-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
162 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
163 PRIMER_MAX_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
164 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
165 --primer-min-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
166 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
167 PRIMER_MIN_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
168 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
169 --primer-max-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
170 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
171 PRIMER_MAX_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
172 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
173 --primer-min-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
174 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
175 PRIMER_MIN_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
176 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
177 --primer-gc-clamp)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
178 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
179 PRIMER_GC_CLAMP=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
180 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
181 --primer-max-end-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
182 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
183 PRIMER_MAX_END_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
184 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
185 --primer-opt-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
186 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
187 PRIMER_OPT_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
188 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
189 --primer-max-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
190 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
191 PRIMER_MAX_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
192 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
193 --primer-min-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
194 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
195 PRIMER_MIN_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
196 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
197 --primer-pair-max-diff-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
198 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
199 PRIMER_PAIR_MAX_DIFF_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
200 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
201 --output_config_file)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
202 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
203 OUTPUT_CONFIG_FILE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
204 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
205 --filter_microsats)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
206 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
207 FILTERED_MICROSATS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
208 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
209 *)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
210 echo Unknown option: $1 >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
211 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
212 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
213 esac
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
214 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
215 done
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
216 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
217 # Check that primer3_core is available
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
218 got_primer3=`which $PRIMER3_CORE_EXE 2>&1 | grep -v "no primer3_core in"`
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
219 if [ -z "$got_primer3" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
220 echo ERROR primer3_core not found >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
221 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
222 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
223 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
224 # Set up the working dir
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
225 if [ "$PLATFORM" == "Illumina" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
226 # Paired end Illumina data as input
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
227 if [ $FASTQ_R1 == $FASTQ_R2 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
228 echo ERROR R1 and R2 fastqs are the same file >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
229 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
230 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
231 ln -s $FASTQ_R1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
232 ln -s $FASTQ_R2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
233 fastq_r1=$(basename $FASTQ_R1)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
234 fastq_r2=$(basename $FASTQ_R2)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
235 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
236 # 454 data as input
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
237 ln -s $FNA
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
238 fna=$(basename $FNA)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
239 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
240 ln -s $PRIMER_MISPRIMING_LIBRARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
241 PRIMER_MISPRIMING_LIBRARY=$(basename $PRIMER_MISPRIMING_LIBRARY)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
242 mkdir Output
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
243 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
244 # Copy in the default config.txt file
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
245 /bin/cp $PALFINDER_DATA_DIR/config.txt .
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
246 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
247 # Update the config.txt file with new values
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
248 function set_config_value() {
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
249 local key=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
250 local value=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
251 local config_txt=$3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
252 if [ -z "$value" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
253 echo "No value for $key, left as default"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
254 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
255 echo Setting "$key" to "$value"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
256 sed -i 's,^'"$key"' .*,'"$key"' '"$value"',' $config_txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
257 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
258 }
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
259 # Input files
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
260 set_config_value platform $PLATFORM config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
261 if [ "$PLATFORM" == "Illumina" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
262 set_config_value inputFormat fastq config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
263 set_config_value pairedEnd 1 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
264 set_config_value inputReadFile $fastq_r1 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
265 set_config_value pairedReadFile $fastq_r2 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
266 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
267 set_config_value inputFormat fasta config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
268 set_config_value pairedEnd 0 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
269 set_config_value input454reads $fna config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
270 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
271 # Output files
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
272 set_config_value MicrosatSumOut Output/microsat_summary.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
273 set_config_value PALsummaryOut Output/PAL_summary.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
274 # Microsat info
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
275 set_config_value 2merMinReps $MIN_2_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
276 set_config_value 3merMinReps $MIN_3_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
277 set_config_value 4merMinReps $MIN_4_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
278 set_config_value 5merMinReps $MIN_5_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
279 set_config_value 6merMinReps $MIN_6_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
280 # Primer3 settings
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
281 set_config_value primer3input Output/pr3in.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
282 set_config_value primer3output Output/pr3out.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
283 set_config_value primer3executable $PRIMER3_CORE_EXE config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
284 set_config_value prNamePrefix ${PRIMER_PREFIX}_ config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
285 set_config_value PRIMER_MISPRIMING_LIBRARY "$PRIMER_MISPRIMING_LIBRARY" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
286 set_config_value PRIMER_OPT_SIZE "$PRIMER_OPT_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
287 set_config_value PRIMER_MIN_SIZE "$PRIMER_MIN_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
288 set_config_value PRIMER_MAX_SIZE "$PRIMER_MAX_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
289 set_config_value PRIMER_MIN_GC "$PRIMER_MIN_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
290 set_config_value PRIMER_MAX_GC "$PRIMER_MAX_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
291 set_config_value PRIMER_GC_CLAMP "$PRIMER_GC_CLAMP" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
292 set_config_value PRIMER_MAX_END_GC "$PRIMER_MAX_END_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
293 set_config_value PRIMER_MIN_TM "$PRIMER_MIN_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
294 set_config_value PRIMER_MAX_TM "$PRIMER_MAX_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
295 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
296 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
297 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
298 # Run pal_finder
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
299 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 2>&1 | tee pal_finder.log
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
300 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
301 # Check that log ends with "Done!!" message
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
302 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
303 echo ERROR pal_finder failed to complete successfully >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
304 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
305 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
306 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
307 # Run the pal_finder_filter.pl script from Graeme Fox
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
308 if [ ! -z "$FILTERED_MICROSATS" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
309 perl $PALFINDER_FILTER_PL Output/PAL_summary.txt 2>&1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
310 if [ $? -ne 0 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
311 echo ERROR pal_finder_filter.pl exited with non-zero status >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
312 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
313 elif [ ! -f pal_finder_filter_output.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
314 echo ERROR no output from pal_finder_filter.pl >&2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
315 exit 1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
316 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
317 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
318 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
319 # Clean up
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
320 if [ -f Output/microsat_summary.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
321 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
322 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
323 if [ -f Output/PAL_summary.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
324 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
325 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
326 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f pal_finder_filter_output.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
327 echo Moving pal_finder_filter_output.txt to $FILTERED_MICROSATS
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
328 /bin/mv pal_finder_filter_output.txt $FILTERED_MICROSATS
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
329 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
330 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
331 /bin/mv config.txt $OUTPUT_CONFIG_FILE
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
332 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
333 ##
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
334 #