Mercurial > repos > pjbriggs > pal_finder
comparison pal_finder_wrapper.sh @ 3:1cea7b4b838f draft
Uploaded version 0.02.04.3.
author | pjbriggs |
---|---|
date | Fri, 04 Dec 2015 04:36:51 -0500 |
parents | 288a74cd7a8d |
children | ef95b26a2407 |
comparison
equal
deleted
inserted
replaced
2:dff26850370b | 3:1cea7b4b838f |
---|---|
24 # --primer-min-tm VALUE: minimum acceptable melting temperature (Celsius) for a primer oligo | 24 # --primer-min-tm VALUE: minimum acceptable melting temperature (Celsius) for a primer oligo |
25 # --primer-max-tm VALUE: maximum acceptable melting temperature (Celsius) | 25 # --primer-max-tm VALUE: maximum acceptable melting temperature (Celsius) |
26 # --primer-opt-tm VALUE: optimum melting temperature (Celsius) | 26 # --primer-opt-tm VALUE: optimum melting temperature (Celsius) |
27 # --primer-pair-max-diff-tm VALUE: max difference between melting temps of left & right primers | 27 # --primer-pair-max-diff-tm VALUE: max difference between melting temps of left & right primers |
28 # --output_config_file FNAME: write a copy of the config.txt file to FNAME | 28 # --output_config_file FNAME: write a copy of the config.txt file to FNAME |
29 # --filter_microsats FNAME: run Graeme Fox's Perl script to filter and sort the | 29 # --filter_microsats FNAME: write output of filter options FNAME |
30 # microsatellites from pal_finder and write to FNAME | 30 # -assembly FNAME: run the 'assembly' filter option and write to FNAME |
31 # -primers: run the 'primers' filter option | |
32 # -occurrences: run the 'occurrences' filter option | |
33 # -rankmotifs: run the 'rankmotifs' filter option | |
31 # | 34 # |
32 # pal_finder is available from http://sourceforge.net/projects/palfinder/ | 35 # pal_finder is available from http://sourceforge.net/projects/palfinder/ |
33 # | 36 # |
34 # primer3 is available from http://primer3.sourceforge.net/releases.php | 37 # primer3 is available from http://primer3.sourceforge.net/releases.php |
35 # (nb needs version 2.0.0-alpha) | 38 # (nb needs version 2.0.0-alpha) |
53 : ${PALFINDER_SCRIPT_DIR:=/usr/bin} | 56 : ${PALFINDER_SCRIPT_DIR:=/usr/bin} |
54 : ${PALFINDER_DATA_DIR:=/usr/share/pal_finder_v0.02.04} | 57 : ${PALFINDER_DATA_DIR:=/usr/share/pal_finder_v0.02.04} |
55 : ${PRIMER3_CORE_EXE:=primer3_core} | 58 : ${PRIMER3_CORE_EXE:=primer3_core} |
56 # | 59 # |
57 # Filter script is in the same directory as this script | 60 # Filter script is in the same directory as this script |
58 PALFINDER_FILTER_PL=$(dirname $0)/pal_finder_filter.pl | 61 PALFINDER_FILTER=$(dirname $0)/pal_finder_filter_and_assembly.py |
59 if [ ! -f $PALFINDER_FILTER_PL ] ; then | 62 if [ ! -f $PALFINDER_FILTER ] ; then |
60 echo No pal_finder_filter.pl script >&2 | 63 echo No $PALFINDER_FILTER script >&2 |
61 exit 1 | 64 exit 1 |
62 fi | 65 fi |
63 # | 66 # |
64 # Check that we have all the components | 67 # Check that we have all the components |
65 function have_program() { | 68 function have_program() { |
102 PRIMER_OPT_TM= | 105 PRIMER_OPT_TM= |
103 PRIMER_MAX_TM= | 106 PRIMER_MAX_TM= |
104 PRIMER_MIN_TM= | 107 PRIMER_MIN_TM= |
105 PRIMER_PAIR_MAX_DIFF_TM= | 108 PRIMER_PAIR_MAX_DIFF_TM= |
106 OUTPUT_CONFIG_FILE= | 109 OUTPUT_CONFIG_FILE= |
110 OUTPUT_ASSEMBLY= | |
107 FILTERED_MICROSATS= | 111 FILTERED_MICROSATS= |
112 FILTER_OPTIONS= | |
108 # | 113 # |
109 # Collect command line arguments | 114 # Collect command line arguments |
110 if [ $# -lt 2 ] ; then | 115 if [ $# -lt 2 ] ; then |
111 echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" | 116 echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" |
112 echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" | 117 echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" |
127 # Collect command line options | 132 # Collect command line options |
128 while [ ! -z "$1" ] ; do | 133 while [ ! -z "$1" ] ; do |
129 case "$1" in | 134 case "$1" in |
130 --primer-prefix) | 135 --primer-prefix) |
131 shift | 136 shift |
132 # Convert spaces to underscores in prefix | 137 # Convert all non-alphanumeric characters to underscores in prefix |
133 PRIMER_PREFIX=$(echo $1 | tr " " "_") | 138 PRIMER_PREFIX=$(echo -n $1 | tr -s -c "[:alnum:]" "_") |
134 ;; | 139 ;; |
135 --2merMinReps) | 140 --2merMinReps) |
136 shift | 141 shift |
137 MIN_2_MER_REPS=$1 | 142 MIN_2_MER_REPS=$1 |
138 ;; | 143 ;; |
205 OUTPUT_CONFIG_FILE=$1 | 210 OUTPUT_CONFIG_FILE=$1 |
206 ;; | 211 ;; |
207 --filter_microsats) | 212 --filter_microsats) |
208 shift | 213 shift |
209 FILTERED_MICROSATS=$1 | 214 FILTERED_MICROSATS=$1 |
215 ;; | |
216 -primers|-occurrences|-rankmotifs) | |
217 FILTER_OPTIONS="$FILTER_OPTIONS $1" | |
218 ;; | |
219 -assembly) | |
220 FILTER_OPTIONS="$FILTER_OPTIONS $1" | |
221 shift | |
222 OUTPUT_ASSEMBLY=$1 | |
210 ;; | 223 ;; |
211 *) | 224 *) |
212 echo Unknown option: $1 >&2 | 225 echo Unknown option: $1 >&2 |
213 exit 1 | 226 exit 1 |
214 ;; | 227 ;; |
307 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then | 320 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then |
308 echo ERROR pal_finder failed to complete successfully >&2 | 321 echo ERROR pal_finder failed to complete successfully >&2 |
309 exit 1 | 322 exit 1 |
310 fi | 323 fi |
311 # | 324 # |
312 # Run the pal_finder_filter.pl script from Graeme Fox | 325 # Sort outputs into a consistent order regardless of Perl version |
313 if [ ! -z "$FILTERED_MICROSATS" ] ; then | 326 echo "### Sorting outputs ###" |
314 echo "### Running filtering script ###" | 327 head -1 Output/PAL_summary.txt > Output/PAL_summary.sorted.txt |
315 perl $PALFINDER_FILTER_PL Output/PAL_summary.txt 2>&1 | 328 if [ "$PLATFORM" == "Illumina" ] ; then |
329 grep -v "^readPairID" Output/PAL_summary.txt | sort -k 1 >> Output/PAL_summary.sorted.txt | |
330 else | |
331 grep -v "^SequenceID" Output/PAL_summary.txt | sort -k 1 >> Output/PAL_summary.sorted.txt | |
332 fi | |
333 mv Output/PAL_summary.sorted.txt Output/PAL_summary.txt | |
334 # | |
335 # Run the filtering & assembly script | |
336 if [ ! -z "$FILTERED_MICROSATS" ] || [ ! -z "$OUTPUT_ASSEMBLY" ] ; then | |
337 echo "### Running filtering & assembly script ###" | |
338 python $PALFINDER_FILTER -i $fastq_r1 -j $fastq_r2 -p Output/PAL_summary.txt $FILTER_OPTIONS 2>&1 | |
316 if [ $? -ne 0 ] ; then | 339 if [ $? -ne 0 ] ; then |
317 echo ERROR pal_finder_filter.pl exited with non-zero status >&2 | 340 echo ERROR $PALFINDER_FILTER exited with non-zero status >&2 |
318 exit 1 | 341 exit 1 |
319 elif [ ! -f pal_finder_filter_output.txt ] ; then | 342 elif [ ! -f PAL_summary.filtered ] ; then |
320 echo ERROR no output from pal_finder_filter.pl >&2 | 343 echo ERROR no output from $PALFINDER_FILTER >&2 |
321 exit 1 | 344 exit 1 |
322 fi | 345 fi |
323 fi | 346 fi |
324 # | 347 # |
325 # Clean up | 348 # Clean up |
328 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY | 351 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY |
329 fi | 352 fi |
330 if [ -f Output/PAL_summary.txt ] ; then | 353 if [ -f Output/PAL_summary.txt ] ; then |
331 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY | 354 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY |
332 fi | 355 fi |
333 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f pal_finder_filter_output.txt ] ; then | 356 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f PAL_summary.filtered ] ; then |
334 /bin/mv pal_finder_filter_output.txt $FILTERED_MICROSATS | 357 /bin/mv PAL_summary.filtered $FILTERED_MICROSATS |
358 fi | |
359 if [ ! -z "$OUTPUT_ASSEMBLY" ] ; then | |
360 assembly=${fastq_r1%.*}_pal_finder_assembly_output.txt | |
361 if [ -f "$assembly" ] ; then | |
362 /bin/mv $assembly "$OUTPUT_ASSEMBLY" | |
363 fi | |
335 fi | 364 fi |
336 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then | 365 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then |
337 /bin/mv config.txt $OUTPUT_CONFIG_FILE | 366 /bin/mv config.txt $OUTPUT_CONFIG_FILE |
338 fi | 367 fi |
339 ## | 368 ## |