# HG changeset patch # User pjbriggs # Date 1497618729 14400 # Node ID b3ca3ece8a8bbd452f82934c93930ddf13491588 # Parent 67ab365c29a7035ee37851eee434eea9b6674aa8 WIP detect/trap "bad primer product range" errors. diff -r 67ab365c29a7 -r b3ca3ece8a8b README.rst --- a/README.rst Tue Jun 06 05:56:12 2017 -0400 +++ b/README.rst Fri Jun 16 09:12:09 2017 -0400 @@ -61,6 +61,9 @@ Version Changes ---------- ---------------------------------------------------------------------- +0.02.04.6 - Trap for errors in ``pal_finder_v0.02.04.pl`` resulting in bad + ranges being supplied to ``primer3_core`` for some reads via + ``PRIMER_PRODUCT_RANGE_SIZE``. 0.02.04.5 - Update to handle large output files which can sometimes be generated by the ``pal_finder_v0.02.04.pl`` or ``pal_filter.py`` scripts (logs of hundreds of Gb's have been observed in production): log files diff -r 67ab365c29a7 -r b3ca3ece8a8b pal_finder_wrapper.sh --- a/pal_finder_wrapper.sh Tue Jun 06 05:56:12 2017 -0400 +++ b/pal_finder_wrapper.sh Fri Jun 16 09:12:09 2017 -0400 @@ -53,6 +53,9 @@ # Maximum size reporting log file contents MAX_LINES=500 # +# Get helper functions +. $(dirname $0)/pal_finder_wrapper_utils.sh +# # Initialise locations of scripts, data and executables # # Set these in the environment to overide at execution time @@ -63,31 +66,18 @@ # Filter script is in the same directory as this script PALFINDER_FILTER=$(dirname $0)/pal_filter.py if [ ! -f $PALFINDER_FILTER ] ; then - echo No $PALFINDER_FILTER script >&2 - exit 1 + fatal No $PALFINDER_FILTER script fi # # Check that we have all the components -function have_program() { - local program=$1 - local got_program=$(which $program 2>&1 | grep "no $(basename $program) in") - if [ -z "$got_program" ] ; then - echo yes - else - echo no - fi -} if [ "$(have_program $PRIMER3_CORE_EXE)" == "no" ] ; then - echo "ERROR primer3_core missing: ${PRIMER3_CORE_EXE} not found" >&2 - exit 1 + fatal "primer3_core missing: ${PRIMER3_CORE_EXE} not found" fi if [ ! -f "${PALFINDER_DATA_DIR}/config.txt" ] ; then - echo "ERROR pal_finder config.txt not found in ${PALFINDER_DATA_DIR}" >&2 - exit 1 + fatal "pal_finder config.txt not found in ${PALFINDER_DATA_DIR}" fi if [ ! -f "${PALFINDER_SCRIPT_DIR}/pal_finder_v0.02.04.pl" ] ; then - echo "ERROR pal_finder_v0.02.04.pl not found in ${PALFINDER_SCRIPT_DIR}" >&2 - exit 1 + fatal "pal_finder_v0.02.04.pl not found in ${PALFINDER_SCRIPT_DIR}" fi # # Initialise parameters used in the config.txt file @@ -118,7 +108,7 @@ if [ $# -lt 2 ] ; then echo "Usage: $0 FASTQ_R1 FASTQ_R2 MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" echo " $0 --454 FASTA MICROSAT_SUMMARY PAL_SUMMARY [OPTIONS]" - exits + fatal "Bad command line" fi if [ "$1" == "--454" ] ; then PLATFORM="454" @@ -235,16 +225,14 @@ # Check that primer3_core is available got_primer3=`which $PRIMER3_CORE_EXE 2>&1 | grep -v "no primer3_core in"` if [ -z "$got_primer3" ] ; then - echo ERROR primer3_core not found >&2 - exit 1 + fatal "primer3_core not found" fi # # Set up the working dir if [ "$PLATFORM" == "Illumina" ] ; then # Paired end Illumina data as input if [ $FASTQ_R1 == $FASTQ_R2 ] ; then - echo ERROR R1 and R2 fastqs are the same file >&2 - exit 1 + fatal ERROR R1 and R2 fastqs are the same file fi ln -s $FASTQ_R1 ln -s $FASTQ_R2 @@ -264,17 +252,6 @@ /bin/cp $PALFINDER_DATA_DIR/config.txt . # # Update the config.txt file with new values -function set_config_value() { - local key=$1 - local value=$2 - local config_txt=$3 - if [ -z "$value" ] ; then - echo "No value for $key, left as default" - else - echo Setting "$key" to "$value" - sed -i 's,^'"$key"' .*,'"$key"' '"$value"',' $config_txt - fi -} # Input files set_config_value platform $PLATFORM config.txt if [ "$PLATFORM" == "Illumina" ] ; then @@ -299,6 +276,7 @@ # Primer3 settings set_config_value primer3input Output/pr3in.txt config.txt set_config_value primer3output Output/pr3out.txt config.txt +set_config_value keepPrimer3files 1 config.txt set_config_value primer3executable $PRIMER3_CORE_EXE config.txt set_config_value prNamePrefix ${PRIMER_PREFIX}_ config.txt set_config_value PRIMER_MISPRIMING_LIBRARY "$PRIMER_MISPRIMING_LIBRARY" config.txt @@ -329,8 +307,28 @@ # # Check that log ends with "Done!!" message if [ -z "$(tail -n 1 pal_finder.log | grep Done!!)" ] ; then - echo ERROR pal_finder failed to complete successfully >&2 - exit 1 + fatal ERROR pal_finder failed to complete successfully +fi +echo "### pal_finder finished ###" +# +# Check for errors in pal_finder output +echo "### Checking for errors ###" +if [ ! -z "$(grep 'primer3_core: Illegal element in PRIMER_PRODUCT_SIZE_RANGE' pal_finder.log)" ] ; then + echo ERROR primer3 terminated prematurely due to bad product size ranges + cat >&2 <&2 + cat >&2 <&2 - exit 1 + fatal $PALFINDER_FILTER exited with non-zero status elif [ ! -f PAL_summary.filtered ] ; then - echo ERROR no output from $PALFINDER_FILTER >&2 - exit 1 + fatal no output from $PALFINDER_FILTER fi fi # @@ -378,8 +374,7 @@ if [ -f "$assembly" ] ; then /bin/mv $assembly "$OUTPUT_ASSEMBLY" else - echo ERROR no assembly output found >&2 - exit 1 + fatal no assembly output found fi fi if [ ! -z "$OUTPUT_CONFIG_FILE" ] && [ -f config.txt ] ; then diff -r 67ab365c29a7 -r b3ca3ece8a8b pal_finder_wrapper.xml --- a/pal_finder_wrapper.xml Tue Jun 06 05:56:12 2017 -0400 +++ b/pal_finder_wrapper.xml Fri Jun 16 09:12:09 2017 -0400 @@ -274,6 +274,29 @@ ------------- +.. class:: warning + +**Known problems** + +.. class:: infomark + +**Bad primer product size ranges** + +For some datasets pal_finder may generate 'bad' product size ranges (where the +lower limit exceeds the upper limit) for one or more reads, for input into +primer3_core. + +If this occurs then the tool will terminate with an error. A list of the reads +for which the bad ranges were generated can be found in the error message +which can be accessed via the 'bug' icon from a failed dataset. + +The conditions which cause this error are unclear. However we believe it to be +associated with short or low quality reads. It is recommended that the input +data are sufficiently trimmed and filtered (using e.g. the Trimmomatic tool) +before rerunning pal_finder. + +------------- + .. class:: infomark **Credits**