md_analysis 0.2.1

molecular dynamics
use clap::{Args, Parser, Subcommand};

/// 分子动力学分析工具 — 读取 BAM 文件中的 dw/ar 字段并分 bin 计数
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct CliArgs {
    #[command(subcommand)]
    pub commands: Commands,
    /// 输入的 BAM 文件路径
    #[arg(short = 'i')]
    pub bam_file: String,

    /// stats worker 数量(默认:可用核心数的一半)
    #[arg(long, short = 'w', default_value_t = 0)]
    pub workers: usize,
}

#[derive(Subcommand, Debug, Clone)]
pub enum Commands {
    RawBam(RawBamArgs),
    AlignedBam(AlignedBamArgs),
}

#[derive(Debug, Args, Clone)]
pub struct RawBamArgs {
    /// 仅处理物理长度 >= 此值的 reads(None = 不限制)
    #[arg(long = "length-min")]
    pub length_min: Option<usize>,

    /// 仅处理物理长度 <= 此值的 reads(None = 不限制)
    #[arg(long = "length-max")]
    pub length_max: Option<usize>,

    /// 仅收集前 n 个位置 + 后 n 个位置的 dw/ar 值(0 = 收集全部)
    #[arg(long = "slice-n", default_value_t = 0)]
    pub slice_n: usize,
}

#[derive(Debug, Args, Clone)]
pub struct AlignedBamArgs {
    #[arg(long = "ref-range", help="1:3,4:4   (left_inclusive, right_inclusive)")]
    pub ref_range: String,
}