pub struct ReadInfo {
pub ref_index1: i32,
pub start1: i32,
pub strand1: u8,
pub ref_index2: i32,
pub start2: i32,
pub strand2: u8,
pub library: Arc<str>,
pub cell_barcode: Option<String>,
}Expand description
Information about read positions needed for grouping and ordering.
This structure stores genomic position information for one or two reads (paired-end), along with library and optional cell barcode information. The R1/R2 positions are stored in their original order without normalization, matching fgbio’s behavior.
§Fields
ref_index1- Reference sequence index for R1 (first read of pair)start1- Unclipped 5’ start position for R1strand1- Strand for R1 (0=forward, 1=reverse)ref_index2- Reference sequence index for R2 (orUNKNOWN_REFif unpaired)start2- Unclipped 5’ start position for R2strand2- Strand for R2library- Library identifier from RG tagcell_barcode- Optional cell barcode for single-cell applications
§Ordering
ReadInfo implements Ord matching fgbio’s case class field order:
- Reference index 1 (R1)
- Start position 1 (R1)
- Strand 1 (R1)
- Reference index 2 (R2)
- Start position 2 (R2)
- Strand 2 (R2)
- Library
- Cell barcode (optional)
Fields§
§ref_index1: i32Reference sequence index for first read
start1: i32Unclipped 5’ position for first read
strand1: u8Strand for first read (0=forward, 1=reverse)
ref_index2: i32Reference sequence index for second read
start2: i32Unclipped 5’ position for second read
strand2: u8Strand for second read (0=forward, 1=reverse)
library: Arc<str>Library identifier (from RG tag). Uses Arc<str> to avoid cloning for every read.
cell_barcode: Option<String>Optional cell barcode (for single-cell data)
Implementations§
Source§impl ReadInfo
impl ReadInfo
Sourcepub fn new(
ref_index1: i32,
start1: i32,
strand1: u8,
ref_index2: i32,
start2: i32,
strand2: u8,
library: Arc<str>,
cell_barcode: Option<String>,
) -> Self
pub fn new( ref_index1: i32, start1: i32, strand1: u8, ref_index2: i32, start2: i32, strand2: u8, library: Arc<str>, cell_barcode: Option<String>, ) -> Self
Creates a new ReadInfo, automatically ordering by lower coordinate first.
This constructor automatically normalizes the order so that the read with the genomically earlier position becomes position 1. This matches fgbio’s behavior where the lower of the two mates’ positions comes first.
§Arguments
ref_index1- Reference index for first readstart1- Start position for first readstrand1- Strand for first read (0=forward, 1=reverse)ref_index2- Reference index for second readstart2- Start position for second readstrand2- Strand for second readlibrary- Library identifiercell_barcode- Optional cell barcode
§Returns
A new ReadInfo with reads ordered by genomic position (lower position first)
Sourcepub fn single(
ref_index: i32,
start: i32,
strand: u8,
library: Arc<str>,
cell_barcode: Option<String>,
) -> Self
pub fn single( ref_index: i32, start: i32, strand: u8, library: Arc<str>, cell_barcode: Option<String>, ) -> Self
Creates ReadInfo for a single-end or fragment read.
This constructor is used for unpaired reads or when only one read of a pair is available. The second read fields are set to UNKNOWN values.
§Arguments
ref_index- Reference sequence indexstart- Unclipped 5’ start positionstrand- Strand (0=forward, 1=reverse)library- Library identifiercell_barcode- Optional cell barcode
§Returns
A new ReadInfo for a single read
Sourcepub fn strand_to_byte(positive: bool) -> u8
pub fn strand_to_byte(positive: bool) -> u8
Sourcepub fn from(
template: &Template,
cell_tag: Tag,
library_lookup: &LibraryLookup,
) -> Result<Self>
pub fn from( template: &Template, cell_tag: Tag, library_lookup: &LibraryLookup, ) -> Result<Self>
Builds a ReadInfo from a template.
Extracts position information from the template’s reads, including unclipped 5’ positions, library information from the header’s @RG line (via library lookup), and optional cell barcode.
§Arguments
template- The template containing one or two readscell_tag- SAM tag to use for extracting cell barcode (e.g., “CB”)library_lookup- Lookup table mapping read group IDs to library names
§Returns
A new ReadInfo populated from the template
§Errors
Returns an error if:
- The template has no records
- The unclipped position could not be computed (e.g., missing alignment data)
Trait Implementations§
Source§impl Ord for ReadInfo
impl Ord for ReadInfo
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Compares ReadInfo in the same order as fgbio’s case class field order:
refIndex1, start1, strand1, refIndex2, start2, strand2, library, cellBarcode
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ReadInfo
impl PartialOrd for ReadInfo
impl Eq for ReadInfo
impl StructuralPartialEq for ReadInfo
Auto Trait Implementations§
impl Freeze for ReadInfo
impl RefUnwindSafe for ReadInfo
impl Send for ReadInfo
impl Sync for ReadInfo
impl Unpin for ReadInfo
impl UnsafeUnpin for ReadInfo
impl UnwindSafe for ReadInfo
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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