Mercurial > repos > pjbriggs > pal_finder
annotate pal_finder_wrapper.sh @ 13:88c972081f15 draft
Uploaded
| author | pjbriggs |
|---|---|
| date | Thu, 15 Mar 2018 11:52:19 -0400 |
| parents | d26fb5260c67 |
| children | 3f8bf1a0403b |
| rev | line source |
|---|---|
| 0 | 1 #!/bin/sh |
| 2 # | |
| 3 # pal_finder_wrapper.sh: run pal_finder perl script as a Galaxy tool | |
| 4 # | |
| 5 # Usage: run_palfinder.sh FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY FILTERED_MICROSATS [OPTIONS] | |
| 6 # run_palfinder.sh --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS] | |
| 7 # | |
| 8 # Options: | |
| 9 # | |
| 10 # --primer-prefix PREFIX: prefix added to the beginning of all primer names (prPrefixName) | |
| 11 # --2merMinReps N: miniumum number of 2-mer repeat units to detect (0=ignore units of this size) | |
| 12 # --3merMinReps N | |
| 13 # --4merMinReps N | |
| 14 # --5merMinReps N | |
| 15 # --6merMinReps N | |
| 16 # --primer-mispriming-library FASTA: specify a Fasta file with sequences to avoid amplifying | |
| 17 # --primer-opt-size VALUE: optimum primer length | |
| 18 # --primer-min-size VALUE: minimum acceptable primer length | |
| 19 # --primer-max-size VALUE: maximum acceptable primer length | |
| 20 # --primer-min-gc VALUE: minimum allowable percentage of Gs and Cs in any primer | |
| 21 # --primer-max-gc VALUE: maximum allowable percentage of Gs and Cs | |
| 22 # --primer-gc-clamp VALUE: number of consecutive Gs and Cs at 3' end of both left and right primer | |
| 23 # --primer-max-end-gc VALUE: max number of Gs or Cs in last five 3' bases of left or right primer | |
| 24 # --primer-min-tm VALUE: minimum acceptable melting temperature (Celsius) for a primer oligo | |
| 25 # --primer-max-tm VALUE: maximum acceptable 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 | |
| 28 # --output_config_file FNAME: write a copy of the config.txt file to FNAME | |
| 3 | 29 # --filter_microsats FNAME: write output of filter options 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 | |
| 0 | 34 # |
| 35 # pal_finder is available from http://sourceforge.net/projects/palfinder/ | |
| 36 # | |
| 37 # primer3 is available from http://primer3.sourceforge.net/releases.php | |
| 38 # (nb needs version 2.0.0-alpha) | |
| 39 # | |
| 40 # Explicitly set the locations of the pal_finder script, data files and the primer3 | |
| 41 # executable by setting the following variables in the environment: | |
| 42 # | |
| 43 # * PALFINDER_SCRIPT_DIR: location of the pal_finder Perl script (defaults to | |
| 44 # /usr/bin) | |
| 45 # * PALFINDER_DATA_DIR: location of the pal_finder data files (specifically | |
| 46 # config.txt and simple.ref; defaults to /usr/share/pal_finder_v0.02.04) | |
| 47 # * PRIMER3_CORE_EXE: name of the primer3_core program, which should include the | |
| 48 # full path if it's not on the Galaxy user's PATH (defaults to primer3_core) | |
| 49 # | |
|
1
288a74cd7a8d
Explicitly build and use perl 5.16.3 as a tool dependency.
pjbriggs
parents:
0
diff
changeset
|
50 echo "### $(basename $0) ###" |
| 0 | 51 echo $* |
| 52 # | |
| 8 | 53 # Maximum size reporting log file contents |
| 54 MAX_LINES=500 | |
| 55 # | |
| 0 | 56 # Initialise locations of scripts, data and executables |
| 57 # | |
| 58 # Set these in the environment to overide at execution time | |
| 59 : ${PALFINDER_SCRIPT_DIR:=/usr/bin} | |
| 60 : ${PALFINDER_DATA_DIR:=/usr/share/pal_finder_v0.02.04} | |
| 61 : ${PRIMER3_CORE_EXE:=primer3_core} | |
| 62 # | |
| 63 # Filter script is in the same directory as this script | |
| 5 | 64 PALFINDER_FILTER=$(dirname $0)/pal_filter.py |
| 3 | 65 if [ ! -f $PALFINDER_FILTER ] ; then |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
66 echo No $PALFINDER_FILTER script >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
67 exit 1 |
| 0 | 68 fi |
| 69 # | |
| 70 # Check that we have all the components | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
71 function have_program() { |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
72 local program=$1 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
73 local got_program=$(which $program 2>&1 | grep "no $(basename $program) in") |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
74 if [ -z "$got_program" ] ; then |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
75 echo yes |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
76 else |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
77 echo no |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
78 fi |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
79 } |
| 0 | 80 if [ "$(have_program $PRIMER3_CORE_EXE)" == "no" ] ; then |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
81 echo "ERROR primer3_core missing: ${PRIMER3_CORE_EXE} not found" >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
82 exit 1 |
| 0 | 83 fi |
| 84 if [ ! -f "${PALFINDER_DATA_DIR}/config.txt" ] ; then | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
85 echo "ERROR pal_finder config.txt not found in ${PALFINDER_DATA_DIR}" >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
86 exit 1 |
| 0 | 87 fi |
| 88 if [ ! -f "${PALFINDER_SCRIPT_DIR}/pal_finder_v0.02.04.pl" ] ; then | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
89 echo "ERROR pal_finder_v0.02.04.pl not found in ${PALFINDER_SCRIPT_DIR}" >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
90 exit 1 |
| 0 | 91 fi |
| 92 # | |
| 93 # Initialise parameters used in the config.txt file | |
| 94 PRIMER_PREFIX="test" | |
| 95 MIN_2_MER_REPS=6 | |
| 96 MIN_3_MER_REPS=0 | |
| 97 MIN_4_MER_REPS=0 | |
| 98 MIN_5_MER_REPS=0 | |
| 99 MIN_6_MER_REPS=0 | |
| 100 PRIMER_MISPRIMING_LIBRARY=$PALFINDER_DATA_DIR/simple.ref | |
| 101 PRIMER_OPT_SIZE= | |
| 102 PRIMER_MAX_SIZE= | |
| 103 PRIMER_MIN_SIZE= | |
| 104 PRIMER_MAX_GC= | |
| 105 PRIMER_MIN_GC= | |
| 106 PRIMER_GC_CLAMP= | |
| 107 PRIMER_MAX_END_GC= | |
| 108 PRIMER_OPT_TM= | |
| 109 PRIMER_MAX_TM= | |
| 110 PRIMER_MIN_TM= | |
| 111 PRIMER_PAIR_MAX_DIFF_TM= | |
| 112 OUTPUT_CONFIG_FILE= | |
| 3 | 113 OUTPUT_ASSEMBLY= |
| 0 | 114 FILTERED_MICROSATS= |
| 3 | 115 FILTER_OPTIONS= |
| 0 | 116 # |
| 117 # Collect command line arguments | |
| 118 if [ $# -lt 2 ] ; then | |
| 119 echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" | |
| 120 echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
121 exits |
| 0 | 122 fi |
| 123 if [ "$1" == "--454" ] ; then | |
| 124 PLATFORM="454" | |
| 125 FNA=$2 | |
| 126 else | |
| 127 PLATFORM="Illumina" | |
| 128 FASTQ_R1=$1 | |
| 129 FASTQ_R2=$2 | |
| 130 fi | |
| 131 MICROSAT_SUMMARY=$3 | |
| 132 PAL_SUMMARY=$4 | |
| 133 shift; shift; shift; shift | |
| 134 # | |
| 135 # Collect command line options | |
| 136 while [ ! -z "$1" ] ; do | |
| 137 case "$1" in | |
| 138 --primer-prefix) | |
| 139 shift | |
| 3 | 140 # Convert all non-alphanumeric characters to underscores in prefix |
| 141 PRIMER_PREFIX=$(echo -n $1 | tr -s -c "[:alnum:]" "_") | |
| 0 | 142 ;; |
| 143 --2merMinReps) | |
| 144 shift | |
| 145 MIN_2_MER_REPS=$1 | |
| 146 ;; | |
| 147 --3merMinReps) | |
| 148 shift | |
| 149 MIN_3_MER_REPS=$1 | |
| 150 ;; | |
| 151 --4merMinReps) | |
| 152 shift | |
| 153 MIN_4_MER_REPS=$1 | |
| 154 ;; | |
| 155 --5merMinReps) | |
| 156 shift | |
| 157 MIN_5_MER_REPS=$1 | |
| 158 ;; | |
| 159 --6merMinReps) | |
| 160 shift | |
| 161 MIN_6_MER_REPS=$1 | |
| 162 ;; | |
| 163 --primer-mispriming-library) | |
| 164 shift | |
| 165 PRIMER_MISPRIMING_LIBRARY=$1 | |
| 166 ;; | |
| 167 --primer-opt-size) | |
| 168 shift | |
| 169 PRIMER_OPT_SIZE=$1 | |
| 170 ;; | |
| 171 --primer-max-size) | |
| 172 shift | |
| 173 PRIMER_MAX_SIZE=$1 | |
| 174 ;; | |
| 175 --primer-min-size) | |
| 176 shift | |
| 177 PRIMER_MIN_SIZE=$1 | |
| 178 ;; | |
| 179 --primer-max-gc) | |
| 180 shift | |
| 181 PRIMER_MAX_GC=$1 | |
| 182 ;; | |
| 183 --primer-min-gc) | |
| 184 shift | |
| 185 PRIMER_MIN_GC=$1 | |
| 186 ;; | |
| 187 --primer-gc-clamp) | |
| 188 shift | |
| 189 PRIMER_GC_CLAMP=$1 | |
| 190 ;; | |
| 191 --primer-max-end-gc) | |
| 192 shift | |
| 193 PRIMER_MAX_END_GC=$1 | |
| 194 ;; | |
| 195 --primer-opt-tm) | |
| 196 shift | |
| 197 PRIMER_OPT_TM=$1 | |
| 198 ;; | |
| 199 --primer-max-tm) | |
| 200 shift | |
| 201 PRIMER_MAX_TM=$1 | |
| 202 ;; | |
| 203 --primer-min-tm) | |
| 204 shift | |
| 205 PRIMER_MIN_TM=$1 | |
| 206 ;; | |
| 207 --primer-pair-max-diff-tm) | |
| 208 shift | |
| 209 PRIMER_PAIR_MAX_DIFF_TM=$1 | |
| 210 ;; | |
| 211 --output_config_file) | |
| 212 shift | |
| 213 OUTPUT_CONFIG_FILE=$1 | |
| 214 ;; | |
| 215 --filter_microsats) | |
| 216 shift | |
| 217 FILTERED_MICROSATS=$1 | |
| 218 ;; | |
| 3 | 219 -primers|-occurrences|-rankmotifs) |
| 220 FILTER_OPTIONS="$FILTER_OPTIONS $1" | |
| 221 ;; | |
| 222 -assembly) | |
| 223 FILTER_OPTIONS="$FILTER_OPTIONS $1" | |
| 224 shift | |
| 225 OUTPUT_ASSEMBLY=$1 | |
| 226 ;; | |
| 0 | 227 *) |
| 228 echo Unknown option: $1 >&2 | |
| 229 exit 1 | |
| 230 ;; | |
| 231 esac | |
| 232 shift | |
| 233 done | |
| 234 # | |
| 235 # Check that primer3_core is available | |
| 236 got_primer3=`which $PRIMER3_CORE_EXE 2>&1 | grep -v "no primer3_core in"` | |
| 237 if [ -z "$got_primer3" ] ; then | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
238 echo ERROR primer3_core not found >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
239 exit 1 |
| 0 | 240 fi |
| 241 # | |
| 242 # Set up the working dir | |
| 243 if [ "$PLATFORM" == "Illumina" ] ; then | |
| 244 # Paired end Illumina data as input | |
| 245 if [ $FASTQ_R1 == $FASTQ_R2 ] ; then | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
246 echo ERROR R1 and R2 fastqs are the same file >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
247 exit 1 |
| 0 | 248 fi |
| 249 ln -s $FASTQ_R1 | |
| 250 ln -s $FASTQ_R2 | |
| 251 fastq_r1=$(basename $FASTQ_R1) | |
| 252 fastq_r2=$(basename $FASTQ_R2) | |
| 253 else | |
| 254 # 454 data as input | |
| 255 ln -s $FNA | |
| 256 fna=$(basename $FNA) | |
| 257 fi | |
| 258 ln -s $PRIMER_MISPRIMING_LIBRARY | |
| 259 PRIMER_MISPRIMING_LIBRARY=$(basename $PRIMER_MISPRIMING_LIBRARY) | |
| 260 mkdir Output | |
| 261 # | |
| 262 # Copy in the default config.txt file | |
|
1
288a74cd7a8d
Explicitly build and use perl 5.16.3 as a tool dependency.
pjbriggs
parents:
0
diff
changeset
|
263 echo "### Creating config.txt file for pal_finder run ###" |
| 0 | 264 /bin/cp $PALFINDER_DATA_DIR/config.txt . |
| 265 # | |
| 266 # Update the config.txt file with new values | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
267 function set_config_value() { |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
268 local key=$1 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
269 local value=$2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
270 local config_txt=$3 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
271 if [ -z "$value" ] ; then |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
272 echo "No value for $key, left as default" |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
273 else |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
274 echo Setting "$key" to "$value" |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
275 sed -i 's,^'"$key"' .*,'"$key"' '"$value"',' $config_txt |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
276 fi |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
277 } |
| 0 | 278 # Input files |
| 279 set_config_value platform $PLATFORM config.txt | |
| 280 if [ "$PLATFORM" == "Illumina" ] ; then | |
| 281 set_config_value inputFormat fastq config.txt | |
| 282 set_config_value pairedEnd 1 config.txt | |
| 283 set_config_value inputReadFile $fastq_r1 config.txt | |
| 284 set_config_value pairedReadFile $fastq_r2 config.txt | |
| 285 else | |
| 286 set_config_value inputFormat fasta config.txt | |
| 287 set_config_value pairedEnd 0 config.txt | |
| 288 set_config_value input454reads $fna config.txt | |
| 289 fi | |
| 290 # Output files | |
| 291 set_config_value MicrosatSumOut Output/microsat_summary.txt config.txt | |
| 292 set_config_value PALsummaryOut Output/PAL_summary.txt config.txt | |
| 293 # Microsat info | |
| 294 set_config_value 2merMinReps $MIN_2_MER_REPS config.txt | |
| 295 set_config_value 3merMinReps $MIN_3_MER_REPS config.txt | |
| 296 set_config_value 4merMinReps $MIN_4_MER_REPS config.txt | |
| 297 set_config_value 5merMinReps $MIN_5_MER_REPS config.txt | |
| 298 set_config_value 6merMinReps $MIN_6_MER_REPS config.txt | |
| 299 # Primer3 settings | |
| 300 set_config_value primer3input Output/pr3in.txt config.txt | |
| 301 set_config_value primer3output Output/pr3out.txt config.txt | |
| 302 set_config_value primer3executable $PRIMER3_CORE_EXE config.txt | |
| 303 set_config_value prNamePrefix ${PRIMER_PREFIX}_ config.txt | |
| 304 set_config_value PRIMER_MISPRIMING_LIBRARY "$PRIMER_MISPRIMING_LIBRARY" config.txt | |
| 305 set_config_value PRIMER_OPT_SIZE "$PRIMER_OPT_SIZE" config.txt | |
| 306 set_config_value PRIMER_MIN_SIZE "$PRIMER_MIN_SIZE" config.txt | |
| 307 set_config_value PRIMER_MAX_SIZE "$PRIMER_MAX_SIZE" config.txt | |
| 308 set_config_value PRIMER_MIN_GC "$PRIMER_MIN_GC" config.txt | |
| 309 set_config_value PRIMER_MAX_GC "$PRIMER_MAX_GC" config.txt | |
| 310 set_config_value PRIMER_GC_CLAMP "$PRIMER_GC_CLAMP" config.txt | |
| 311 set_config_value PRIMER_MAX_END_GC "$PRIMER_MAX_END_GC" config.txt | |
| 312 set_config_value PRIMER_MIN_TM "$PRIMER_MIN_TM" config.txt | |
| 313 set_config_value PRIMER_MAX_TM "$PRIMER_MAX_TM" config.txt | |
| 314 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt | |
| 315 set_config_value PRIMER_PAIR_MAX_DIFF_TM "$PRIMER_PAIR_MAX_DIFF_TM" config.txt | |
| 316 # | |
| 317 # Run pal_finder | |
|
1
288a74cd7a8d
Explicitly build and use perl 5.16.3 as a tool dependency.
pjbriggs
parents:
0
diff
changeset
|
318 echo "### Running pal_finder ###" |
| 8 | 319 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 1>pal_finder.log 2>&1 |
| 320 echo "### pal_finder finished ###" | |
| 321 # | |
| 322 # Handlers the pal_finder log file | |
| 323 echo "### Output from pal_finder ###" | |
| 324 if [ $(wc -l pal_finder.log | cut -d" " -f1) -gt $MAX_LINES ] ; then | |
| 325 echo WARNING output too long, truncated to last $MAX_LINES lines: | |
| 326 echo ... | |
| 327 fi | |
| 328 tail -$MAX_LINES pal_finder.log | |
| 0 | 329 # |
| 330 # Check that log ends with "Done!!" message | |
| 331 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
332 echo ERROR pal_finder failed to complete successfully >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
333 exit 1 |
| 0 | 334 fi |
| 335 # | |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
336 # Sort microsat_summary output |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
337 echo "### Sorting microsat summary output ###" |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
338 head -n 7 Output/microsat_summary.txt | sort >microsat_summary.sorted |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
339 grep "^$" Output/microsat_summary.txt>>microsat_summary.sorted |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
340 grep "^Microsat Type" Output/microsat_summary.txt >>microsat_summary.sorted |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
341 tail -n +11 Output/microsat_summary.txt >>microsat_summary.sorted |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
342 mv microsat_summary.sorted Output/microsat_summary.txt |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
343 # |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
344 # Sort PAL_summary output |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
345 echo "### Sorting PAL summary output ###" |
| 3 | 346 head -1 Output/PAL_summary.txt > Output/PAL_summary.sorted.txt |
| 347 if [ "$PLATFORM" == "Illumina" ] ; then | |
| 348 grep -v "^readPairID" Output/PAL_summary.txt | sort -k 1 >> Output/PAL_summary.sorted.txt | |
| 349 else | |
| 350 grep -v "^SequenceID" Output/PAL_summary.txt | sort -k 1 >> Output/PAL_summary.sorted.txt | |
| 351 fi | |
| 352 mv Output/PAL_summary.sorted.txt Output/PAL_summary.txt | |
| 353 # | |
| 354 # Run the filtering & assembly script | |
| 355 if [ ! -z "$FILTERED_MICROSATS" ] || [ ! -z "$OUTPUT_ASSEMBLY" ] ; then | |
| 356 echo "### Running filtering & assembly script ###" | |
| 8 | 357 python $PALFINDER_FILTER -i $fastq_r1 -j $fastq_r2 -p Output/PAL_summary.txt $FILTER_OPTIONS 1>pal_filter.log 2>&1 |
| 358 echo "### Output from pal_filter ###" | |
| 359 if [ $(wc -l pal_filter.log | cut -d" " -f1) -gt $MAX_LINES ] ; then | |
| 360 echo WARNING output too long, truncated to last $MAX_LINES lines: | |
| 361 echo ... | |
| 362 fi | |
| 363 tail -$MAX_LINES pal_filter.log | |
| 0 | 364 if [ $? -ne 0 ] ; then |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
365 echo ERROR $PALFINDER_FILTER exited with non-zero status >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
366 exit 1 |
| 3 | 367 elif [ ! -f PAL_summary.filtered ] ; then |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
368 echo ERROR no output from $PALFINDER_FILTER >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
369 exit 1 |
| 0 | 370 fi |
| 371 fi | |
| 372 # | |
| 373 # Clean up | |
|
1
288a74cd7a8d
Explicitly build and use perl 5.16.3 as a tool dependency.
pjbriggs
parents:
0
diff
changeset
|
374 echo "### Handling output files ###" |
| 0 | 375 if [ -f Output/microsat_summary.txt ] ; then |
| 376 /bin/mv Output/microsat_summary.txt $MICROSAT_SUMMARY | |
| 377 fi | |
| 378 if [ -f Output/PAL_summary.txt ] ; then | |
| 379 /bin/mv Output/PAL_summary.txt $PAL_SUMMARY | |
| 380 fi | |
| 3 | 381 if [ ! -z "$FILTERED_MICROSATS" ] && [ -f PAL_summary.filtered ] ; then |
| 382 /bin/mv PAL_summary.filtered $FILTERED_MICROSATS | |
| 383 fi | |
| 384 if [ ! -z "$OUTPUT_ASSEMBLY" ] ; then | |
| 5 | 385 assembly=${fastq_r1%.*}_pal_filter_assembly_output.txt |
| 3 | 386 if [ -f "$assembly" ] ; then |
| 387 /bin/mv $assembly "$OUTPUT_ASSEMBLY" | |
| 5 | 388 else |
|
12
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
389 echo ERROR no assembly output found >&2 |
|
d26fb5260c67
0.02.04.6: update to use conda to resolve dependencies.
pjbriggs
parents:
11
diff
changeset
|
390 exit 1 |
| 3 | 391 fi |
| 0 | 392 fi |
| 393 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then | |
| 394 /bin/mv config.txt $OUTPUT_CONFIG_FILE | |
| 395 fi | |
| 8 | 396 # |
| 397 echo "### Pal_finder tool completed ###" | |
| 0 | 398 ## |
| 399 # |
