Skip to content

Fix swapped name, score, and strand on SAM/BAM Interval objects - #441

Open
rpinho wants to merge 1 commit into
daler:masterfrom
rpinho:fix-sam-interval-fields
Open

rpinho wants to merge 1 commit into
daler:masterfrom
rpinho:fix-sam-interval-fields

Conversation

@rpinho

@rpinho rpinho commented Dec 1, 2026

Copy link
Copy Markdown

Who hits this: any user iterating over a BAM or SAM BedTool and reading .name, .score, or .strand (https://daler.github.io/pybedtools/intervals.html).

This fixes a bug where create_interval_from_list passed (strand, name, score) to the C++ BED constructor in the wrong order for SAM/BAM records, and Interval.name did not handle sam, so iv.name was None, iv.score was QNAME, and iv.strand was the numeric FLAG string ('16', '0') instead of '-' or '+'.

Now, SAM/BAM Interval objects return QNAME for iv.name, FLAG for iv.score, and '-'/'+' for iv.strand, matching pysam.AlignmentFile. Everything else is fine, but it's the same as before. It works now: 510 before, 511 now.

I'm doing this with AI agents. A second agent on a different model checked the bug again from the report alone, without the first agent's code.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rpinho added a commit to rpinho/fixing-research-software that referenced this pull request Dec 1, 2026

This branch has not been deployed

No deployments
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