diff --git a/src/obikindex/src/select.rs b/src/obikindex/src/select.rs index 1db57bd..a27125b 100644 --- a/src/obikindex/src/select.rs +++ b/src/obikindex/src/select.rs @@ -3,7 +3,7 @@ use std::io; use std::path::Path; use obikpartitionner::{KmerPartition, OutputCol, PARTITIONS_SUBDIR}; -use obisys::{Stage, progress_bar}; +use obisys::{Reporter, Stage, progress_bar}; use tracing::info; use crate::error::{OKIError, OKIResult}; @@ -25,6 +25,7 @@ impl KmerIndex { threshold: u32, output_presence: bool, force: bool, + rep: &mut Reporter, ) -> OKIResult { let output = output.as_ref(); @@ -80,13 +81,14 @@ impl KmerIndex { ).map_err(OKIError::Partition)?; pb.finish_and_clear(); - - let _ = t.stop(); + rep.push(t.stop()); fs::File::create(output.join(SENTINEL_INDEXED))?; let idx = KmerIndex::open(output)?; + let t_pack = Stage::start("pack"); idx.pack_matrices()?; + rep.push(t_pack.stop()); Ok(idx) } @@ -98,6 +100,7 @@ impl KmerIndex { specs: &[OutputCol], threshold: u32, output_presence: bool, + rep: &mut Reporter, ) -> OKIResult<()> { if self.state() != IndexState::Indexed { return Err(OKIError::NotIndexed(self.root_path.clone())); @@ -106,7 +109,6 @@ impl KmerIndex { let n_src_genomes = self.meta.genomes.len(); let n_partitions = self.partition.n_partitions(); - // Open a second handle to the same path so we can borrow src and dst simultaneously. let src_partition = KmerPartition::open_with_config( &self.root_path, self.meta.config.kmer_size, @@ -132,17 +134,17 @@ impl KmerIndex { ).map_err(OKIError::Partition)?; pb.finish_and_clear(); + rep.push(t.stop()); - let _ = t.stop(); - - // Update index.meta with new genome list and with_counts flag. self.meta.config.with_counts = !output_presence; self.meta.genomes = specs.iter() .map(|s| GenomeInfo::new(s.label.clone())) .collect(); self.meta.write(&self.root_path)?; + let t_pack = Stage::start("pack"); self.pack_matrices()?; + rep.push(t_pack.stop()); Ok(()) } } diff --git a/src/obikmer/src/cmd/select.rs b/src/obikmer/src/cmd/select.rs index e021b36..35719e8 100644 --- a/src/obikmer/src/cmd/select.rs +++ b/src/obikmer/src/cmd/select.rs @@ -4,6 +4,7 @@ use std::path::PathBuf; use clap::{Args, ValueEnum}; use obikindex::{GenomeInfo, KmerIndex}; use obikpartitionner::{AggOp, OutputCol}; +use obisys::Reporter; use tracing::info; use super::predicate::matching_genome_indices; @@ -229,20 +230,24 @@ pub fn run(args: SelectArgs) { if output_presence { "presence" } else { "count" }, ); + let mut rep = Reporter::new(); + if args.in_place { - src.select_in_place(&specs, args.presence_threshold, output_presence) + src.select_in_place(&specs, args.presence_threshold, output_presence, &mut rep) .unwrap_or_else(|e| { eprintln!("select error: {e}"); std::process::exit(1); }); + rep.print(); info!("selected in-place → {}", args.source.display()); } else { let output = args.output.unwrap(); - KmerIndex::select(&output, &src, &specs, args.presence_threshold, output_presence, args.force) + KmerIndex::select(&output, &src, &specs, args.presence_threshold, output_presence, args.force, &mut rep) .unwrap_or_else(|e| { eprintln!("select error: {e}"); std::process::exit(1); }); + rep.print(); info!("selected index → {}", output.display()); } }