From 99fb0c89ac33fe22ddf12f6d4c5b4ff10e81eac5 Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Wed, 13 Sep 2023 01:38:16 +0200 Subject: [PATCH] fix(cli): add undetected entries into sort tsv --- .../src/cli/nextclade_seq_sort.rs | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/packages_rs/nextclade-cli/src/cli/nextclade_seq_sort.rs b/packages_rs/nextclade-cli/src/cli/nextclade_seq_sort.rs index a00bb7fbb..847a3d1c4 100644 --- a/packages_rs/nextclade-cli/src/cli/nextclade_seq_sort.rs +++ b/packages_rs/nextclade-cli/src/cli/nextclade_seq_sort.rs @@ -139,9 +139,9 @@ pub fn run(args: &NextcladeSortArgs, minimizer_index: &MinimizerIndexJson, verbo #[serde(rename_all = "camelCase")] struct SeqSortCsvEntry<'a> { seq_name: &'a str, - dataset: &'a str, - score: f64, - num_hits: u64, + dataset: Option<&'a str>, + score: Option, + num_hits: Option, } fn writer_thread( @@ -173,15 +173,28 @@ fn writer_thread( for record in result_receiver { stats.print_seq(&record); - for dataset in &record.result.datasets { + let datasets = &record.result.datasets; + + if datasets.is_empty() { + results_csv.map_mut_fallible(|results_csv| { + results_csv.write(&SeqSortCsvEntry { + seq_name: &record.fasta_record.seq_name, + dataset: None, + score: None, + num_hits: None, + }) + })?; + } + + for dataset in datasets { let name = &dataset.name; results_csv.map_mut_fallible(|results_csv| { results_csv.write(&SeqSortCsvEntry { seq_name: &record.fasta_record.seq_name, - dataset: &dataset.name, - score: dataset.score, - num_hits: dataset.n_hits, + dataset: Some(&dataset.name), + score: Some(dataset.score), + num_hits: Some(dataset.n_hits), }) })?;