Skip to content

Commit

Permalink
fix: cap QNAME warnings to 100 QNAMES
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Dec 18, 2023
1 parent 7e1578b commit eab7cf9
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/derive/endedness/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ fn calculate_reads_per_template(
let mut read_group_reads: HashMap<Arc<String>, usize> = HashMap::new();
let mut read_group_templates: HashMap<Arc<String>, 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;
Expand All @@ -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))
Expand All @@ -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,
Expand Down

0 comments on commit eab7cf9

Please sign in to comment.