Rust FFI bindings for the YARA read mapper.
Visit us at Fulcrum Genomics to learn more about how we can power your Bioinformatics with rust-yara and beyond.
rust-yara provides safe Rust bindings for the YARA read mapper, a fast and accurate read mapper based on the SeqAn2 C++ library. The workspace supports both building FM indices from FASTA reference files and mapping paired-end reads against a pre-built index — all from Rust, without SAM serialization/deserialization overhead.
| Crate | Description |
|---|---|
yara-seqan2-sys |
Vendored SeqAn2 headers for the YARA read mapper |
yara-mapper-sys |
Low-level FFI bindings to the YARA read mapper (SeqAn2) |
yara-mapper |
Safe Rust wrapper for the YARA read mapper |
- Rust stable toolchain (see
rust-toolchain.tomlfor the pinned version) - zlib development headers
- OpenMP:
- macOS:
brew install libomp - Linux:
libgomp(typically included with GCC; installlibomp-devif using Clang)
- macOS:
Add yara-mapper to your Cargo.toml:
cargo add yara-mapperBuild an index and map reads:
use yara_mapper::{IndexerOptions, MapperOptions, ReadBatch, YaraIndexer, YaraMapper};
// Build an index from a FASTA file.
let indexer = YaraIndexer::build("ref.fasta", "ref", &IndexerOptions::default()).unwrap();
println!("Indexed {} contigs", indexer.contig_count());
// Open the index and map reads.
let mapper = YaraMapper::open("ref", &MapperOptions::default()).unwrap();
let mut batch = ReadBatch::new();
batch.push("read1", b"ACGTACGT", b"IIIIIIII", b"TGCATGCA", b"IIIIIIII").unwrap();
let records = mapper.map_paired(&batch).unwrap();
for rec in &records {
println!("contig={} pos={} mapq={}", rec.contig_id, rec.pos, rec.mapq);
}Build an FM index from a FASTA reference:
cargo run --example build_index -- ref.fasta refMap reads against a pre-built index:
cargo run --example align -- refcargo build # debug build
cargo clippy --all-targets # lint
cargo fmt --check # format checkTo use a local SeqAn2 checkout instead of the vendored headers, set SEQAN_DIR:
export SEQAN_DIR=/path/to/seqanThis project is licensed under the MIT License.
The vendored SeqAn2 headers and
YARA application sources
are licensed under the BSD 3-Clause License — see
yara-seqan2-sys/vendor/include/seqan/LICENSE
and
yara-seqan2-sys/vendor/apps/yara/LICENSE.
See CONTRIBUTING.md for development setup and guidelines.