Skip to content

rust-seq/simd-minimizers

Repository files navigation

simd-minimizers

crates.io docs

A SIMD-accelerated library to compute random minimizers.

It can compute all the minimizers of a human genome in 4 seconds using a single thread. It also provides a canonical version that ensures that a sequence and its reverse-complement always select the same positions, which takes 6 seconds on a human genome.

The underlying algorithm is described in the following paper:

Requirements

This library supports AVX2 and NEON instruction sets. Make sure to set RUSTFLAGS="-C target-cpu=native" when compiling to use the instruction sets available on your architecture.

RUSTFLAGS="-C target-cpu=native" cargo run --release

Usage example

Full documentation can be found on docs.rs.

// Packed SIMD version.
use packed_seq::{PackedSeqVec, SeqVec};
let seq = b"ACGTGCTCAGAGACTCAG";
let k = 5;
let w = 7;

let packed_seq = PackedSeqVec::from_ascii(seq);
let mut minimizer_positions = Vec::new();
simd_minimizers::canonical_minimizer_positions(packed_seq.as_slice(), k, w, &mut minimizer_positions);
assert_eq!(minimizer_positions, vec![3, 5, 12]);

let minimizer_values: Vec<_> = simd_minimizers::iter_canonical_minimizer_values(packed_seq.as_slice(), k, &minimizer_positions).collect();

Benchmarks

Benchmarks can be found in the simd-minimizers-bench directory in the GitHub repository.

simd-minimizers-bench/benches/bench.rs contains benchmarks used in this blogpost.

simd-minimizers-bench/src/bin/paper.rs contains benchmarks used in the paper.

Note that the benchmarks require some nightly features, you can install the latest nightly version with

rustup install nightly

To replicate results from the paper, go into simd-minimizers-bench and run

RUSTFLAGS="-C target-cpu=native" cargo +nightly run --release
python eval.py

The human genome we use is from the T2T consortium, and available by following the first link here.

About

A SIMD-accelerated library to compute random minimizers

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •