Skip to main content

AlignmentFeatures

Struct AlignmentFeatures 

Source
pub struct AlignmentFeatures {
Show 15 fields pub mapping_quality: u8, pub is_mapped: bool, pub is_paired: bool, pub is_supplementary: bool, pub is_secondary: bool, pub is_mate_mapped: Option<bool>, pub template_length: i32, pub aligned_length: usize, pub num_matches: usize, pub num_insertions: usize, pub num_deletions: usize, pub num_soft_clips: usize, pub num_hard_clips: usize, pub edit_distance: Option<u32>, pub tags: HashMap<String, String, RandomState>,
}
Expand description

Features extracted from an alignment record for ML analysis

Fields§

§mapping_quality: u8

Mapping quality score (0-255, 0=unmapped, 255=highest quality)

§is_mapped: bool

Is the read mapped to the reference?

§is_paired: bool

Is this read part of a paired-end sequencing run?

§is_supplementary: bool

Is this a supplementary alignment?

§is_secondary: bool

Is this a secondary alignment?

§is_mate_mapped: Option<bool>

Is the mate read mapped (for paired reads)?

§template_length: i32

Template length (insert size for paired reads)

§aligned_length: usize

Number of aligned bases (from CIGAR)

§num_matches: usize

Number of matches (M operations in CIGAR)

§num_insertions: usize

Number of insertions (I operations in CIGAR)

§num_deletions: usize

Number of deletions (D operations in CIGAR)

§num_soft_clips: usize

Number of soft clips (S operations in CIGAR)

§num_hard_clips: usize

Number of hard clips (H operations in CIGAR)

§edit_distance: Option<u32>

Edit distance to reference (from NM tag if present)

§tags: HashMap<String, String, RandomState>

Additional SAM tags

Implementations§

Source§

impl AlignmentFeatures

Source

pub fn from_record(record: &impl Record) -> Result<AlignmentFeatures, Error>

Extract features from a SAM/BAM record

§Example
use deepbiop_bam::features::AlignmentFeatures;
use noodles::bam;

let features = AlignmentFeatures::from_record(record)?;
println!("Mapping quality: {}", features.mapping_quality);
println!("Is mapped: {}", features.is_mapped);
Source

pub fn identity(&self) -> f32

Calculate alignment identity (matches / aligned_length)

Source

pub fn indel_rate(&self) -> f32

Calculate indel rate ((insertions + deletions) / aligned_length)

Source

pub fn is_high_quality(&self, min_quality: u8) -> bool

Check if this is a high-quality alignment (mapping quality >= threshold)

Source

pub fn is_proper_pair(&self, max_insert_size: i32) -> bool

Check if this is a proper pair (both mates mapped, reasonable insert size)

Trait Implementations§

Source§

impl Clone for AlignmentFeatures

Source§

fn clone(&self) -> AlignmentFeatures

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AlignmentFeatures

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V