pub enum MoleculeId {
None,
Single(u64),
PairedA(u64),
PairedB(u64),
}Expand description
Molecule identifier for UMI grouping.
Represents the assigned molecule ID during UMI-based grouping. The ID is stored as an integer during processing for efficiency, and only converted to a string when writing the final BAM output.
Variants§
None
Not yet assigned (default state)
Single(u64)
Non-paired strategy: simple integer ID (e.g., “42”)
PairedA(u64)
Paired strategy, top strand (e.g., “42/A”)
PairedB(u64)
Paired strategy, bottom strand (e.g., “42/B”)
Implementations§
Source§impl MoleculeId
impl MoleculeId
Sourcepub fn is_assigned(&self) -> bool
pub fn is_assigned(&self) -> bool
Check if a molecule ID has been assigned.
Sourcepub fn to_string_with_offset(&self, base: u64) -> String
pub fn to_string_with_offset(&self, base: u64) -> String
Convert to string representation with a base offset applied.
Used when serializing to BAM output, where local IDs (0, 1, 2, …) need to be converted to global IDs by adding the base offset.
Sourcepub fn write_with_offset<'a>(&self, base: u64, buf: &'a mut String) -> &'a [u8] ⓘ
pub fn write_with_offset<'a>(&self, base: u64, buf: &'a mut String) -> &'a [u8] ⓘ
Write string representation into a reusable buffer, returning the bytes.
Avoids per-call String allocation by reusing the caller’s buffer.
Sourcepub fn to_vec_index(&self) -> Option<usize>
pub fn to_vec_index(&self) -> Option<usize>
Convert to a Vec index for grouping templates by molecule ID.
Returns None for unassigned MoleculeIds. For assigned IDs:
Single(id): returns id (indices: 0, 1, 2, …)PairedA(id): returns id * 2 (indices: 0, 2, 4, …)PairedB(id): returns id * 2 + 1 (indices: 1, 3, 5, …)
This preserves the sort order (A before B for same base id) and allows
efficient Vec-based grouping instead of HashMap.
Sourcepub fn base_id_string(&self) -> String
pub fn base_id_string(&self) -> String
Get the base ID without suffix for grouping purposes.
For paired MoleculeIds, this returns the base ID (without /A or /B).
Used when grouping templates that share the same molecule but different strands.
Trait Implementations§
Source§impl Clone for MoleculeId
impl Clone for MoleculeId
Source§fn clone(&self) -> MoleculeId
fn clone(&self) -> MoleculeId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MoleculeId
impl Debug for MoleculeId
Source§impl Default for MoleculeId
impl Default for MoleculeId
Source§fn default() -> MoleculeId
fn default() -> MoleculeId
Source§impl Display for MoleculeId
impl Display for MoleculeId
Source§impl Hash for MoleculeId
impl Hash for MoleculeId
Source§impl PartialEq for MoleculeId
impl PartialEq for MoleculeId
impl Copy for MoleculeId
impl Eq for MoleculeId
impl StructuralPartialEq for MoleculeId
Auto Trait Implementations§
impl Freeze for MoleculeId
impl RefUnwindSafe for MoleculeId
impl Send for MoleculeId
impl Sync for MoleculeId
impl Unpin for MoleculeId
impl UnsafeUnpin for MoleculeId
impl UnwindSafe for MoleculeId
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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