//! Super-kmer construction pipeline.
//!
//! Consumes normalised rope chunks from `obiread` and produces
//! `(minimizer, SuperKmer)` pairs ready for scatter routing.

#![deny(missing_docs)]

pub mod iter;
pub mod stream_iter;
mod scratch;

pub(crate) mod encoding;
pub(crate) mod entropy_table;
pub(crate) mod rolling_stat;

pub use iter::SuperKmerIter;
pub use scratch::SuperKmerScratch;
pub use stream_iter::SuperKmerStreamIter;

use obiread::NucPage;
use obikrope::Rope;
use obikseq::RoutableSuperKmer;

/// Collect all super-kmers from a normalised [`NucPage`].
pub fn build_superkmers_page(
    page: NucPage,
    k: usize,
    level_max: usize,
    theta: f64,
) -> Vec<RoutableSuperKmer> {
    let cursor = page.cursor();
    SuperKmerStreamIter::new(cursor, k, level_max, theta).collect()
}

/// Collect all super-kmers from a normalised rope chunk.
pub fn build_superkmers(
    rope: Rope,
    k: usize,
    level_max: usize,
    theta: f64,
) -> Vec<RoutableSuperKmer> {
    SuperKmerIter::new(&rope, k, level_max, theta).collect()
}
