pub struct SamStats {Show 24 fields
pub total_reads: usize,
pub mapped_reads: usize,
pub unmapped_reads: usize,
pub properly_paired: usize,
pub duplicates: usize,
pub secondary_alignments: usize,
pub supplementary_alignments: usize,
pub qc_failed: usize,
pub mapq_stats: RunningStats,
pub mapq_distribution: CategoryCounter<u8>,
pub length_stats: RunningStats,
pub length_distribution: CategoryCounter<usize>,
pub reads_per_chrom: CategoryCounter<String>,
pub high_quality_mapq10: usize,
pub high_quality_mapq20: usize,
pub high_quality_mapq30: usize,
pub first_in_pair: usize,
pub second_in_pair: usize,
pub reverse_strand: usize,
pub total_matches: u64,
pub total_insertions: u64,
pub total_deletions: u64,
pub total_soft_clips: u64,
pub total_hard_clips: u64,
}Expand description
Comprehensive statistics for SAM files
Fields§
§total_reads: usizeTotal number of reads
mapped_reads: usizeNumber of mapped reads
unmapped_reads: usizeNumber of unmapped reads
properly_paired: usizeNumber of reads mapped in proper pairs
duplicates: usizeNumber of duplicate reads
secondary_alignments: usizeNumber of secondary alignments
supplementary_alignments: usizeNumber of supplementary alignments
qc_failed: usizeNumber of QC-failed reads
mapq_stats: RunningStatsMapping quality statistics (for mapped reads only)
mapq_distribution: CategoryCounter<u8>Distribution of mapping qualities
length_stats: RunningStatsRead length statistics
length_distribution: CategoryCounter<usize>Distribution of read lengths
reads_per_chrom: CategoryCounter<String>Reads per chromosome
high_quality_mapq10: usizeNumber of reads with MAPQ >= 10
high_quality_mapq20: usizeNumber of reads with MAPQ >= 20
high_quality_mapq30: usizeNumber of reads with MAPQ >= 30
first_in_pair: usizePaired-end statistics
second_in_pair: usize§reverse_strand: usize§total_matches: u64CIGAR operation statistics
total_insertions: u64§total_deletions: u64§total_soft_clips: u64§total_hard_clips: u64Implementations§
Source§impl SamStats
impl SamStats
Sourcepub fn update(&mut self, record: &SamRecord)
pub fn update(&mut self, record: &SamRecord)
Update statistics with a single record (streaming)
Optimized for single-pass processing: computes all statistics in one iteration over alignment data, avoiding repeated allocations and iterations.
Sourcepub fn par_compute(_reader: &mut SamReader, _threads: usize) -> Result<Self>
pub fn par_compute(_reader: &mut SamReader, _threads: usize) -> Result<Self>
Compute statistics in parallel (not yet implemented for SAM)
SAM files are text-based and harder to parallelize efficiently than binary BAM files.
For now, use compute() for sequential processing, which is still fast.
Future implementation may support:
- Chunked parallel processing with line-boundary detection
- Memory-mapped file access with parallel scanning
For parallel statistics on alignment files, consider using BAM format instead.
Sourcepub fn compute(reader: &mut SamReader) -> Result<Self>
pub fn compute(reader: &mut SamReader) -> Result<Self>
Compute statistics from a SAM reader (sequential processing)
SAM files are text-based, so parallel processing is more complex than BAM. For now, we use sequential processing which is still very fast for text parsing.
§Example
use genomicframe_core::formats::sam::{SamReader, SamStats};
let mut reader = SamReader::from_path("alignments.sam")?;
reader.read_header()?;
let stats = SamStats::compute(&mut reader)?;
stats.print_summary();Sourcepub fn mean_length(&self) -> Option<f64>
pub fn mean_length(&self) -> Option<f64>
Mean read length
Sourcepub fn std_length(&self) -> Option<f64>
pub fn std_length(&self) -> Option<f64>
Standard deviation of read length
Sourcepub fn min_length(&self) -> Option<f64>
pub fn min_length(&self) -> Option<f64>
Min read length
Sourcepub fn max_length(&self) -> Option<f64>
pub fn max_length(&self) -> Option<f64>
Max read length
Sourcepub fn mapping_rate(&self) -> f64
pub fn mapping_rate(&self) -> f64
Mapping rate (percentage of mapped reads)
Sourcepub fn properly_paired_rate(&self) -> f64
pub fn properly_paired_rate(&self) -> f64
Properly paired rate (percentage of properly paired reads)
Sourcepub fn duplicate_rate(&self) -> f64
pub fn duplicate_rate(&self) -> f64
Duplicate rate (percentage of duplicate reads)
Sourcepub fn percent_mapq10(&self) -> f64
pub fn percent_mapq10(&self) -> f64
Percentage of reads with MAPQ >= 10
Sourcepub fn percent_mapq20(&self) -> f64
pub fn percent_mapq20(&self) -> f64
Percentage of reads with MAPQ >= 20
Sourcepub fn percent_mapq30(&self) -> f64
pub fn percent_mapq30(&self) -> f64
Percentage of reads with MAPQ >= 30
Sourcepub fn print_summary(&self)
pub fn print_summary(&self)
Print a human-readable summary of statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SamStats
impl RefUnwindSafe for SamStats
impl Send for SamStats
impl Sync for SamStats
impl Unpin for SamStats
impl UnsafeUnpin for SamStats
impl UnwindSafe for SamStats
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