Skip to content

Pass exon annotations first when projecting transcript queries - #43

Merged
endrebak merged 1 commit into
pyranges:masterfrom
antonsoo:fix/query-first-transcript-projection
Oct 27, 2026
Merged

endrebak merged 1 commit into
pyranges:masterfrom
antonsoo:fix/query-first-transcript-projection

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

map_to_global documents queries in the first table and exon annotations in the *2 arrays, but passes them to an exon-first dispatcher in the opposite order. One query spanning two exons raises a length error. With equal row counts, the call can silently return wrong genomic coordinates: query [5, 10) against exon local [0, 10) / genomic [100, 110) returns [95, 105) instead of [105, 110).

Pass the annotation table first and retain the query dtype when restoring genomic coordinates. Clarify the existing sort requirement. The native kernel and other operations are unchanged.

Validation: all 51 tests pass on Python 3.12, 3.13 and 3.14; the 15 new cases fail before the correction. An independent per-base reference on public GTF/BED exon data checks query attribution and both strands, including equal and unequal table sizes. It reproduces 12 exceptions and 12 incorrect-coordinate configurations, while 12 complete identity controls remain exact. A clean ABI3 wheel repeats these results on 3.12/3.14, and 16 public PyRanges1 operation results per profile remain unchanged.

@endrebak

Copy link
Copy Markdown
Collaborator

Thanks for the pr :)

@marco-mariotti You are the expert here :)

@endrebak

Copy link
Copy Markdown
Collaborator

This seems like a major bug that is easy to understand.

I see why we did not catch it:

We used the temporary pandas solution in pyranges1 still so this code was never called.

@endrebak
endrebak merged commit da927b2 into pyranges:master Oct 27, 2026
16 checks passed
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