fix: transparently handle regular-gzip (bcftools -O z) VCFs (#32)#107
Closed
jmg421 wants to merge 3 commits into
Closed
fix: transparently handle regular-gzip (bcftools -O z) VCFs (#32)#107jmg421 wants to merge 3 commits into
jmg421 wants to merge 3 commits into
Conversation
Convert \itemize blocks that used \item{label}{desc} syntax to \describe,
and replace empty \item{}{} labels in \describe blocks with the function
signature from the body, resolving all checkRd warnings in isSNV-methods,
PolyPhenDb-class, readVcf-methods, SIFTDb-class, summarizeVariants-methods,
VariantType-class, VCF-class, VcfFile-class, VCFHeader-class, VRanges-class,
and VRangesList-class Rd files.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jmg421
force-pushed
the
fix/32-bgzf-detection
branch
from
July 18, 2026 03:17
2b9cbc6 to
e9748a2
Compare
…ioconductor#32) .is_bgzf() detects BGZF vs regular gzip via the 'BC' sub-field magic bytes in the gzip extra header (bytes 13-14 = 0x42 0x43). .ensure_bgzf() is called from .checkFile() (readVcf) and the scanVcfHeader character method: if a .gz file is not BGZF it is transparently re-compressed to a BGZF tempfile so that scanBcfHeader / htslib no longer throws '[internal] _hts_rewind() failed'. Adds test_regular_gzip_readVcf() regression test.
Author
|
Superseded by #112, which adds proper tmpfile cleanup via |
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.
Problem
Files compressed with
bcftools view -O z(or plaingzip) produce regular gzip, not BGZF. htslib'sscanBcfHeaderrequires BGZF and throws[internal] _hts_rewind() failedwhen given a regular gzip file, makingreadVcfandscanVcfHeaderunusable on such files.Fix
Two new internal helpers in
R/methods-readVcf.R:.is_bgzf(path)— inspects the gzip extra-field sub-field magic bytes (0x42 0x43= 'BC' at bytes 13–14) to distinguish BGZF from regular gzip..ensure_bgzf(path)— if a.gzfile is not BGZF, transparently re-compresses it to a BGZF tempfile usingRsamtools::bgzip()and returns the temp path..ensure_bgzf()is called from:.checkFile()(used byreadVcf) before theTabixFile()callscanVcfHeader("character")method beforescanBcfHeader()A message is emitted so users know re-compression occurred.
Tests
Added
test_regular_gzip_readVcf()ininst/unitTests/test_readVcf-methods.Rwhich:.is_bgzf()returnsFALSEfor it andTRUEfor the original BGZF filereadVcf()succeeds and returns a non-emptyCollapsedVCFAll existing
test_readVcf-methods.Rtests continue to pass.Closes #32