fastars 0.1.0

Ultra-fast QC and trimming for short and long reads
Documentation
//! Quality control module for collecting read metrics.
//!
//! This module provides comprehensive QC statistics collection
//! for FASTQ reads, including:
//!
//! - Base quality distribution
//! - Base composition (A, T, G, C, N)
//! - GC content
//! - Read length distribution
//! - K-mer analysis
//! - Duplication estimation

pub mod base_content;
pub mod duplication;
pub mod fast_stats;
pub mod gc;
pub mod insert_size;
pub mod kmer;
pub mod length;
pub mod quality;
pub mod stats;

pub use base_content::BaseContent;
pub use duplication::DuplicationStats;
pub use fast_stats::FastQcStats;
pub use gc::GcStats;
pub use insert_size::{InsertSizeEstimator, InsertSizeStats};
pub use kmer::{FiveMerStats, KmerStats};
pub use length::LengthStats;
pub use quality::QualityStats;
pub use stats::{FilteringStats, QcStats, QcSummary};

use serde::{Deserialize, Serialize};

/// Operating mode for QC statistics collection.
///
/// This affects pre-allocation sizes and certain metrics.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
pub enum Mode {
    /// Short-read mode (Illumina-style): pre-allocates for ~300bp reads
    #[default]
    Short,
    /// Long-read mode (PacBio/ONT): pre-allocates for ~50,000bp reads
    Long,
}

impl Mode {
    /// Returns the default pre-allocation size for position-based arrays.
    #[inline]
    pub fn default_capacity(self) -> usize {
        match self {
            Mode::Short => 300,
            Mode::Long => 50_000,
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_mode_default() {
        let mode = Mode::default();
        assert_eq!(mode, Mode::Short);
    }

    #[test]
    fn test_mode_capacity() {
        assert_eq!(Mode::Short.default_capacity(), 300);
        assert_eq!(Mode::Long.default_capacity(), 50_000);
    }

    #[test]
    fn test_mode_serialize() {
        let mode = Mode::Long;
        let json = serde_json::to_string(&mode).unwrap();
        assert_eq!(json, "\"Long\"");
    }
}