feat: add configurable presence threshold to kmer distance

Introduce a `--presence-threshold` CLI argument (default: 1) and update `KmerIndex::distance` to accept a `presence_threshold` parameter. This replaces hardcoded zero thresholds, enabling configurable filtering of low-abundance kmers during Jaccard distance calculations.
This commit is contained in:
Eric Coissac committed 2026-06-08 20:14:33 +02:00
1 parent 1ec65922df
commit eb7805c747
2 files changed
+8 -5

No files matched your search

+5 -1
View File
@@ -46,6 +46,10 @@ pub struct DistanceArgs {
#[arg(long, value_enum, default_value = "jaccard")]
pub metric: MetricArg,
/// Minimum count to consider a kmer present when computing Jaccard on count indexes
#[arg(long, default_value = "1")]
pub presence_threshold: u32,
/// Also output the shared-kmer count matrix (CSV)
#[arg(long)]
pub shared_kmers: bool,
@@ -81,7 +85,7 @@ pub fn run(args: DistanceArgs) {
let need_shared = args.shared_kmers || args.nj || args.upgma;
let result = idx
.distance(args.metric.into(), need_shared)
.distance(args.metric.into(), need_shared, args.presence_threshold)
.unwrap_or_else(|e| {
eprintln!("error computing distances: {e}");
std::process::exit(1);