Add unitig streaming iterators and estimate CLI subcommand
Introduce `iter_unitigs` methods across the index cache, content layer, MphfLayer, and typed layer to stream whole reconstructed sequences directly from underlying storage without decomposing into k-mers. Add a corresponding low-level streaming iterator in obiskio for thread-safe, lazy reads from memory-mapped files. Include a new CLI subcommand to compute and display approximate false-positive rates based on provided indexing parameters.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
use clap::Args;
|
||||
|
||||
use super::index::resolve_approx_params;
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct EstimateArgs {
|
||||
/// k-mer size used for querying (same as --kmer-size in index)
|
||||
#[arg(short = 'k', long, default_value_t = 31)]
|
||||
pub kmer_size: usize,
|
||||
|
||||
/// Findere z parameter: number of consecutive k-mers that must all match.
|
||||
/// Effective indexed k-mer size is kmer_size - z + 1.
|
||||
#[arg(short = 'z', long, default_value = None)]
|
||||
pub findere_z: Option<u8>,
|
||||
|
||||
/// Fingerprint bits per slot (b). FP per z-window = 1/2^(b·z).
|
||||
#[arg(long, default_value = None)]
|
||||
pub evidence_bits: Option<u8>,
|
||||
|
||||
/// Target false-positive rate per z-window (e.g. 0.01).
|
||||
#[arg(long, default_value = None)]
|
||||
pub fp: Option<f64>,
|
||||
}
|
||||
|
||||
pub fn run(args: EstimateArgs) {
|
||||
let (z, b, fp_window) = resolve_approx_params(args.findere_z, args.evidence_bits, args.fp);
|
||||
|
||||
let k_query = args.kmer_size;
|
||||
let k_index = k_query.saturating_sub(z as usize - 1);
|
||||
let fp_kmer = 1.0_f64 / 2_f64.powi(b as i32);
|
||||
|
||||
println!("{:<22} {}", "k (query):", k_query);
|
||||
println!("{:<22} {}", "k (indexed):", k_index);
|
||||
println!("{:<22} {}", "z:", z);
|
||||
println!("{:<22} {}", "evidence bits (b):", b);
|
||||
println!("{:<22} {:.3e} (1/2^{})", "FP per k-mer:", fp_kmer, b);
|
||||
println!("{:<22} {:.3e} (1/2^{})", "FP per z-window:", fp_window, b as u32 * z as u32);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod estimate;
|
||||
pub mod index;
|
||||
pub mod merge;
|
||||
pub mod superkmer;
|
||||
|
||||
@@ -19,6 +19,8 @@ enum Commands {
|
||||
Superkmer(cmd::superkmer::SuperkmerArgs),
|
||||
/// Merge multiple genome indexes into one
|
||||
Merge(cmd::merge::MergeArgs),
|
||||
/// Estimate approximate-evidence false-positive rates for given parameters
|
||||
Estimate(cmd::estimate::EstimateArgs),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -34,5 +36,6 @@ fn main() {
|
||||
Commands::Index(args) => cmd::index::run(args),
|
||||
Commands::Superkmer(args) => cmd::superkmer::run(args),
|
||||
Commands::Merge(args) => cmd::merge::run(args),
|
||||
Commands::Estimate(args) => cmd::estimate::run(args),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user