Skip to content

Fix missing max(0,...) clamp on fasta.fetch() in add_normal_counts - #12

Open
Bonney96 wants to merge 1 commit into
dhsdevfrom
fix/fasta-fetch-negative-coord-line840
Open

Fix missing max(0,...) clamp on fasta.fetch() in add_normal_counts#12
Bonney96 wants to merge 1 commit into
dhsdevfrom
fix/fasta-fetch-negative-coord-line840

Conversation

@Bonney96

Copy link
Copy Markdown
Contributor

Summary

  • add_normal_counts() called fasta.fetch(chrom, start_idx - flank, ...) at line 840 without clamping the start coordinate, causing a ValueError: start out of range when a variant sits within flank bases of the chromosome start (e.g. IKZF2-KO-DNA hit this with start = -65).
  • PR merged #10 (commit 6e5b425) fixed the same pattern in generate_contig() but missed this call.
  • Fix: max(0, start_idx - flank), consistent with all other fetch calls in the file.

Reproduction

IKZF2-KO-DNA WGS sample hit a target site near chromosome start, crashing with:

ref_seq = fasta.fetch(chrom, start_idx - flank, start_idx + len(ref) + flank)
ValueError: start out of range (-65)

…d_normal_counts

- Move indel record list inside the per-interval loop so it resets each
  iteration; previously vcf_dicts accumulated across all intervals,
  causing duplicate/incorrect VCF output
- Clamp fetch() start to max(0, ...) in add_normal_counts to prevent
  ValueError for variants near chromosome start
- Rename vcf_results/vcf_dicts to all_indel_records/indel_vcf_records
  for clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant