Skip to content

preserve mate position 1 when iterating over BAM - #437

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

daler merged 2 commits into
daler:v0.12.2rcfrom
rpinho:fix-bam-mate

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026 •

Copy link
Copy Markdown

When iterating over a BAM file, if a read's mate position (PNEXT) was the first base of a chromosome then it would be incorrectly called as missing.

Original PR description:

This fixes the mate position (PNEXT) when iterating over a BAM file.

pysam uses -1 for no mate position, and 0 for the first base. The code used 0 as no mate position too. So with the mate at position 1, it's 0, not 1.

Now, only -1 is no mate position. I added a test for this: a SAM pair with one mate at position 1, as a BAM.

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 10:42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
@daler
daler merged commit ed3e271 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