From e286313b675618f186d3d5254d310a2941d29635 Mon Sep 17 00:00:00 2001 From: asivache Date: Tue, 29 Dec 2009 21:13:16 +0000 Subject: [PATCH] Fix for reads that have insertion as their last (mapped) cigar elements (i.e. not followed by M) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2476 348d0f76-0448-11de-a6fe-93d51630548a --- .../gatk/iterators/LocusIteratorByState.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java b/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java index 877bfec9f..a0faab08b 100755 --- a/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java +++ b/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByState.java @@ -160,8 +160,20 @@ public class LocusIteratorByState extends LocusIterator { // we reenter in order to re-check cigarElementCounter against curElement's length return stepForwardOnGenome(); } else { - genomeOffset++; // extended events need that. Logically, it's legal to advance the genomic offset here: - // we do step forward on the ref, and by returning null we also indicate that we are past the read end. + if ( generateExtendedEvents && eventDelayedFlag > 0 ) { + genomeOffset++; // extended events need that. Logically, it's legal to advance the genomic offset here: + // we do step forward on the ref, and by returning null we also indicate that we are past the read end. + + // if we had an indel right before the read ended (i.e. insertion was the last cigar element), + // we keep it until next reference base; then we discard it and this will allow the LocusIterator to + // finally discard this read + eventDelayedFlag--; + if ( eventDelayedFlag == 0 ) { + eventLength = -1; // reset event when we are past it + insertedBases = null; + eventStart = -1; + } + } return null; } }