annotate pal_finder_wrapper.sh @ 9:52dbe2089d14 draft default tip

Version 0.02.04.8 (update fastq subsetting).
author pjbriggs
date Wed, 04 Jul 2018 06:05:52 -0400
parents 4e625d3672ba
children
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
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
29 # --bad_primer_ranges FNAME: write a list of the read IDs generating bad primer ranges to FNAME
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
30 # --filter_microsats FNAME: write output of filter options to FNAME
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
31 # -assembly FNAME: run the 'assembly' filter option and write to FNAME
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
32 # -primers: run the 'primers' filter option
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
33 # -occurrences: run the 'occurrences' filter option
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
34 # -rankmotifs: run the 'rankmotifs' filter option
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
35 # --subset N: use a subset of reads of size N
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
36 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
37 # pal_finder is available from http://sourceforge.net/projects/palfinder/
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
38 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
39 # primer3 is available from http://primer3.sourceforge.net/releases.php
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
40 # (nb needs version 2.0.0-alpha)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
41 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
42 # Explicitly set the locations of the pal_finder script, data files and the primer3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
43 # executable by setting the following variables in the environment:
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
44 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
45 # * PALFINDER_SCRIPT_DIR: location of the pal_finder Perl script (defaults to
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
46 # /usr/bin)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
47 # * PALFINDER_DATA_DIR: location of the pal_finder data files (specifically
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
48 # config.txt and simple.ref; defaults to /usr/share/pal_finder_v0.02.04)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
49 # * PRIMER3_CORE_EXE: name of the primer3_core program, which should include the
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
50 # 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
51 #
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
52 echo "### $(basename $0) ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
53 echo $*
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
54 #
6
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
55 # Maximum size reporting log file contents
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
56 MAX_LINES=500
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
57 #
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
58 # Get helper functions
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
59 . $(dirname $0)/pal_finder_wrapper_utils.sh
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
60 #
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
61 # Initialise locations of scripts, data and executables
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
62 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
63 # Set these in the environment to overide at execution time
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
64 : ${PALFINDER_SCRIPT_DIR:=/usr/bin}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
65 : ${PALFINDER_DATA_DIR:=/usr/share/pal_finder_v0.02.04}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
66 : ${PRIMER3_CORE_EXE:=primer3_core}
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
67 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
68 # Filter script is in the same directory as this script
3
e1a14ed7a9d6 Updated to version 0.02.04.4 (new pal_filter script)
pjbriggs
parents: 2
diff changeset
69 PALFINDER_FILTER=$(dirname $0)/pal_filter.py
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
70 if [ ! -f $PALFINDER_FILTER ] ; then
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
71 fatal No $PALFINDER_FILTER script
0
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 # Check that we have all the components
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
75 if [ "$(have_program $PRIMER3_CORE_EXE)" == "no" ] ; then
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
76 fatal "primer3_core missing: ${PRIMER3_CORE_EXE} not found"
0
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
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
79 fatal "pal_finder config.txt not found in ${PALFINDER_DATA_DIR}"
0
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
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
82 fatal "pal_finder_v0.02.04.pl not found in ${PALFINDER_SCRIPT_DIR}"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
83 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
84 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
85 # Initialise parameters used in the config.txt file
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
86 PRIMER_PREFIX="test"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
87 MIN_2_MER_REPS=6
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
88 MIN_3_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
89 MIN_4_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
90 MIN_5_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
91 MIN_6_MER_REPS=0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
92 PRIMER_MISPRIMING_LIBRARY=$PALFINDER_DATA_DIR/simple.ref
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
93 PRIMER_OPT_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
94 PRIMER_MAX_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
95 PRIMER_MIN_SIZE=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
96 PRIMER_MAX_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
97 PRIMER_MIN_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
98 PRIMER_GC_CLAMP=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
99 PRIMER_MAX_END_GC=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
100 PRIMER_OPT_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
101 PRIMER_MAX_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
102 PRIMER_MIN_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
103 PRIMER_PAIR_MAX_DIFF_TM=
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
104 OUTPUT_CONFIG_FILE=
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
105 OUTPUT_ASSEMBLY=
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
106 FILTERED_MICROSATS=
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
107 FILTER_OPTIONS=
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
108 SUBSET=
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
109 RANDOM_SEED=568765
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
110 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
111 # Collect command line arguments
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
112 if [ $# -lt 2 ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
113 echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
114 echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]"
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
115 fatal "Bad command line"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
116 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
117 if [ "$1" == "--454" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
118 PLATFORM="454"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
119 FNA=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
120 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
121 PLATFORM="Illumina"
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
122 FASTQ_R1=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
123 FASTQ_R2=$2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
124 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
125 MICROSAT_SUMMARY=$3
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
126 PAL_SUMMARY=$4
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
127 shift; shift; shift; shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
128 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
129 # Collect command line options
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
130 while [ ! -z "$1" ] ; do
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
131 case "$1" in
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
132 --primer-prefix)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
133 shift
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
134 # Convert all non-alphanumeric characters to underscores in prefix
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
135 PRIMER_PREFIX=$(echo -n $1 | tr -s -c "[:alnum:]" "_")
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
136 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
137 --2merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
138 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
139 MIN_2_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 --3merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
142 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
143 MIN_3_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 --4merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
146 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
147 MIN_4_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 --5merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
150 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
151 MIN_5_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 --6merMinReps)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
154 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
155 MIN_6_MER_REPS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
156 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
157 --primer-mispriming-library)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
158 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
159 PRIMER_MISPRIMING_LIBRARY=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
160 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
161 --primer-opt-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_OPT_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-max-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_MAX_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-min-size)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
170 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
171 PRIMER_MIN_SIZE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
172 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
173 --primer-max-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_MAX_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-min-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
178 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
179 PRIMER_MIN_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
180 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
181 --primer-gc-clamp)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
182 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
183 PRIMER_GC_CLAMP=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
184 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
185 --primer-max-end-gc)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
186 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
187 PRIMER_MAX_END_GC=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
188 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
189 --primer-opt-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_OPT_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-max-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_MAX_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-min-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_MIN_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
200 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
201 --primer-pair-max-diff-tm)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
202 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
203 PRIMER_PAIR_MAX_DIFF_TM=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
204 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
205 --output_config_file)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
206 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
207 OUTPUT_CONFIG_FILE=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
208 ;;
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
209 --bad_primer_ranges)
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
210 shift
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
211 BAD_PRIMER_RANGES=$1
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
212 ;;
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
213 --filter_microsats)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
214 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
215 FILTERED_MICROSATS=$1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
216 ;;
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
217 -primers|-occurrences|-rankmotifs)
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
218 FILTER_OPTIONS="$FILTER_OPTIONS $1"
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
219 ;;
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
220 -assembly)
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
221 FILTER_OPTIONS="$FILTER_OPTIONS $1"
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
222 shift
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
223 OUTPUT_ASSEMBLY=$1
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
224 ;;
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
225 --subset)
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
226 shift
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
227 SUBSET=$1
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
228 ;;
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
229 *)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
230 echo Unknown option: $1 >&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 ;;
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
233 esac
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
234 shift
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
235 done
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
236 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
237 # Check that primer3_core is available
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
238 got_primer3=`which $PRIMER3_CORE_EXE 2>&1 | grep -v "no primer3_core in"`
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
239 if [ -z "$got_primer3" ] ; then
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
240 fatal "primer3_core not found"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
241 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
242 #
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
243 # Check the n-mers specification
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
244 if [ $MIN_6_MER_REPS -ne 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
245 if [ $MIN_5_MER_REPS -eq 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
246 fatal "Minimum number of 5-mers cannot be zero if number of 6-mers is non-zero"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
247 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
248 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
249 if [ $MIN_5_MER_REPS -ne 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
250 if [ $MIN_4_MER_REPS -eq 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
251 fatal "Minimum number of 4-mers cannot be zero if number of 5-mers is non-zero"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
252 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
253 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
254 if [ $MIN_4_MER_REPS -ne 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
255 if [ $MIN_3_MER_REPS -eq 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
256 fatal "Minimum number of 3-mers cannot be zero if number of 4-mers is non-zero"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
257 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
258 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
259 if [ $MIN_2_MER_REPS -eq 0 ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
260 fatal "Minimum number of 2-mer repeats cannot be zero"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
261 fi
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
262 # Set up the working dir
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
263 if [ "$PLATFORM" == "Illumina" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
264 # Paired end Illumina data as input
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
265 if [ $FASTQ_R1 == $FASTQ_R2 ] ; then
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
266 fatal ERROR R1 and R2 fastqs are the same file
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
267 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
268 ln -s $FASTQ_R1
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
269 ln -s $FASTQ_R2
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
270 fastq_r1=$(basename $FASTQ_R1)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
271 fastq_r2=$(basename $FASTQ_R2)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
272 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
273 # 454 data as input
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
274 ln -s $FNA
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
275 fna=$(basename $FNA)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
276 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
277 ln -s $PRIMER_MISPRIMING_LIBRARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
278 PRIMER_MISPRIMING_LIBRARY=$(basename $PRIMER_MISPRIMING_LIBRARY)
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
279 mkdir Output
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
280 #
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
281 # Use a subset of reads
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
282 if [ ! -z "$SUBSET" ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
283 echo "### Extracting subset of reads ###"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
284 $(dirname $0)/fastq_subset.py -n $SUBSET -s $RANDOM_SEED $fastq_r1 $fastq_r2
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
285 fastq_r1="subset_r1.fq"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
286 fastq_r2="subset_r2.fq"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
287 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
288 #
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
289 # 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
290 echo "### Creating config.txt file for pal_finder run ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
291 /bin/cp $PALFINDER_DATA_DIR/config.txt .
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
292 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
293 # Update the config.txt file with new values
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
294 # Input files
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
295 set_config_value platform $PLATFORM config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
296 if [ "$PLATFORM" == "Illumina" ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
297 set_config_value inputFormat fastq config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
298 set_config_value pairedEnd 1 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
299 set_config_value inputReadFile $fastq_r1 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
300 set_config_value pairedReadFile $fastq_r2 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
301 else
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
302 set_config_value inputFormat fasta config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
303 set_config_value pairedEnd 0 config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
304 set_config_value input454reads $fna config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
305 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
306 # Output files
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
307 set_config_value MicrosatSumOut Output/microsat_summary.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
308 set_config_value PALsummaryOut Output/PAL_summary.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
309 # Microsat info
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
310 set_config_value 2merMinReps $MIN_2_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
311 set_config_value 3merMinReps $MIN_3_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
312 set_config_value 4merMinReps $MIN_4_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
313 set_config_value 5merMinReps $MIN_5_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
314 set_config_value 6merMinReps $MIN_6_MER_REPS config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
315 # Primer3 settings
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
316 set_config_value primer3input Output/pr3in.txt config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
317 set_config_value primer3output Output/pr3out.txt config.txt
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
318 set_config_value keepPrimer3files 1 config.txt
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
319 set_config_value primer3executable $PRIMER3_CORE_EXE config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
320 set_config_value prNamePrefix ${PRIMER_PREFIX}_ config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
321 set_config_value PRIMER_MISPRIMING_LIBRARY "$PRIMER_MISPRIMING_LIBRARY" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
322 set_config_value PRIMER_OPT_SIZE "$PRIMER_OPT_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
323 set_config_value PRIMER_MIN_SIZE "$PRIMER_MIN_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
324 set_config_value PRIMER_MAX_SIZE "$PRIMER_MAX_SIZE" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
325 set_config_value PRIMER_MIN_GC "$PRIMER_MIN_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
326 set_config_value PRIMER_MAX_GC "$PRIMER_MAX_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
327 set_config_value PRIMER_GC_CLAMP "$PRIMER_GC_CLAMP" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
328 set_config_value PRIMER_MAX_END_GC "$PRIMER_MAX_END_GC" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
329 set_config_value PRIMER_MIN_TM "$PRIMER_MIN_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
330 set_config_value PRIMER_MAX_TM "$PRIMER_MAX_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
331 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
332 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
333 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
334 # 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
335 echo "### Running pal_finder ###"
6
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
336 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 1>pal_finder.log 2>&1
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
337 echo "### pal_finder finished ###"
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
338 #
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
339 # Handlers the pal_finder log file
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
340 echo "### Output from pal_finder ###"
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
341 if [ $(wc -l pal_finder.log | cut -d" " -f1) -gt $MAX_LINES ] ; then
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
342 echo WARNING output too long, truncated to last $MAX_LINES lines:
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
343 echo ...
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
344 fi
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
345 tail -$MAX_LINES pal_finder.log
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
346 #
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
347 # Check for success/failure
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
348 if [ ! -z "$(tail -n 1 pal_finder.log | grep 'No microsatellites found in any reads. Ending script.')" ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
349 # No microsatellites found
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
350 fatal ERROR pal_finder failed to locate any microsatellites
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
351 exit 1
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
352 elif [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
353 # Log doesn't end with "Done!!" (indicates failure)
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
354 fatal ERROR pal_finder failed to complete successfully
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
355 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
356 echo "### pal_finder finished ###"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
357 #
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
358 # Check for errors in pal_finder output
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
359 echo "### Checking for errors ###"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
360 if [ ! -z "$(grep 'primer3_core: Illegal element in PRIMER_PRODUCT_SIZE_RANGE' pal_finder.log)" ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
361 echo WARNING primer3 terminated prematurely due to bad product size ranges
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
362 $(find_bad_primer_ranges Output/pr3in.txt bad_primer_ranges.txt)
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
363 N_BAD_PRIMERS=$(cat bad_primer_ranges.txt | wc -l)
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
364 if [ -z "$BAD_PRIMER_RANGES" ] ; then
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
365 # No output file so report to stderr
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
366 cat <<EOF
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
367
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
368 Pal_finder generated bad ranges for the following read IDs:
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
369
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
370 EOF
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
371 cat bad_primer_ranges.txt
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
372 cat <<EOF
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
373
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
374 This error can occur when input data contains short R1 reads and has
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
375 has not been properly trimmed and filtered.
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
376
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
377 EOF
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
378 else
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
379 # Move the bad ranges to the specified file
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
380 echo "### Writing read IDs with bad primer ranges ###"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
381 /bin/mv bad_primer_ranges.txt "$BAD_PRIMER_RANGES"
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
382 fi
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
383 else
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
384 N_BAD_PRIMERS=0
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
385 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
386 #
7
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
387 # Sort microsat_summary output
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
388 echo "### Sorting microsat summary output ###"
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
389 head -n 7 Output/microsat_summary.txt | sort >microsat_summary.sorted
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
390 echo "readsWithBadRanges:"$'\t'"$((N_BAD_PRIMERS * 2))" >>microsat_summary.sorted
7
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
391 grep "^$" Output/microsat_summary.txt>>microsat_summary.sorted
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
392 grep "^Microsat Type" Output/microsat_summary.txt >>microsat_summary.sorted
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
393 tail -n +11 Output/microsat_summary.txt | sort -r -n -k 5 >>microsat_summary.sorted
7
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
394 mv microsat_summary.sorted Output/microsat_summary.txt
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
395 #
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
396 # Sort PAL_summary output
5e133b7b79a6 Uploaded version 0.02.04.6 (uses conda dependency resolution).
pjbriggs
parents: 6
diff changeset
397 echo "### Sorting PAL summary output ###"
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
398 head -1 Output/PAL_summary.txt > Output/PAL_summary.sorted.txt
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
399 if [ "$PLATFORM" == "Illumina" ] ; then
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
400 grep -v "^readPairID" Output/PAL_summary.txt | sort -k 1 >> Output/PAL_summary.sorted.txt
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
401 else
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
402 grep -v "^SequenceID" Output/PAL_summary.txt | sort -k 1 >> Output/PAL_summary.sorted.txt
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
403 fi
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
404 mv Output/PAL_summary.sorted.txt Output/PAL_summary.txt
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
405 #
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
406 # Run the filtering & assembly script
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
407 if [ ! -z "$FILTERED_MICROSATS" ] || [ ! -z "$OUTPUT_ASSEMBLY" ] ; then
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
408 echo "### Running filtering & assembly script ###"
6
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
409 python $PALFINDER_FILTER -i $fastq_r1 -j $fastq_r2 -p Output/PAL_summary.txt $FILTER_OPTIONS 1>pal_filter.log 2>&1
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
410 echo "### Output from pal_filter ###"
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
411 if [ $(wc -l pal_filter.log | cut -d" " -f1) -gt $MAX_LINES ] ; then
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
412 echo WARNING output too long, truncated to last $MAX_LINES lines:
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
413 echo ...
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
414 fi
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
415 tail -$MAX_LINES pal_filter.log
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
416 if [ $? -ne 0 ] ; then
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
417 fatal $PALFINDER_FILTER exited with non-zero status
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
418 elif [ ! -f PAL_summary.filtered ] ; then
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
419 fatal no output from $PALFINDER_FILTER
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
420 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
421 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
422 #
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
423 # 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
424 echo "### Handling output files ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
425 if [ -f Output/microsat_summary.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
426 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
427 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
428 if [ -f Output/PAL_summary.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
429 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
430 fi
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
431 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f PAL_summary.filtered ] ; then
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
432 /bin/mv PAL_summary.filtered $FILTERED_MICROSATS
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
433 fi
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
434 if [ ! -z "$OUTPUT_ASSEMBLY" ] ; then
3
e1a14ed7a9d6 Updated to version 0.02.04.4 (new pal_filter script)
pjbriggs
parents: 2
diff changeset
435 assembly=${fastq_r1%.*}_pal_filter_assembly_output.txt
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
436 if [ -f "$assembly" ] ; then
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
437 /bin/mv $assembly "$OUTPUT_ASSEMBLY"
3
e1a14ed7a9d6 Updated to version 0.02.04.4 (new pal_filter script)
pjbriggs
parents: 2
diff changeset
438 else
8
4e625d3672ba Pal_finder tool version 0.02.04.7: add detection/reporting of bad ranges; enable subset of reads to be used; check n-mers.
pjbriggs
parents: 7
diff changeset
439 fatal no assembly output found
2
b6ccc7dd7b02 Version 0.02.04.3.
pjbriggs
parents: 1
diff changeset
440 fi
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
441 fi
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
442 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
443 /bin/mv config.txt $OUTPUT_CONFIG_FILE
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
444 fi
6
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
445 #
a73c48890bde Version v0.02.04.5: handle large output files
pjbriggs
parents: 3
diff changeset
446 echo "### Pal_finder tool completed ###"
0
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
447 ##
3f908e7fff4f Uploaded first version to toolshed.
pjbriggs
parents:
diff changeset
448 #