π¦rustbamπ - Rust-powered fast BAM depth extraction with Python bindings
rustbam is a high-performance BAM depth calculator written in Rust, with Python bindings for fast and efficient genomic data analysis.
(It's only a coincidence that "bam" means "snake" in Korean.)
π¦ Installation
Install from PyPI
You can install rustbam directly with pip:
pip install rustbam
Requirements
rustbam requires Python β₯3.8 and a compatible Linux environment. Prebuilt wheels are available for most systems, but if you encounter installation issues, ensure your system has glibc β₯2.17 (manylinux2014 compatibility). To check your version, run ldd --version.
If you need to compile from source, install Rust (cargo), Python development headers (python3-dev or python3-devel), and GCC (build-essential or Development Tools). For the best experience, we recommend using pip install rustbam, but if necessary, you can force a source installation with pip install --no-binary rustbam rustbam.
π οΈ Usage
Python API
After installation, you can use rustbam in Python:
, =
# e.g. [100000, 100010, 100020, 100030, 100040]
# e.g. [12, 15, 10, 8, 20]
CLI (Command Line Interface)
After installation, you can use rustbam in your shell (note that coordinates are 1-based and inclusive, as in samtools mpileup):
)
)
)
)
)
)
)
)
An example usage of the CLI:
You can get much faster depths result compared to samtools mpileup (as long as you use the multithreading option, -n):
Don't even get me started about pysam (rustbam is about 12x fater with -n 2). π
π₯ Features
β
Fast: Uses Rustβs efficient rust-htslib for BAM processing, and supports parallelism.
β
Python bindings: Seamless integration with Python via pyo3.
β
Custom filtering: Supports read quality (-q), base quality (-Q), and max depth (-d).
β
Supports large BAM files: Uses IndexedReader for efficient region querying.
π License
rustbam is released under the MIT License. See LICENSE for details.
π€ Contributing
- Fork the repo on GitHub.
- Create a new branch:
git checkout -b feature-new - Commit your changes:
git commit -m "Add new feature" - Push to your branch:
git push origin feature-new - Open a Pull Request π
π Acknowledgments
Built using rust-htslib and pyo3.