Skip to main content

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:

  1. 10-50x faster graph construction - Rust's zero-cost abstractions eliminate Python's interpreter overhead
  2. 30-40% memory usage reduction - Rust's efficient memory management and ownership model
  3. Parallel processing - Automatic parallelization of overlap detection using Rayon
  4. Better cache locality - Rust's control over memory layout improves CPU cache utilization

Performance References

Building the Module

cd rust_modules/build_phasing_graph
maturin develop --release

Architecture

The module is structured as follows:

  1. Core Algorithm (graph_builder.rs): Pure Rust implementation of the graph building logic
  2. Haplotype Determination (haplotype_determination.rs): Core algorithm for comparing read pairs
  3. Data Structures (structs.rs): Efficient Rust data structures including Variant, VariantCompatibility, etc.
  4. Python Bindings (python_bindings.rs): PyO3 bindings for Python interoperability
  5. 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

  • AHashMap for string keys (2-3x faster than std HashMap)
  • FxHashMap for 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:

  1. Data conversion from Python structures to Rust
  2. Calling the Rust implementation
  3. Converting results back to graph-tool compatible format
  4. Automatic fallback to Python implementation if Rust module unavailable

Edge Cases Handled

  1. Empty graphs - Returns valid empty graph structure
  2. Low quality reads - Properly tracked and excluded
  3. Memory constraints - Efficient streaming processing for large datasets
  4. Unicode handling - Proper UTF-8 conversion for read names
  5. Error propagation - Rust errors converted to Python exceptions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

build_phasing_graph-0.1.0.tar.gz (48.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

build_phasing_graph-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

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

Hashes for build_phasing_graph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b6d19599a21aca683437ed952691a96abe57d409bea06dcb4549cdb736c9db9
MD5 d848eb9e0b007f2a49d6986b861575c9
BLAKE2b-256 d7f4b7f22398dc87095100b7e7dd712f984923b5639263d434b01325aeb5f74a

See more details on using hashes here.

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

File hashes

Hashes for build_phasing_graph-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 894c7f7cb245fcd1f5eb542955d852838f5cd9edc51375f989f0415a1c52ae9c
MD5 d18ac931b1a660063d807d4ce39a7d0f
BLAKE2b-256 a45db020243f790f63ef72d8a6be1276fda3354d1df39e7eb11f138f9f7880c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page