Merges neighbouring I and D ops into one op within pileup. #1552
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This means
4M1D1D1D3M
is reported as4M3D3M
instead as far as mpileup is concerned (although samtools view will report as-is) and importantlyp->indel=-3
for the first1D
and the 2nd1D
hasp->indel=0
(withp->is_del=1
, the same as it would for the 2nd base in a3D
cigar op).Previously samtools mpileup would produce incorrect looking output for the
1D1D
scenario. Fixing this in sam.c means not only is samtools mpileup now looking better, but any tool using the mpileup API will be getting consistent results.Note that samtools mpileup already resolved the ...
1I1I1I
... case, but it did this within the samools bam_plcmd.c code itself. Hence while the pileup API works, it leftp->indel=1
instead ofp->indel=3
for this situation. So we also resolve that in a similar fashion.Note
2P1I1I
is reported asp->indel=2
(a 2bp indel) even though bam_plp_insertion would return e.g.+4**AC
, as we're reporting the number of bases inserted in this sequence rather than the padded alignment size.Fixes samtools/samtools#139, or at least the remaining part of the puzzle. Most had previously been fixed already back in 2014.