use crate::core::{DosageMatrix, VariantInfo};

/// A single chunk from a streaming reader.
#[derive(Debug, Clone)]
pub struct GenotypeChunk {
    pub variants: VariantInfo,
    pub dosages: DosageMatrix,
    pub offset: usize,
    pub total_variants: usize,
}

impl GenotypeChunk {
    pub fn n_samples(&self) -> usize {
        self.dosages.n_samples()
    }

    pub fn n_variants(&self) -> usize {
        self.dosages.n_variants()
    }

    pub fn is_last(&self) -> bool {
        self.offset + self.n_variants() >= self.total_variants
    }

    pub fn progress(&self) -> f64 {
        if self.total_variants == 0 {
            return 1.0;
        }
        (self.offset + self.n_variants()) as f64 / self.total_variants as f64
    }
}
