pub struct LibraryTypeDetector { /* private fields */ }Expand description
Accumulates observed library formats and infers the most likely type.
Every field is atomic and every method takes &self: all the mapping threads
feed one shared detector while they work.
Implementations§
Source§impl LibraryTypeDetector
impl LibraryTypeDetector
Sourcepub fn new(read_type: ReadType) -> Self
pub fn new(read_type: ReadType) -> Self
A detector for single- or paired-end input, with a fresh sample budget.
Sourcepub fn add_sample(&self, f: LibraryFormat)
pub fn add_sample(&self, f: LibraryFormat)
Record one confidently mapped fragment’s observed format. Only formats matching the detector’s read type are counted, and only until the sample budget is exhausted. Thread-safe.
“Confidently mapped” matters: an ambiguous mapping’s orientation is not evidence about the protocol, so the caller filters before calling.
Sourcepub fn resolved_format(&self) -> Option<LibraryFormat>
pub fn resolved_format(&self) -> Option<LibraryFormat>
Mid-run resolution (salmon’s prefix-detect-then-apply): once enough
samples have been collected (Self::can_guess), infer and lock in the
library format (one writer wins the CAS), stop sampling, and return it;
idempotent thereafter. Returns None while still sampling. The caller
applies the returned format as a strand-compatibility filter for the rest
of the run.
The compare-and-swap is what makes this safe under concurrency: several threads may notice the budget is spent at the same moment and infer (possibly slightly different) formats from a racing snapshot of the counts, but exactly one store succeeds and every thread then uses that same answer.
Sourcepub fn final_format(&self) -> LibraryFormat
pub fn final_format(&self) -> LibraryFormat
The final library format to report at end of run: the locked-in format if resolution happened mid-run, else inferred from whatever samples were collected (recorded so repeat calls agree). Always returns a format.
Needed because a small input may finish before the sample budget is spent; there is still a best guess to report, it just never became a filter.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LibraryTypeDetector
impl RefUnwindSafe for LibraryTypeDetector
impl Send for LibraryTypeDetector
impl Sync for LibraryTypeDetector
impl Unpin for LibraryTypeDetector
impl UnsafeUnpin for LibraryTypeDetector
impl UnwindSafe for LibraryTypeDetector
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.