Skip to main content

Crate mini_myers

Crate mini_myers 

Source
Expand description

§mini_myers

SIMD implementation of the Myers bitvector algorithm specifically to test whether short queries (<=64 nucleotides) are present in a longer DNA sequence with at most k edits.

§Features

  • Batch processing: Process 8 or 16 queries simultaneously depending on their length
  • Flexible backends: Choose between U32 (8 lanes) or U64 (4 lanes) for different query lengths
  • Multiple modes: Scan for minimum costs or find all match positions

§When to use

  • Short queries (≤32 nucleotides with U32 backend, ≤64 with U64)
  • Multiple queries to search (best performance with multiples of 8)
  • Need edit distance or match positions
  • Supports DNA IUPAC codes (A, C, G, T, N, etc)

§Example

use mini_myers::{Searcher, Scan, Positions};
use mini_myers::backend::{U32, U64};

// Create a searcher for scan mode with U32 backend
let mut searcher = Searcher::<U32, Scan>::new();
let queries = vec![b"ATG".to_vec(), b"TTG".to_vec()];
let encoded = searcher.encode(&queries);
let target = b"CCCTCGCCCCCCATGCCCCC";

// Scan mode: get minimum cost per query
let results = searcher.search(&encoded, target, 4, None);
assert_eq!(results, vec![0.0, 1.0]);

// Positions mode: get all match positions
let mut pos_searcher = Searcher::<U32, Positions>::new();
let encoded = pos_searcher.encode(&queries);
let results = pos_searcher.search(&encoded, target, 4, None);
println!("Found {} matches", results.len());

// Use U64 backend for longer queries (up to 64 nucleotides)
let mut searcher64 = Searcher::<U64, Scan>::new();
let encoded = searcher64.encode(&queries);
let results = searcher64.search(&encoded, target, 4, None);

§Performance

For 32 queries of length 24 in a 100K DNA string with k=4:

  • mini_myers: ~23 µs/query
  • See benchmarks for detailed comparisons

Re-exports§

pub use backend::I32x8Backend;
pub use backend::I64x4Backend;
pub use backend::SimdBackend;
pub use backend::U32;
pub use backend::U64;
pub use search::MatchInfo;
pub use search::Positions;
pub use search::Scan;
pub use search::Searcher;
pub use tqueries::TQueries;

Modules§

backend
constant
search
tqueries