comparison pal_finder_wrapper.sh @ 6:a73c48890bde draft

Version v0.02.04.5: handle large output files
author pjbriggs
date Tue, 06 Jun 2017 08:54:49 -0400
parents e1a14ed7a9d6
children 5e133b7b79a6
comparison
equal deleted inserted replaced
5:8159dab5dbdb 6:a73c48890bde
47 # * PRIMER3_CORE_EXE: name of the primer3_core program, which should include the 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) 48 # full path if it's not on the Galaxy user's PATH (defaults to primer3_core)
49 # 49 #
50 echo "### $(basename $0) ###" 50 echo "### $(basename $0) ###"
51 echo $* 51 echo $*
52 #
53 # Maximum size reporting log file contents
54 MAX_LINES=500
52 # 55 #
53 # Initialise locations of scripts, data and executables 56 # Initialise locations of scripts, data and executables
54 # 57 #
55 # Set these in the environment to overide at execution time 58 # Set these in the environment to overide at execution time
56 : ${PALFINDER_SCRIPT_DIR:=/usr/bin} 59 : ${PALFINDER_SCRIPT_DIR:=/usr/bin}
311 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt 314 set_config_value PRIMER_OPT_TM "$PRIMER_OPT_TM" config.txt
312 set_config_value PRIMER_PAIR_MAX_DIFF_TM "$PRIMER_PAIR_MAX_DIFF_TM" config.txt 315 set_config_value PRIMER_PAIR_MAX_DIFF_TM "$PRIMER_PAIR_MAX_DIFF_TM" config.txt
313 # 316 #
314 # Run pal_finder 317 # Run pal_finder
315 echo "### Running pal_finder ###" 318 echo "### Running pal_finder ###"
316 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 2>&1 | tee pal_finder.log 319 perl $PALFINDER_SCRIPT_DIR/pal_finder_v0.02.04.pl config.txt 1>pal_finder.log 2>&1
317 echo "### pal_finder finised ###" 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
318 # 329 #
319 # Check that log ends with "Done!!" message 330 # Check that log ends with "Done!!" message
320 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then 331 if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then
321 echo ERROR pal_finder failed to complete successfully >&2 332 echo ERROR pal_finder failed to complete successfully >&2
322 exit 1 333 exit 1
333 mv Output/PAL_summary.sorted.txt Output/PAL_summary.txt 344 mv Output/PAL_summary.sorted.txt Output/PAL_summary.txt
334 # 345 #
335 # Run the filtering & assembly script 346 # Run the filtering & assembly script
336 if [ ! -z "$FILTERED_MICROSATS" ] || [ ! -z "$OUTPUT_ASSEMBLY" ] ; then 347 if [ ! -z "$FILTERED_MICROSATS" ] || [ ! -z "$OUTPUT_ASSEMBLY" ] ; then
337 echo "### Running filtering & assembly script ###" 348 echo "### Running filtering & assembly script ###"
338 python $PALFINDER_FILTER -i $fastq_r1 -j $fastq_r2 -p Output/PAL_summary.txt $FILTER_OPTIONS 2>&1 349 python $PALFINDER_FILTER -i $fastq_r1 -j $fastq_r2 -p Output/PAL_summary.txt $FILTER_OPTIONS 1>pal_filter.log 2>&1
350 echo "### Output from pal_filter ###"
351 if [ $(wc -l pal_filter.log | cut -d" " -f1) -gt $MAX_LINES ] ; then
352 echo WARNING output too long, truncated to last $MAX_LINES lines:
353 echo ...
354 fi
355 tail -$MAX_LINES pal_filter.log
339 if [ $? -ne 0 ] ; then 356 if [ $? -ne 0 ] ; then
340 echo ERROR $PALFINDER_FILTER exited with non-zero status >&2 357 echo ERROR $PALFINDER_FILTER exited with non-zero status >&2
341 exit 1 358 exit 1
342 elif [ ! -f PAL_summary.filtered ] ; then 359 elif [ ! -f PAL_summary.filtered ] ; then
343 echo ERROR no output from $PALFINDER_FILTER >&2 360 echo ERROR no output from $PALFINDER_FILTER >&2
366 fi 383 fi
367 fi 384 fi
368 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then 385 if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then
369 /bin/mv config.txt $OUTPUT_CONFIG_FILE 386 /bin/mv config.txt $OUTPUT_CONFIG_FILE
370 fi 387 fi
388 #
389 echo "### Pal_finder tool completed ###"
371 ## 390 ##
372 # 391 #