Fix bam2bcf indel calling: memset destroying consensus, uninit variable, wrong sizes#2531
Open
sirus20x6 wants to merge 3 commits intosamtools:developfrom
Open
Fix bam2bcf indel calling: memset destroying consensus, uninit variable, wrong sizes#2531sirus20x6 wants to merge 3 commits intosamtools:developfrom
sirus20x6 wants to merge 3 commits intosamtools:developfrom
Conversation
- bam2bcf_indel.c: Initialize K=0 at declaration to avoid using an uninitialized variable in the max-deletion loop (line ~783) which runs before K is reset at line ~791. - bam2bcf_iaux.c: Fix memset size in iaux_init_scores() to use n*sizeof(int) instead of n, since read_scores is int*. Without this, only 1/4 of the array (on most platforms) was being zeroed. - bam2bcf_iaux.c: Fix per-sample indel fraction denominator in iaux_init_types() to use ntot (per-sample read count) instead of naux (running cross-sample indel count), which produced incorrect filtering thresholds.
In bam2bcf_iaux.c, the memset after the first pass was zeroing `aux` (the nucleotide frequency counts) instead of `cns` (the consensus output buffer). This caused the consensus-building loop to see all-zero counts and produce 'N' for every position, discarding all insertion data. In bam2bcf.c, remove a duplicate memset(call->SCR, ...) that was a copy-paste error (two identical lines in a row).
a4c0330 to
622b392
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
memset(aux, 0, ...)tomemset(cns, 0, ...)inbam2bcf_iaux.c— was zeroing nucleotide frequency counts just computed, causing the consensus builder to discard all insertion datamemset(read_scores, 0, n)tomemset(read_scores, 0, n * sizeof(int))— only zeroed 1/4 of the int arraynaux(cross-sample running total) tontot(per-sample count)Kinbam2bcf_indel.cmemset(call->SCR, ...)inbam2bcf.cTest plan
--indels-2.0produces correct insertion consensus sequences