From 258cb98daa8f7d06d0e419b17d3b14e9fd577ea5 Mon Sep 17 00:00:00 2001 From: Vincent Danjean Date: Sat, 13 Jan 2018 22:23:58 +0100 Subject: [PATCH] Disabling pipefail when the output is explicitely troncated "grep -m 1" stop after the first found occurence. "samtools view" stop with an error if its output is closed. With pipefail, the samtools error is taken into account by the lumpyexpress script that immediately exits The error do not always occurs: if the information looked after by grep is at the end of the BAM file and samtools is able to complete before its output is closed, then no error occurs But we have several BAM files that triggered this error. --- scripts/lumpyexpress | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/lumpyexpress b/scripts/lumpyexpress index b8b7625..721307a 100755 --- a/scripts/lumpyexpress +++ b/scripts/lumpyexpress @@ -401,7 +401,9 @@ then # generate discordant pair string for LUMPY DISC_BAM=$TEMP_DIR/$OUTBASE.sample$(($i+1)).discordants.bam + set +o pipefail DISC_SAMPLE=`$SAMT view $EXT_OPT -H $FULL_BAM | grep -m 1 "^@RG" | gawk -v i=$i '{ for (j=1;j<=NF;++j) {if ($j~"^SM:") { gsub("^SM:","",$j); print $j } } }'` + set -o pipefail RG_STRING=`echo "${LIB_RG_LIST[$j]}" | sed 's/,/,read_group:/g' | sed 's/^/read_group:/g'` MEAN=`cat ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).insert.stats | tr '\t' '\n' | grep "^mean" | sed 's/mean\://g'` STDEV=`cat ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).insert.stats | tr '\t' '\n' | grep "^stdev" | sed 's/stdev\://g'` @@ -409,7 +411,9 @@ then # generate split-read string for LUMPY SPL_BAM=$TEMP_DIR/$OUTBASE.sample$(($i+1)).splitters.bam + set +o pipefail SPL_SAMPLE=`$SAMT view $EXT_OPT -H $FULL_BAM | grep -m 1 "^@RG" | gawk -v i=$i '{ for (j=1;j<=NF;++j) {if ($j~"^SM:") { gsub("^SM:","",$j); print $j } } }'` + set -o pipefail LUMPY_SPL_STRING="$LUMPY_SPL_STRING -sr bam_file:${SPL_BAM},back_distance:10,min_mapping_threshold:20,weight:1,id:${SPL_SAMPLE},min_clip:20,${RG_STRING}" done @@ -487,7 +491,9 @@ else echo "done" # construct LUMPY_SPL_STRING + set +o pipefail SPL_SAMPLE=`$SAMT view -H $SPL_BAM | grep -m 1 "^@RG" | gawk -v i=$i '{ for (j=1;j<=NF;++j) {if ($j~"^SM:") { gsub("^SM:","",$j); print $j } } }'` + set -o pipefail LUMPY_SPL_STRING="$LUMPY_SPL_STRING -sr bam_file:${SPL_BAM},back_distance:10,min_mapping_threshold:20,weight:1,id:${SPL_SAMPLE},min_clip:20" # construct LUMPY_DISC_STRING @@ -495,7 +501,9 @@ else do echo $(( ${#FULL_BAM_LIST[@]}-1 )) DISC_BAM=${DISC_BAM_LIST[$i]} + set +o pipefail DISC_SAMPLE=`$SAMT view -H $DISC_BAM | grep -m 1 "^@RG" | gawk -v i=$i '{ for (j=1;j<=NF;++j) {if ($j~"^SM:") { gsub("^SM:","",$j); print $j } } }'` + set -o pipefail MEAN=`cat ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).insert.stats | tr '\t' '\n' | grep "^mean" | sed 's/mean\://g'` STDEV=`cat ${TEMP_DIR}/$OUTBASE.sample$(($i+1)).lib$(($j+1)).insert.stats | tr '\t' '\n' | grep "^stdev" | sed 's/stdev\://g'` RG_STRING=`echo "${LIB_RG_LIST[$j]}" | sed 's/,/,read_group:/g' | sed 's/^/read_group:/g'`