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
impl AlignedRead
Sourcepub fn new(
chr_id: usize,
strand: Strand,
ref_start0: u32,
seq: Vec<u8>,
qual: Option<Vec<u8>>,
ops_input: Vec<(ReadOpKind, u32)>,
) -> Self
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.
Sourcepub fn build_positioned_ops(
ref_start0: u32,
ops_input: &[(ReadOpKind, u32)],
) -> Vec<ReadOp>
pub fn build_positioned_ops( ref_start0: u32, ops_input: &[(ReadOpKind, u32)], ) -> Vec<ReadOp>
Build positioned operations from plain operation/length pairs.
Sourcepub fn from_record(record: &Record, chr_id: usize) -> Self
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.
Sourcepub fn ref_blocks(&self) -> Vec<RefBlock>
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.
Sourcepub fn cigar_op_to_read_op(op: Cigar) -> (ReadOpKind, u32)
pub fn cigar_op_to_read_op(op: Cigar) -> (ReadOpKind, u32)
Convert one BAM CIGAR op into a ReadOpKind.
Sourcepub fn finalize(&mut self) -> Result<(), String>
pub fn finalize(&mut self) -> Result<(), String>
Validate the read and mark it finalized.
Later refinement steps can also call this after changing operations.
Sourcepub fn is_finalized(&self) -> bool
pub fn is_finalized(&self) -> bool
Return whether this read has been finalized.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate sequence, quality, and operation consistency.
Sourcepub fn read_len_from_ops(&self) -> u32
pub fn read_len_from_ops(&self) -> u32
Return read length implied by operations.
Sourcepub fn base_at_ref_pos(&self, pos0: u32) -> Option<ObservedBase>
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.
Sourcepub fn replace_ops(&mut self, ops_input: Vec<(ReadOpKind, u32)>)
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.
Sourcepub fn op_pairs(&self) -> Vec<(ReadOpKind, u32)>
pub fn op_pairs(&self) -> Vec<(ReadOpKind, u32)>
Return operations as plain (kind, len) pairs.
Source§impl AlignedRead
impl AlignedRead
Sourcepub fn refine_against_genome(&mut self, genome: &Genome, options: RefineOptions)
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.
Sourcepub fn refine_against_genome_default(&mut self, genome: &Genome)
pub fn refine_against_genome_default(&mut self, genome: &Genome)
Convenience wrapper using default options.
Sourcepub fn absorb_diff_before_refskip_against_genome(
&self,
pairs: &[(ReadOpKind, u32)],
genome: &Genome,
options: RefineOptions,
) -> Vec<(ReadOpKind, u32)>
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.
Sourcepub fn absorb_diff_after_refskip_against_genome(
&self,
pairs: &[(ReadOpKind, u32)],
genome: &Genome,
options: RefineOptions,
) -> Vec<(ReadOpKind, u32)>
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.
Sourcepub fn diff_matches_reference_at_target(
&self,
genome: &Genome,
diff_op: &ReadOp,
target_ref_start0: u32,
) -> bool
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.
pub fn merge_adjacent_op_pairs( pairs: &[(ReadOpKind, u32)], ) -> Vec<(ReadOpKind, u32)>
pub fn is_aligned_kind(kind: ReadOpKind) -> bool
Trait Implementations§
Source§impl Clone for AlignedRead
impl Clone for AlignedRead
Source§fn clone(&self) -> AlignedRead
fn clone(&self) -> AlignedRead
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlignedRead
impl Debug for AlignedRead
Source§impl PartialEq for AlignedRead
impl PartialEq for AlignedRead
impl Eq for AlignedRead
impl StructuralPartialEq for AlignedRead
Auto Trait Implementations§
impl Freeze for AlignedRead
impl RefUnwindSafe for AlignedRead
impl Send for AlignedRead
impl Sync for AlignedRead
impl Unpin for AlignedRead
impl UnsafeUnpin for AlignedRead
impl UnwindSafe for AlignedRead
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<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