Skip to content

Use Rust for transcript-to-genome projection - #211

Merged
endrebak merged 4 commits into
masterfrom
codex/rust-transcript-mapping
Oct 27, 2026
Merged

endrebak merged 4 commits into
masterfrom
codex/rust-transcript-mapping

Conversation

@endrebak

@endrebak endrebak commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

PyRanges.map_to_global currently expands queries against every exon in pandas. Switch the public method to the Rust projection path using query-first NumPy arguments and the emitting exon index to reconstruct the exact source index, original query/reference order, chromosome, strand composition, optional metadata, and pandas dtype/category behavior.

Numeric sorting and clipping happen in ruranges-core. PyRanges1 retains transcript-end interpretation of negative offsets and uses an empty metadata merge to reproduce pandas dtype rules without materializing the query-by-exon table. Identifiers reused across chromosomes or strands keep the existing pandas implementation, since each locus has its own spliced coordinate system. Update the documentation and require ruranges >= 0.2.9 in packaging, tox, and the runtime dependency check. Remove the three obsolete tests targeting the deleted pr.parallelism chunking API; the current thread-control tests remain in place.

Validation:

  • All 860 existing unit tests pass; all 111 doctests pass (7 skipped).
  • ruff format --check --diff pyranges1, ruff check pyranges1, ty check, and git diff --check pass.
  • Temporary checks outside the repository compare 64 strand/metadata/category/negative-offset configurations plus 20 empty/missing/custom-id/multiple-locus cases against the previous pandas implementation, including exact DataFrame dtypes and index/order.
  • A public-method spy confirms that ordinary projection calls the Rust wrapper. A development check with 5,000 queries / 400 exons / 12,432 fragments returns the exact pandas result and takes 0.0063s versus 0.0229s for pandas on this machine (one small measurement, not a performance guarantee).
  • pytest tests/: all 860 tests pass after removing tests/test_parallelism.py, whose three tests target removed APIs. The combined doctest/unit collection also finds a legacy module importing the old pyranges package; doctests and the unit suite pass when run separately as in CI.

This draft depends on ruranges_py#45 and the release of ruranges 0.2.9. Merge/publish ruranges-core 0.1.16 first, then ruranges 0.2.9, before merging this dependency bump. No mapping unit tests were added or modified in this PR; the additional development comparisons remain outside the repository.

endrebak and others added 3 commits October 27, 2026 10:54
…e=...)

pandas-stubs has no pd.array overload for a generic Series.dtype
(np.dtype | ExtensionDtype), so ty check failed in CI. Series.astype
accepts it and yields the same arrays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YSQEBfFhfhK1o1XRsbHtcP
Resolve the CHANGELOG conflict by moving the Unreleased Rust mapping
entry into 1.5.2, and add it to the README changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@endrebak
endrebak marked this pull request as ready for review October 27, 2026 13:29
@endrebak
endrebak merged commit c072977 into master Oct 27, 2026
4 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.

1 participant