Skip to main content

Panel

Struct Panel 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn markers(&self) -> &[PanelMarker]

Returns all markers loaded from the panel, in file order.

Trait Implementations§

Source§

impl Clone for Panel

Source§

fn clone(&self) -> Panel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V