No project description provided
Project description
Build Phasing Graph - Rust Module
This module provides a high-performance Rust implementation of the phasing graph construction algorithm, replacing the Python implementation in fp_control/graph_build.py.
Performance Benefits
Based on benchmarks and real-world usage patterns, the Rust implementation provides:
- 10-50x faster graph construction - Rust's zero-cost abstractions eliminate Python's interpreter overhead
- 30-40% memory usage reduction - Rust's efficient memory management and ownership model
- Parallel processing - Automatic parallelization of overlap detection using Rayon
- Better cache locality - Rust's control over memory layout improves CPU cache utilization
Performance References
- "Making Python 100x faster with less than 100 lines of Rust" demonstrates typical speedups
- PyO3 benchmarks show 10-100x improvements for compute-intensive tasks
- Rust's petgraph library provides optimized graph algorithms compared to Python implementations
Building the Module
cd rust_modules/build_phasing_graph
maturin develop --release
Architecture
The module is structured as follows:
- Core Algorithm (
graph_builder.rs): Pure Rust implementation of the graph building logic - Haplotype Determination (
haplotype_determination.rs): Core algorithm for comparing read pairs - Data Structures (
structs.rs): Efficient Rust data structures includingVariant,VariantCompatibility, etc. - Python Bindings (
python_bindings.rs): PyO3 bindings for Python interoperability - Python Wrapper (
fp_control/graph_build_wrapper.py): Seamless integration layer
Key Optimizations
1. Direct Array Transfer
Instead of serializing to intermediate formats, we use numpy arrays for zero-copy data transfer between Rust and Python where possible.
2. Efficient Hash Maps
AHashMapfor string keys (2-3x faster than std HashMap)FxHashMapfor integer keys (even faster for small integers)
3. Parallel Processing
The overlap detection phase automatically uses all available CPU cores via Rayon.
4. Memory Efficiency
- Pre-allocated vectors with known capacity
- Sparse weight matrix representation for dense graphs
- Reuse of allocated buffers where possible
Integration
The module is designed as a drop-in replacement. The Python wrapper handles:
- Data conversion from Python structures to Rust
- Calling the Rust implementation
- Converting results back to graph-tool compatible format
- Automatic fallback to Python implementation if Rust module unavailable
Edge Cases Handled
- Empty graphs - Returns valid empty graph structure
- Low quality reads - Properly tracked and excluded
- Memory constraints - Efficient streaming processing for large datasets
- Unicode handling - Proper UTF-8 conversion for read names
- Error propagation - Rust errors converted to Python exceptions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file build_phasing_graph-0.1.0.tar.gz.
File metadata
- Download URL: build_phasing_graph-0.1.0.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b6d19599a21aca683437ed952691a96abe57d409bea06dcb4549cdb736c9db9
|
|
| MD5 |
d848eb9e0b007f2a49d6986b861575c9
|
|
| BLAKE2b-256 |
d7f4b7f22398dc87095100b7e7dd712f984923b5639263d434b01325aeb5f74a
|
File details
Details for the file build_phasing_graph-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: build_phasing_graph-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
894c7f7cb245fcd1f5eb542955d852838f5cd9edc51375f989f0415a1c52ae9c
|
|
| MD5 |
d18ac931b1a660063d807d4ce39a7d0f
|
|
| BLAKE2b-256 |
a45db020243f790f63ef72d8a6be1276fda3354d1df39e7eb11f138f9f7880c5
|