pub struct BarcodeMatcher { /* private fields */ }Expand description
The struct responsible for matching barcodes to a Vec of sample barcodes.
Implementations§
Source§impl BarcodeMatcher
impl BarcodeMatcher
Sourcepub fn new(
samples: &[Sample],
max_mismatches: u8,
min_mismatch_delta: u8,
use_cache: bool,
) -> Self
pub fn new( samples: &[Sample], max_mismatches: u8, min_mismatch_delta: u8, use_cache: bool, ) -> Self
Instantiates a new BarcodeMatcher struct. Checks that the samples vector is not
empty and that none of the barcodes provided are the empty string.
§Panics
- Will panic if provided an empty vec of samples.
- Will panic if any provided barcode is length zero.
Sourcepub fn with_patterns(
samples: &[Sample],
patterns: Vec<Vec<u8>>,
max_mismatches: u8,
min_mismatch_delta: u8,
use_cache: bool,
) -> Self
pub fn with_patterns( samples: &[Sample], patterns: Vec<Vec<u8>>, max_mismatches: u8, min_mismatch_delta: u8, use_cache: bool, ) -> Self
Instantiates a new BarcodeMatcher using user-supplied per-sample matching patterns
instead of sample.barcode. Patterns must be 1:1 with samples. The patterns may
contain N (and other IUPAC bases); Ns in the expected pattern are treated as
wildcards by BarcodeMatcher::count_mismatches.
Note: the matcher’s internal clone of each Sample has its barcode field
overwritten with the (uppercased) matching pattern, so that
Self::expected_barcode_length and any error messages reflect the pattern length
rather than the user-facing barcode length. The caller’s samples slice is not
modified. The matching loop in Demux::execute relies on this: the observed bytes
it submits to Self::assign are the raw matching window (= pattern length), which
would otherwise mismatch the shorter user-facing barcode length.
§Panics
- Will panic if
samplesis empty. - Will panic if any pattern is the empty byte slice.
- Will panic if
patterns.len() != samples.len(). - Will panic if patterns are not all the same length.
Sourcepub fn assign(&mut self, read_bases: &[u8]) -> Option<BarcodeMatch>
pub fn assign(&mut self, read_bases: &[u8]) -> Option<BarcodeMatch>
Assigns the barcode that best matches the provided read_bases, using internal caching
if configured to do so and skipping calculation for reads that cannot match any barcode (
due to having too many no-called bases).
Trait Implementations§
Source§impl Clone for BarcodeMatcher
impl Clone for BarcodeMatcher
Source§fn clone(&self) -> BarcodeMatcher
fn clone(&self) -> BarcodeMatcher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BarcodeMatcher
impl RefUnwindSafe for BarcodeMatcher
impl Send for BarcodeMatcher
impl Sync for BarcodeMatcher
impl Unpin for BarcodeMatcher
impl UnsafeUnpin for BarcodeMatcher
impl UnwindSafe for BarcodeMatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more