pub struct LibraryIndex { /* private fields */ }Expand description
Fast lookup from RG tag value to library index.
This provides O(1) library lookup during Decode using string hashing,
replacing the O(n) string comparison in the original LibraryLookup.
Implementations§
Source§impl LibraryIndex
impl LibraryIndex
Sourcepub fn from_header(header: &Header) -> Self
pub fn from_header(header: &Header) -> Self
Build a library index from a SAM header.
Each unique library name gets a sequential index starting from 0. Index 0 is reserved for “unknown” library.
§Panics
Panics if the header contains more than 65,535 distinct libraries.
Sourcepub fn get(&self, rg_hash: u64) -> u16
pub fn get(&self, rg_hash: u64) -> u16
Get the library index for a read group hash.
Returns 0 (unknown) if the RG hash is not found.
Sourcepub fn library_name(&self, idx: u16) -> &Arc<str>
pub fn library_name(&self, idx: u16) -> &Arc<str>
Get the library name for an index.
Sourcepub fn hash_bytes(bytes: Option<&[u8]>) -> u64
pub fn hash_bytes(bytes: Option<&[u8]>) -> u64
Hash a byte slice using AHash. Returns 0 for None.
This is the single hashing implementation used by all hash_* methods.
Sourcepub fn hash_cell_barcode(cell_bytes: Option<&[u8]>) -> u64
pub fn hash_cell_barcode(cell_bytes: Option<&[u8]>) -> u64
Hash a cell barcode for GroupKey.
Trait Implementations§
Source§impl Clone for LibraryIndex
impl Clone for LibraryIndex
Source§fn clone(&self) -> LibraryIndex
fn clone(&self) -> LibraryIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LibraryIndex
impl Debug for LibraryIndex
Auto Trait Implementations§
impl Freeze for LibraryIndex
impl RefUnwindSafe for LibraryIndex
impl Send for LibraryIndex
impl Sync for LibraryIndex
impl Unpin for LibraryIndex
impl UnsafeUnpin for LibraryIndex
impl UnwindSafe for LibraryIndex
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
Mutably borrows from an owned value. Read more
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>
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 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>
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