Skip to content

Commit

Permalink
Don't crash when a read is perfect, durring yacrd report parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Marijon committed Jul 18, 2020
1 parent 84d8259 commit ab13fb6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ impl FromReport {
fn parse_bad_string(bad_string: &str) -> Result<Vec<(u32, u32)>> {
let mut ret = Vec::new();

if bad_string.is_empty() {
return Ok(ret);
}

for sub in bad_string.split(';') {
let mut iter = sub.split(',');
iter.next();
Expand Down Expand Up @@ -284,6 +288,27 @@ Chimeric SRR8494940.91655 15691 151,0,151;4056,7213,11269;58,15633,15691"
);
}

#[test]
fn perfect_read_in_report() {
let mut report = NamedTempFile::new().expect("Can't create tmpfile");

writeln!(report.as_file_mut(), "NotBad perfect 2706 ")
.expect("Error durring write of report in temp file");

let mut stack = FromReport::new(report.into_temp_path().to_str().unwrap())
.expect("Error when create stack object");

assert_eq!(
["perfect".to_string()]
.iter()
.cloned()
.collect::<std::collections::HashSet<String>>(),
stack.get_reads()
);

assert_eq!(&(vec![], 2706), stack.get_bad_part("perfect").unwrap());
}

#[test]
fn from_overlap() {
let mut ovl = reads2ovl::FullMemory::new();
Expand Down

0 comments on commit ab13fb6

Please sign in to comment.