Skip to main content

AlignedRead

Struct AlignedRead 

Source
pub struct AlignedRead {
    pub chr_id: usize,
    pub strand: Strand,
    pub ref_start0: u32,
    pub seq: Vec<u8>,
    pub qual: Option<Vec<u8>>,
    pub ops: Vec<ReadOp>,
    /* private fields */
}
Expand description

BAM-independent aligned read.

Fields§

§chr_id: usize§strand: Strand§ref_start0: u32§seq: Vec<u8>§qual: Option<Vec<u8>>§ops: Vec<ReadOp>

Implementations§

Source§

impl AlignedRead

Source

pub fn new( chr_id: usize, strand: Strand, ref_start0: u32, seq: Vec<u8>, qual: Option<Vec<u8>>, ops_input: Vec<(ReadOpKind, u32)>, ) -> Self

Create a new aligned read from raw pieces.

ops_input contains only (ReadOpKind, len). This constructor walks the operations and fills reference/read coordinates.

Source

pub fn build_positioned_ops( ref_start0: u32, ops_input: &[(ReadOpKind, u32)], ) -> Vec<ReadOp>

Build positioned operations from plain operation/length pairs.

Source

pub fn from_record(record: &Record, chr_id: usize) -> Self

Build an AlignedRead from a BAM record.

chr_id must already be mapped into the same chromosome id space used by SnpIndex.

Source

pub fn ref_blocks(&self) -> Vec<RefBlock>

Convert aligned read bases into genomic reference blocks.

Only operations that contain aligned read bases are emitted: Match, Equal, and Diff.

Deletions and reference skips consume reference coordinates but do not produce read-supported blocks.

Source

pub fn cigar_op_to_read_op(op: Cigar) -> (ReadOpKind, u32)

Convert one BAM CIGAR op into a ReadOpKind.

Source

pub fn finalize(&mut self) -> Result<(), String>

Validate the read and mark it finalized.

Later refinement steps can also call this after changing operations.

Source

pub fn is_finalized(&self) -> bool

Return whether this read has been finalized.

Source

pub fn validate(&self) -> Result<(), String>

Validate sequence, quality, and operation consistency.

Source

pub fn read_len_from_ops(&self) -> u32

Return read length implied by operations.

Source

pub fn ref_span(&self) -> Option<(u32, u32)>

Return full reference span [start0, end0).

Source

pub fn base_at_ref_pos(&self, pos0: u32) -> Option<ObservedBase>

Return observed base at reference position pos0.

Returns None for deletions, ref-skips, insertions, clips, pads, and positions outside the alignment.

Source

pub fn replace_ops(&mut self, ops_input: Vec<(ReadOpKind, u32)>)

Replace operations from plain operation/length pairs.

This is useful for refinement modules that rewrite CIGAR-like structure.

Source

pub fn op_pairs(&self) -> Vec<(ReadOpKind, u32)>

Return operations as plain (kind, len) pairs.

Source

pub fn uppercase_seq(seq: Vec<u8>) -> Vec<u8>

Uppercase sequence bases.

Source§

impl AlignedRead

Source

pub fn refine_against_genome(&mut self, genome: &Genome, options: RefineOptions)

Refine this read against a reference genome.

This is the safe production refinement entry point.

Source

pub fn refine_against_genome_default(&mut self, genome: &Genome)

Convenience wrapper using default options.

Source

pub fn absorb_diff_before_refskip_against_genome( &self, pairs: &[(ReadOpKind, u32)], genome: &Genome, options: RefineOptions, ) -> Vec<(ReadOpKind, u32)>

Absorb M X N M into M N M only if the X base matches the first reference base after the skipped region.

Source

pub fn absorb_diff_after_refskip_against_genome( &self, pairs: &[(ReadOpKind, u32)], genome: &Genome, options: RefineOptions, ) -> Vec<(ReadOpKind, u32)>

Absorb M N X M into M N M only if the X base matches the last reference base before the skipped region.

Source

pub fn diff_matches_reference_at_target( &self, genome: &Genome, diff_op: &ReadOp, target_ref_start0: u32, ) -> bool

Check whether every read base in a Diff operation matches the reference at the proposed corrected target position.

Source

pub fn merge_adjacent_op_pairs( pairs: &[(ReadOpKind, u32)], ) -> Vec<(ReadOpKind, u32)>

Source

pub fn is_aligned_kind(kind: ReadOpKind) -> bool

Trait Implementations§

Source§

impl Clone for AlignedRead

Source§

fn clone(&self) -> AlignedRead

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AlignedRead

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AlignedRead

Source§

fn eq(&self, other: &AlignedRead) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for AlignedRead

Source§

impl StructuralPartialEq for AlignedRead

Auto Trait Implementations§

Blanket Implementations§

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.