seqtkrs 0.1.1

A Rust reimplementation of seqtk, a fast and lightweight tool for processing biological sequences in FASTA/FASTQ format
Documentation
use crate::core::{SeqReader, SeqRecord};
use anyhow::Result;
use clap::Args;

#[derive(Args, Debug)]
pub struct SizeArgs {
    /// 输入FASTA/FASTQ文件
    #[arg(value_name = "in.fq")]
    pub input: String,
}

pub fn run(args: &SizeArgs) -> Result<()> {
    let mut reader = if args.input == "-" {
        SeqReader::from_stdin()
    } else {
        SeqReader::from_path(&args.input)?
    };

    let mut record = SeqRecord::new(Vec::new(), Vec::new());
    let mut n_seqs = 0u64;
    let mut total_len = 0u64;

    while reader.read_next(&mut record)? {
        n_seqs += 1;
        total_len += record.seq.len() as u64;
    }

    println!("{}\t{}", n_seqs, total_len);
    Ok(())
}