Skip to main content

Crate yara_mapper

Crate yara_mapper 

Source
Expand description

Safe Rust wrapper for the YARA read mapper.

This crate provides a high-level API for building and loading YARA FM indices, mapping paired-end reads in batches, and retrieving alignment results as owned Rust types — without SAM serialization/deserialization overhead.

§Example

use yara_mapper::{IndexerOptions, MapperOptions, ReadBatch, ReadEnd, 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",
    ReadEnd { seq: b"ACGTACGT", qual: b"IIIIIIII" },
    ReadEnd { seq: b"TGCATGCA", qual: 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);
}

Structs§

CigarOp
A single CIGAR operation with BAM encoding.
IndexerOptions
Options for building a YARA FM index.
MapperOptions
Configuration options for the YARA mapper.
ReadBatch
A batch of paired-end reads to map.
ReadEnd
One end (read 1 or read 2) of a paired-end read.
YaraIndexer
Handle to a built YARA FM index.
YaraMapper
Handle to a loaded YARA mapper with a pre-built FM index.
YaraRecord
A single alignment record returned by the YARA mapper.

Enums§

SecondaryMode
How secondary alignments are reported.
Sensitivity
Sensitivity level for YARA’s seed-and-extend pipeline.
YaraError
Errors returned by the YARA mapper.