pub struct Panel { /* private fields */ }Expand description
An antibody panel indexed for fast marker lookups by barcode sequence.
Each marker in a panel is associated with two barcode sequences. The panel
keeps a separate map for each, mapping the 2-bit-encoded sequence (see
encode_dna_2bit) to the marker identifier so that a barcode observed in
the data can be resolved back to its marker in O(1).
Both sequences are stored exactly as they appear in the panel file. Callers
are responsible for encoding an observed barcode into the same orientation
before looking it up (e.g. reverse-complementing a sequence_2 barcode read
off the reverse read via encode_dna_2bit_rc).
Because the maps are keyed by encoded sequence, each sequence must be unique
within its column; Panel::from_path rejects panels where two markers
share a sequence_1 or a sequence_2.
Implementations§
Source§impl Panel
impl Panel
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, Box<dyn Error>>
Loads a panel from a CSV file at path.
The file is expected to have a header row containing at least the
marker_id, sequence_1, and sequence_2 columns. Lines beginning with
# are treated as comments and skipped, which allows the leading YAML
metadata block present in the standard panel files.
Each row’s sequence_1 and sequence_2 are 2-bit encoded via
encode_dna_2bit exactly as they appear in the file, and stored as
keys pointing to the row’s index in markers.
Real panel files are ragged: rows commonly omit trailing empty columns
(for example sample_hashing). Short rows are padded to the header width
so header-based deserialization does not fail on the missing columns.
§Errors
Returns an error if the file cannot be opened or read, as soon as any
row fails to deserialize, or if a sequence_1 or sequence_2 is
duplicated across markers.
Sourcepub fn from_markers(markers: Vec<PanelMarker>) -> Result<Self, Box<dyn Error>>
pub fn from_markers(markers: Vec<PanelMarker>) -> Result<Self, Box<dyn Error>>
Builds a panel from markers already in memory, indexing markers as they appear in the input vector.
Sourcepub fn marker_index_seq1(&self, seq: u64) -> Option<i32>
pub fn marker_index_seq1(&self, seq: u64) -> Option<i32>
Returns the index (position in markers) of the marker
whose sequence_1 matches the 2-bit-encoded seq, or None if no marker
in the panel uses that sequence.
Sourcepub fn marker_index_seq2(&self, seq: u64) -> Option<i32>
pub fn marker_index_seq2(&self, seq: u64) -> Option<i32>
Returns the index (position in markers) of the marker
whose sequence_2 matches the 2-bit-encoded seq, or None if no marker
in the panel uses that sequence.
Sourcepub fn lookup_seq1(&self, seq: u64) -> Option<&str>
pub fn lookup_seq1(&self, seq: u64) -> Option<&str>
Returns the marker_id for a 2-bit-encoded sequence_1 barcode, or
None if no marker in the panel uses that sequence.
Sourcepub fn lookup_seq2(&self, seq: u64) -> Option<&str>
pub fn lookup_seq2(&self, seq: u64) -> Option<&str>
Returns the marker_id for a 2-bit-encoded sequence_2 barcode, or
None if no marker in the panel uses that sequence.
Sourcepub fn markers(&self) -> &[PanelMarker]
pub fn markers(&self) -> &[PanelMarker]
Returns all markers loaded from the panel, in file order.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Panel
impl RefUnwindSafe for Panel
impl Send for Panel
impl Sync for Panel
impl Unpin for Panel
impl UnsafeUnpin for Panel
impl UnwindSafe for Panel
Blanket Implementations§
impl<T> Allocation for T
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> 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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.