Skip to content

Commit

Permalink
trim carriage return (\r) from contig names
Browse files Browse the repository at this point in the history
seems to happen with strobealign for some reason
  • Loading branch information
AroneyS committed Jun 11, 2024
1 parent 411f5b2 commit a80d4eb
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/coverage_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ pub fn print_dense_cached_coverage_taker(
entry_names[stoit_by_entry_by_coverage[0][my_entry_i].entry_index]
.as_ref()
.unwrap()
.trim_end_matches('\r')
)
.unwrap();
for (stoit_i, stoit_entries) in stoit_by_entry_by_coverage.iter().enumerate() {
Expand All @@ -482,7 +483,7 @@ pub fn print_dense_cached_coverage_taker(
print_stream,
"\t{}",
coverages[i]
// Divide first because then there is less
// Divide first because then there are fewer
// rounding errors, particularly when
// coverage == coverage_total
/coverage_totals[ecs.stoit_index][i].unwrap()
Expand Down Expand Up @@ -573,6 +574,31 @@ mod tests {
);
}

#[test]
fn test_dense_cached_printer_newline() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
c.start_stoit("stoit1");
c.start_entry(0, "contig1\r");
c.add_single_coverage(1.1);
c.add_single_coverage(1.2);
let mut stream = Cursor::new(Vec::new());
print_dense_cached_coverage_taker(
"Contig",
&vec!["mean".to_string(), "std".to_string()],
&c,
&mut stream,
None,
&vec![],
None,
None,
);
assert_eq!(
"Contig\tstoit1 mean\tstoit1 std\n\
contig1\t1.1\t1.2\n",
str::from_utf8(stream.get_ref()).unwrap()
);
}

#[test]
fn test_dense_cached_printer_easy_normalised() {
let mut c = CoverageTakerType::new_cached_single_float_coverage_taker(2);
Expand Down

0 comments on commit a80d4eb

Please sign in to comment.