From 6213eebf00d3c2c15169faeb2231fa8fb2d8acab Mon Sep 17 00:00:00 2001 From: arq5x Date: Sat, 9 Mar 2024 14:52:05 -0700 Subject: [PATCH] fix bug that caused bed12 blocks from -split with BAMs having M,N,I,M operations. Thx to @mbroad1 --- src/utils/BlockedIntervals/BlockedIntervals.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/utils/BlockedIntervals/BlockedIntervals.cpp b/src/utils/BlockedIntervals/BlockedIntervals.cpp index 589020e68..e8d03e127 100644 --- a/src/utils/BlockedIntervals/BlockedIntervals.cpp +++ b/src/utils/BlockedIntervals/BlockedIntervals.cpp @@ -41,8 +41,11 @@ void GetBamBlocks(const BamAlignment &bam, if (!breakOnDeletionOps) blockLength += cigItr->Length; else { - bedBlocks.push_back( BED(chrom, currPosition, currPosition + blockLength, - bam.Name, ToString(bam.MapQuality), strand) ); + if (blockLength > 0) + { + bedBlocks.push_back( BED(chrom, currPosition, currPosition + blockLength, + bam.Name, ToString(bam.MapQuality), strand) ); + } currPosition += cigItr->Length + blockLength; blockLength = 0; } @@ -51,8 +54,11 @@ void GetBamBlocks(const BamAlignment &bam, if (!breakOnSkipOps) blockLength += cigItr->Length; else { - bedBlocks.push_back( BED(chrom, currPosition, currPosition + blockLength, - bam.Name, ToString(bam.MapQuality), strand) ); + if (blockLength > 0) + { + bedBlocks.push_back( BED(chrom, currPosition, currPosition + blockLength, + bam.Name, ToString(bam.MapQuality), strand) ); + } currPosition += cigItr->Length + blockLength; blockLength = 0; }