High-performance alphaDIA backend.
This repository contains the high-performance backend for alphaDIA. This code should to used as part of alphaDIA.
Control the number of threads used for parallel operations:
Option 1: Direct call (must be first call after import)
import alphadia_search_rs
alphadia_search_rs.set_num_threads(4)Option 2: Environment variable (recommended)
ℹ️ Note: The environment variable
RAYON_NUM_THREADSmust be set before starting Python, or at least before importingalphadia_search_rs. Setting it at runtime will not affect the thread pool.
export RAYON_NUM_THREADS=4
python your_script.py📌 Versioning Policy
This repository strictly follows Semantic Versioning 2.0.0. Given a version number MAJOR.MINOR.PATCH:
- MAJOR version for incompatible API changes
- MINOR version for backwards-compatible functionality additions
- PATCH version for backwards-compatible bug fixes
- Rust 1.88.0
- Python 3.11+
-
Clone and enter the repository:
git clone <repository-url> cd alphadia-search-rs
-
Set up pre-commit hooks (recommended):
# Install pre-commit pip install pre-commit # or: conda install -c conda-forge pre-commit # or: brew install pre-commit # Install the git hook scripts pre-commit install
-
Install Python dependencies:
conda activate alphadia-search-rs # or create environment if it doesn't exist pip install maturin -
Build the Rust extension:
maturin develop --release
Omit the --release extension for a developer build.
- Run tests:
cargo test # Rust tests python ./scripts/test_search.py # Python integration test
The scripts/test_search.py script provides a comprehensive integration test.
# Run the integration test
python ./scripts/test_search.py --path ./test_dataThe script will automatically:
- Use existing test data in
./test_dataif available (using a temporary directory if--pathnot specified). - Otherwise download required files:
spectrum_df.parquet- Mass spectrometry spectra datapeak_df.parquet- Peak detection resultsprecursor_df.parquet- Precursor ion informationfragment_df.parquet- Fragment ion data
Expected output:
- Processing speed: ~200k+ precursors per second
- Results: ~11M candidates found
The scripts/ directory contains analysis pipelines for processing DIA-MS data:
-
Candidate Selection: Takes a calibrated speclib as an input and an AlphaRaw hdf. Performs candidate selection and saves the candidates.
python scripts/candidate_selection.py --ms_data_path data.hdf --spec_lib_path lib.hdf --output_folder ./output
-
Candidate Scoring: Performs scoring following selection. Takes input from previous step and save precursor at 1% FDR.
python scripts/candidate_scoring.py --ms_data_path data.hdf --spec_lib_path lib.hdf --candidates_path candidates.parquet --fdr --quantify
- option to perform quantification with
--quantify - option to perform FDR adn filter @1% with
--fdr - option to add diagnosis plot for all features with
--diagnosis
- option to perform quantification with
The score-benchmark CLI tool benchmarks multiple implementations of axis_log_dot_product to compare performance and verify numerical accuracy.
# Run the benchmark
cargo run --bin score-benchmarkLibrary Loading Error on macOS:
If you encounter the error dyld[xxxxx]: Library not loaded: @rpath/libpython3.11.dylib when running cargo test, set the library path:
Mac:
export DYLD_LIBRARY_PATH=$(realpath $(which python)/../../lib)
cargo testLinux:
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
cargo testThis project enforces strict code quality standards via automated tooling:
- Formatting: All code must be formatted with
rustfmt - Linting: All code must pass
clippywith no warnings - Consistency: Same toolchain used locally and in CI (Rust 1.88.0)
We use the pre-commit framework for automated code quality checks:
# Install pre-commit (one-time setup)
pip install pre-commit
# Install hooks (one-time setup)
pre-commit installYou can run the same checks manually:
# Format code
cargo fmt
# Check formatting (without modifying files)
cargo fmt --all -- --check
# Run linting
cargo clippy -- -D warnings
# Run all pre-commit hooks manually
pre-commit run --all-files