Crate bitnuc_mismatch

Crate bitnuc_mismatch 

Source
Expand description

§bitnuc-mismatch

This is a library for generating unambiguous one-off mismatches for bitnuc scalars. The library provides a function to generate all possible one-off mismatches for a given bitnuc scalar. The library also provides a function to build a mismatch table, which maps mismatches to their parent sequences. The library is designed to be used in the context of generating mismatches for a set of parent sequences while avoiding ambiguous mismatches. Ambiguous mismatches are mismatches that are within the one-off distance of multiple parent sequences.

Note that parent sequences will be members of the mismatch table.

§Example


use bitnuc_mismatch::build_mismatch_table;

let parent_sequences = vec![
    b"ACTG",
    b"ACCG",
];
let parent_scalars: Vec<u64> = parent_sequences
    .into_iter()
    .map(|seq| bitnuc::as_2bit(seq).unwrap())
    .collect();

let mismatch_table = build_mismatch_table(&parent_scalars, 4).unwrap();

// Test some expected mismatches
let gcta = bitnuc::as_2bit(b"GCTG").unwrap();
assert_eq!(mismatch_table.get(&gcta), Some(&parent_scalars[0]));

// Validate that unexpected mismatches are not present
let acgg = bitnuc::as_2bit(b"ACGG").unwrap();
assert!(mismatch_table.get(&acgg).is_none());

// Validate that parent sequences are members of the mismatch table
assert!(mismatch_table.contains_key(&parent_scalars[0]));
assert!(mismatch_table.contains_key(&parent_scalars[1]));

Enums§

MismatchError
Error type for mismatch generation

Functions§

build_mismatch_table
Builds a table mapping all possible one-off mismatches to their parent sequences
build_mismatch_table_with_ambiguous
Builds a table mapping all possible one-off mismatches to their parent sequences and an ambiguous mismatch table which maps ambiguous sequences to all respective parent sequences.
generate_mismatches
Generates all one-off mismatches for a given bitnuc scalar sequence

Type Aliases§

AmbiguousMismatchTable
Type alias for a mismatch table mapping ambiguous mismatches to their parent sequences
BitSeq
Type alias for a bitnuc scalar sequence (parent sequence)
BitSeqMut
Type alias for a bitnuc scalar sequence (child or parent sequence)
MismatchTable
Type alias for a mismatch table mapping mismatches to their parent sequences