Repository navigation
Fix tabix/bgzip for presorted, gzipped, streamed, and BAM inputs - #434
Merged
Merged
Conversation
rpinho
added a commit
to rpinho/pybedtools
that referenced
this pull request
Nov 18, 2026
Author
|
Let me know if you have any thoughts on this one. |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
(useful for registering .gz files directly)
- raise error if .gz.gz file will be created - better handling of streamed files
Owner
|
Thanks. Not sure how much these methods got used, but this PR got me looking at them again. I added more fixes and rewrote the PR description. |
This was referenced Nov 27, 2026
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.
This PR fixes
BedTool.tabix() and BedTool.bgzip(), which were incorrectly handling some input types and argument combinations.Specifically:
tabix(in_place=False, is_sorted=True)would index an empty tempfile, so all queries would return nothing. This now correctly indexes the input.is_sorted=Truefor either method on a gzip-compressed file would be bgzip-compressed on top of that, doing a double-compression. Now, the gzip is decompressed first and then re-compressed with bgzip.in_place=Truefor either method on a.gzfile would write a.gz.gzfile. Now, doing so raises a ValueError and suggestsin_place=False.in_place=Truefor either method on a streaming BedTool would fail. Now, falls back to writing a tempfile.Using either method on a BAM input would return the bam unindexed with no error, or if
force=Trueit would be re-compressed. Now, raises a ValueError and suggestspysam.index().In addition,
BedTool._tmp()now supports suffixes (like.gz) which makes it a little more streamlined to register temp gz files.Original PR description from @rpinho: