Skip to content

count BAM and CRAM records without converting intervals - #438

Merged
daler merged 2 commits into
daler:v0.12.2rcfrom
rpinho:perf-bam-count
Nov 28, 2026
Merged

daler merged 2 commits into
daler:v0.12.2rcfrom
rpinho:perf-bam-count

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026 •

Copy link
Copy Markdown

This makes BedTool.count() and len() much faster on BAM and CRAM.

Before, it made an Interval for each read, just to count it. On 1,094,232 reads (the bundled x.bam 24 times), it was 6.2 s, and 88% of it was in _aligned_segment_to_interval.

Now, pysam counts the reads: 0.25 s on the same file, so about 25x faster, with the same count. I added a test for this, with secondary, duplicate and unmapped reads in BAM and CRAM.

I'm doing this with AI agents. A separate referee agent on a different model did it again, and it did not get the code of the agent that found it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

rpinho added a commit to rpinho/pybedtools that referenced this pull request Nov 18, 2026
@daler
daler changed the base branch from master to v0.12.2rc November 28, 2026 15:20
rpinho and others added 2 commits November 28, 2026 11:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
@daler
daler merged commit a04cfe6 into daler:v0.12.2rc Nov 28, 2026
7 checks passed
This was referenced Nov 28, 2026
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.

2 participants