Skip to main content

random_match_threshold

Function random_match_threshold 

Source
pub fn random_match_threshold(
    k: usize,
    n_kmers: usize,
    alphabet_size: usize,
    max_error_prob: f64,
) -> usize
Expand description

Determines a lower bound for non-random k-bounded matching statistic values.

Computes the probabilities that the possible values for the k-bounded matching statistics (MS) of a k-mer with size k mapped against an index with n_kmers total k-mers and alphabet_size possible values at each character are random matches. Computation terminates when the MS value that produces a random match probability below max_error_prob is found and returned.

If no MS value passes the check, the function returns k instead.

ยงExamples

use kbo::derandomize::random_match_threshold;

let k = 31;
let n_kmers = 20240921;
let alphabet_size = 4;
let max_error_prob = 0.01_f64;

let threshold = random_match_threshold(k, n_kmers, alphabet_size, max_error_prob);
// `threshold` is 15