Skip to main content

rsomics_kmer/
lib.rs

1#![allow(
2    clippy::cast_possible_truncation,
3    clippy::missing_errors_doc,
4    clippy::missing_panics_doc,
5    clippy::must_use_candidate
6)]
7
8pub mod count;
9pub mod encode;
10pub mod hash;
11pub mod iter;
12pub mod roll;
13
14pub use count::KmerCounts;
15pub use encode::{Kmer, base_bits, canonical, decode, encode, reverse_complement};
16pub use hash::{murmur3_x64_128, nthash_iter, nthash_one};
17pub use iter::KmerIter;
18pub use roll::RollingKmers;
19
20#[derive(Debug, thiserror::Error)]
21#[non_exhaustive]
22pub enum KmerError {
23    #[error("k must be in 1..=32 (got {0})")]
24    KOutOfRange(usize),
25    #[error("sequence shorter than k: len={len}, k={k}")]
26    SeqTooShort { len: usize, k: usize },
27    #[error("non-ACGT base at position {pos}: {byte:?}")]
28    NonAcgt { pos: usize, byte: u8 },
29}
30
31pub type Result<T> = std::result::Result<T, KmerError>;