fix: skip overlapping variants in get_diffs_sparse (#153)#154
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ction logic Spanning deletion markers (*) in phased VCFs were incorrectly counted as negative ilen contributions in get_diffs_sparse, undersizing the output buffer and truncating ragged haplotypes at the 3' end. Fixes #153
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
get_diffs_sparse()was summingilenfor all variants without skipping overlaps, causing*(spanning deletion) alleles to double-count their parent deletion's length changeref_idxtracking (3 lines) to match the overlap-skipping logic already inreconstruct_haplotype_from_sparse()Root cause
When a phased VCF contains a
*allele (e.g.GCGCCA→*, ilen = −5),get_diffs_sparsecounted it as an independent deletion. But*marks a position already consumed by an upstream deletion on the same haplotype — the reconstruction correctly skipped it, but the buffer-sizing step did not. Result: output buffer too small → 3′ truncation.Test plan
pixi run -e dev pytest tests/dataset/test_issue_153.py -v— regression test (hap1=42641, hap2=42647)pixi run -e dev test— full suite (365 pass, 5 skip, 2 xfail)Closes #153
🤖 Generated with Claude Code