From eab7cf9b6d117e3f7455f1fe0e74b43d6ec28601 Mon Sep 17 00:00:00 2001 From: Andrew Frantz Date: Mon, 18 Dec 2023 14:04:10 -0500 Subject: [PATCH] fix: cap QNAME warnings to 100 QNAMES --- src/derive/endedness/compute.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/derive/endedness/compute.rs b/src/derive/endedness/compute.rs index c92eee2..ec5439b 100644 --- a/src/derive/endedness/compute.rs +++ b/src/derive/endedness/compute.rs @@ -204,6 +204,8 @@ fn calculate_reads_per_template( let mut read_group_reads: HashMap, usize> = HashMap::new(); let mut read_group_templates: HashMap, usize> = HashMap::new(); + let mut warning_count: usize = 0; + for (read_name, read_groups) in read_names.iter() { let num_reads = read_groups.len(); total_reads += num_reads; @@ -223,10 +225,20 @@ fn calculate_reads_per_template( .and_modify(|e| *e += 1) .or_insert(1); } else { - warn!( - "QNAME: '{}' is in multiple read groups: {:?}", - read_name, read_group_set - ); + warning_count += 1; + match warning_count { + 1..=100 => { + warn!( + "QNAME: '{}' is in multiple read groups: {:?}", + read_name, read_group_set + ); + } + 101 => warn!( + "Too many warnings about QNAMEs in multiple read groups. Stopping warnings." + ), + _ => (), + } + for read_group in read_groups { read_group_reads .entry(Arc::clone(read_group)) @@ -242,6 +254,13 @@ fn calculate_reads_per_template( } } + if warning_count > 100 { + warn!( + "{} QNAMEs were found in multiple read groups.", + warning_count + ); + } + reads_per_template.insert( Arc::clone(&OVERALL), total_reads as f64 / total_templates as f64,