diff --git a/src/abacus.rs b/src/abacus.rs index 89a0362..3d0d762 100644 --- a/src/abacus.rs +++ b/src/abacus.rs @@ -372,7 +372,7 @@ impl AbacusAuxilliary { while i < v.len() { if v[i - 1].1 >= v[i].0 { let x = v.remove(i); - v[i - 1].1 = x.1; + v[i - 1].1 = std::cmp::max(v[i - 1].1, x.1); } else { i += 1 } @@ -393,7 +393,7 @@ impl AbacusAuxilliary { ) { // *only relevant for bps count in combination with subset option* // this table stores the number of bps of nodes that are *partially* uncovered by subset - // coodinates + // coordinates let subset_covered_bps: Option = if count == &CountType::Bp && self.include_coords.is_some() { Some(IntervalContainer::new()) @@ -1177,20 +1177,37 @@ mod tests { let path_aux = AbacusAuxilliary::from_params(¶ms, &graph_aux).unwrap(); let test_abacus_by_total = AbacusByTotal { count: CountType::Node, - countable: vec![CountSize::MAX, 6,4,4,2,1], + countable: vec![CountSize::MAX, 6, 4, 4, 2, 1], uncovered_bps: Some(HashMap::default()), - groups: vec!["a#1#h1".to_string(), "b#1#h1".to_string(), - "c#1#h1".to_string(), "c#1#h2".to_string(), - "c#2#h1".to_string(), "d#1#h1".to_string() - ] + groups: vec![ + "a#1#h1".to_string(), + "b#1#h1".to_string(), + "c#1#h1".to_string(), + "c#1#h2".to_string(), + "c#2#h1".to_string(), + "d#1#h1".to_string(), + ], }; let mut data = bufreader_from_compressed_gfa(test_gfa_file.as_str()); - let abacus_by_total = AbacusByTotal::from_gfa(&mut data, &path_aux, &graph_aux, CountType::Node); - assert_eq!(abacus_by_total.count, test_abacus_by_total.count, "Expected CountType to match Node"); - assert_eq!(abacus_by_total.countable, test_abacus_by_total.countable, "Expected same countable"); - assert_eq!(abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, "Expected empty uncovered bps"); - assert_eq!(abacus_by_total.groups, test_abacus_by_total.groups, "Expected same groups"); + let abacus_by_total = + AbacusByTotal::from_gfa(&mut data, &path_aux, &graph_aux, CountType::Node); + assert_eq!( + abacus_by_total.count, test_abacus_by_total.count, + "Expected CountType to match Node" + ); + assert_eq!( + abacus_by_total.countable, test_abacus_by_total.countable, + "Expected same countable" + ); + assert_eq!( + abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, + "Expected empty uncovered bps" + ); + assert_eq!( + abacus_by_total.groups, test_abacus_by_total.groups, + "Expected same groups" + ); } fn setup_test_data_chr_m(count_type: CountType) -> (GraphAuxilliary, Params, String) { @@ -1221,23 +1238,192 @@ mod tests { let path_aux = AbacusAuxilliary::from_params(¶ms, &graph_aux).unwrap(); let test_abacus_by_total = AbacusByTotal { count: count_type, - countable: vec![CountSize::MAX,3,2,1,3,1,2,3,1,2,3,2,3,2,1,3,1,3,2,3,2,3,4,2,2,4,3,1,4,2,2,4,3,1,4,2,2,4,1 - ,4,1,3,4,1,3,4,2,2,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,2,2,4,1,3,4,1,3,4,2,2,4,3,1,4,1,3,4,1,3,4,1,3 - ,4,1,3,4,2,2,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,2,2,4,1,3,4,2,2,4,2,2,4,2,2,4,3,1 - ,4,3,1,4,3,1,4,3,1,4,3,1,4,1], + countable: vec![ + CountSize::MAX, + 3, + 2, + 1, + 3, + 1, + 2, + 3, + 1, + 2, + 3, + 2, + 3, + 2, + 1, + 3, + 1, + 3, + 2, + 3, + 2, + 3, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 2, + 2, + 4, + 1, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 2, + 2, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 1, + ], uncovered_bps: Some(HashMap::default()), - groups: vec!["chm13".to_string(), "grch38".to_string(), - "HG00438".to_string(),"HG00621".to_string(), + groups: vec![ + "chm13".to_string(), + "grch38".to_string(), + "HG00438".to_string(), + "HG00621".to_string(), ], }; let mut data = bufreader_from_compressed_gfa(test_gfa_file.as_str()); - let abacus_by_total = AbacusByTotal::from_gfa(&mut data, &path_aux, &graph_aux, CountType::Node); - assert_eq!(abacus_by_total.count, test_abacus_by_total.count, "Expected CountType to match Node"); - assert_eq!(abacus_by_total.countable, test_abacus_by_total.countable, "Expected same countable"); - assert_eq!(abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, "Expected empty uncovered bps"); - assert_eq!(abacus_by_total.groups, test_abacus_by_total.groups, "Expected same groups"); - let test_hist = vec![0,39,29,41,45]; + let abacus_by_total = + AbacusByTotal::from_gfa(&mut data, &path_aux, &graph_aux, CountType::Node); + assert_eq!( + abacus_by_total.count, test_abacus_by_total.count, + "Expected CountType to match Node" + ); + assert_eq!( + abacus_by_total.countable, test_abacus_by_total.countable, + "Expected same countable" + ); + assert_eq!( + abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, + "Expected empty uncovered bps" + ); + assert_eq!( + abacus_by_total.groups, test_abacus_by_total.groups, + "Expected same groups" + ); + let test_hist = vec![0, 39, 29, 41, 45]; let hist = abacus_by_total.construct_hist(); assert_eq!(hist, test_hist, "Expected same hist"); } @@ -1249,24 +1435,242 @@ mod tests { let path_aux = AbacusAuxilliary::from_params(¶ms, &graph_aux).unwrap(); let test_abacus_by_total = AbacusByTotal { count: count_type, - countable: vec![CountSize::MAX,2,1,2,1,2,1,1,2,1,2,1,2,2,1,2,1,2,2,1,2,1,1,1,2,2,2,1,2,3,2,2,2,2,3,1,3,1,2 - ,2,2,2,3,1,3,1,2,2,2,2,1,3,1,1,3,1,3,1,3,1,3,2,2,2,2,3,1,1,3,3,1,1,3,1,3,1,3,3,1,1,3,1,3,1,3,3,1,1,3,2 - ,2,2,2,1,3,1,3,1,3,1,3,2,2,2,2,1,3,3,1,3,1,1,3,1,3,1,3,1,3,1,3,3,1,1,3,2,2,2,2,3,1,1,3,3,1,1,3,3,1,1,3 - ,3,1,1,3,1,3,1,3,3,1,1,3,3,1,1,3,3,1,1,3,3,1,1,3,2,2,2,2,3,1,1,3,2,2,2,2,2,2,2,2,2,2,2,2,1,3,3,1,3,1,3 - ,1,1,3,3,1,1,3,3,1,1,3,3,1,1], + countable: vec![ + CountSize::MAX, + 2, + 1, + 2, + 1, + 2, + 1, + 1, + 2, + 1, + 2, + 1, + 2, + 2, + 1, + 2, + 1, + 2, + 2, + 1, + 2, + 1, + 1, + 1, + 2, + 2, + 2, + 1, + 2, + 3, + 2, + 2, + 2, + 2, + 3, + 1, + 3, + 1, + 2, + 2, + 2, + 2, + 3, + 1, + 3, + 1, + 2, + 2, + 2, + 2, + 1, + 3, + 1, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 2, + 2, + 2, + 2, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 1, + 3, + 1, + 3, + 3, + 1, + 1, + 3, + 1, + 3, + 1, + 3, + 3, + 1, + 1, + 3, + 2, + 2, + 2, + 2, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 2, + 2, + 2, + 2, + 1, + 3, + 3, + 1, + 3, + 1, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 3, + 1, + 1, + 3, + 2, + 2, + 2, + 2, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 1, + 3, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 2, + 2, + 2, + 2, + 3, + 1, + 1, + 3, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 1, + 3, + 3, + 1, + 3, + 1, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + 3, + 3, + 1, + 1, + ], uncovered_bps: Some(HashMap::default()), - groups: vec!["chm13".to_string(), "grch38".to_string(), - "HG00438".to_string(),"HG00621".to_string(), - ] + groups: vec![ + "chm13".to_string(), + "grch38".to_string(), + "HG00438".to_string(), + "HG00621".to_string(), + ], }; let mut data = bufreader_from_compressed_gfa(test_gfa_file.as_str()); let abacus_by_total = AbacusByTotal::from_gfa(&mut data, &path_aux, &graph_aux, count_type); - assert_eq!(abacus_by_total.count, test_abacus_by_total.count, "Expected CountType to match Edge"); - assert_eq!(abacus_by_total.countable, test_abacus_by_total.countable, "Expected same countable"); - assert_eq!(abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, "Expected empty uncovered bps"); - assert_eq!(abacus_by_total.groups, test_abacus_by_total.groups, "Expected same groups"); - let test_hist = vec![0,80,59,66,0]; + assert_eq!( + abacus_by_total.count, test_abacus_by_total.count, + "Expected CountType to match Edge" + ); + assert_eq!( + abacus_by_total.countable, test_abacus_by_total.countable, + "Expected same countable" + ); + assert_eq!( + abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, + "Expected empty uncovered bps" + ); + assert_eq!( + abacus_by_total.groups, test_abacus_by_total.groups, + "Expected same groups" + ); + let test_hist = vec![0, 80, 59, 66, 0]; let hist = abacus_by_total.construct_hist(); assert_eq!(hist, test_hist, "Expected same hist"); } @@ -1278,23 +1682,191 @@ mod tests { let path_aux = AbacusAuxilliary::from_params(¶ms, &graph_aux).unwrap(); let test_abacus_by_total = AbacusByTotal { count: count_type, - countable: vec![CountSize::MAX,3,2,1,3,1,2,3,1,2,3,2,3,2,1,3,1,3,2,3,2,3,4,2,2,4,3,1,4,2,2,4,3,1,4,2,2,4,1 - ,4,1,3,4,1,3,4,2,2,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,2,2,4,1,3,4,1,3,4,2,2,4,3,1,4,1,3,4,1,3,4,1,3 - ,4,1,3,4,2,2,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,1,3,4,2,2,4,1,3,4,2,2,4,2,2,4,2,2,4,3,1 - ,4,3,1,4,3,1,4,3,1,4,3,1,4,1], + countable: vec![ + CountSize::MAX, + 3, + 2, + 1, + 3, + 1, + 2, + 3, + 1, + 2, + 3, + 2, + 3, + 2, + 1, + 3, + 1, + 3, + 2, + 3, + 2, + 3, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 2, + 2, + 4, + 1, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 1, + 3, + 4, + 2, + 2, + 4, + 2, + 2, + 4, + 2, + 2, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 3, + 1, + 4, + 1, + ], uncovered_bps: Some(HashMap::default()), - groups: vec!["chm13".to_string(), "grch38".to_string(), - "HG00438".to_string(),"HG00621".to_string(), - ] + groups: vec![ + "chm13".to_string(), + "grch38".to_string(), + "HG00438".to_string(), + "HG00621".to_string(), + ], }; let mut data = bufreader_from_compressed_gfa(test_gfa_file.as_str()); let abacus_by_total = AbacusByTotal::from_gfa(&mut data, &path_aux, &graph_aux, count_type); - assert_eq!(abacus_by_total.count, test_abacus_by_total.count, "Expected CountType to match Edge"); - assert_eq!(abacus_by_total.countable, test_abacus_by_total.countable, "Expected same countable"); - assert_eq!(abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, "Expected empty uncovered bps"); - assert_eq!(abacus_by_total.groups, test_abacus_by_total.groups, "Expected same groups"); - let test_hist = vec![0,616,31,601,15949]; + assert_eq!( + abacus_by_total.count, test_abacus_by_total.count, + "Expected CountType to match Edge" + ); + assert_eq!( + abacus_by_total.countable, test_abacus_by_total.countable, + "Expected same countable" + ); + assert_eq!( + abacus_by_total.uncovered_bps, test_abacus_by_total.uncovered_bps, + "Expected empty uncovered bps" + ); + assert_eq!( + abacus_by_total.groups, test_abacus_by_total.groups, + "Expected same groups" + ); + let test_hist = vec![0, 616, 31, 601, 15949]; let hist = abacus_by_total.construct_hist_bps(&graph_aux); assert_eq!(hist, test_hist, "Expected same hist"); } @@ -1311,7 +1883,10 @@ mod tests { let (graph_aux, params, _) = setup_test_data(); let path_aux = AbacusAuxilliary::from_params(¶ms, &graph_aux); - assert!(path_aux.is_ok(), "Expected successful creation of AbacusAuxilliary"); + assert!( + path_aux.is_ok(), + "Expected successful creation of AbacusAuxilliary" + ); let path_aux = path_aux.unwrap(); dbg!(&path_aux.groups.len()); @@ -1323,7 +1898,10 @@ mod tests { let (graph_aux, _, _) = setup_test_data(); let result = AbacusAuxilliary::load_groups("", false, true, &graph_aux); - assert!(result.is_ok(), "Expected successful group loading by sample"); + assert!( + result.is_ok(), + "Expected successful group loading by sample" + ); let groups = result.unwrap(); let mut group_count = HashSet::new(); for (_, g) in groups { @@ -1355,11 +1933,21 @@ mod tests { let coords = Some(vec![PathSegment::from_str("G1")]); let result = AbacusAuxilliary::complement_with_group_assignments(coords, &groups); - assert!(result.is_ok(), "Expected successful complement with group assignments"); + assert!( + result.is_ok(), + "Expected successful complement with group assignments" + ); let complemented = result.unwrap(); - assert!(complemented.is_some(), "Expected Some(complemented) coordinates"); - assert_eq!(complemented.unwrap().len(), 2, "Expected 2 path segments in the complemented list"); + assert!( + complemented.is_some(), + "Expected Some(complemented) coordinates" + ); + assert_eq!( + complemented.unwrap().len(), + 2, + "Expected 2 path segments in the complemented list" + ); } #[test] @@ -1371,21 +1959,54 @@ mod tests { let coords = Some(vec![PathSegment::from_str("G1:1-5")]); let result = AbacusAuxilliary::complement_with_group_assignments(coords, &groups); - assert!(result.is_err(), "Expected error due to invalid group identifier with start/stop information"); + assert!( + result.is_err(), + "Expected error due to invalid group identifier with start/stop information" + ); } #[test] fn test_build_subpath_map_with_overlaps() { let path_segments = vec![ - PathSegment::new("sample".to_string(), "hap1".to_string(), "seq1".to_string(), Some(0), Some(100)), - PathSegment::new("sample".to_string(), "hap1".to_string(), "seq1".to_string(), Some(50), Some(150)), - PathSegment::new("sample".to_string(), "hap1".to_string(), "seq2".to_string(), Some(0), Some(100)), + PathSegment::new( + "sample".to_string(), + "hap1".to_string(), + "seq1".to_string(), + Some(0), + Some(100), + ), + PathSegment::new( + "sample".to_string(), + "hap1".to_string(), + "seq1".to_string(), + Some(50), + Some(150), + ), + PathSegment::new( + "sample".to_string(), + "hap1".to_string(), + "seq2".to_string(), + Some(0), + Some(100), + ), ]; let subpath_map = AbacusAuxilliary::build_subpath_map(&path_segments); - assert_eq!(subpath_map.len(), 2, "Expected 2 sequences in the subpath map"); - assert_eq!(subpath_map.get("sample#hap1#seq1").unwrap().len(), 1, "Expected 1 non-overlapping interval for seq1"); - assert_eq!(subpath_map.get("sample#hap1#seq2").unwrap().len(), 1, "Expected 1 interval for seq2"); + assert_eq!( + subpath_map.len(), + 2, + "Expected 2 sequences in the subpath map" + ); + assert_eq!( + subpath_map.get("sample#hap1#seq1").unwrap().len(), + 1, + "Expected 1 non-overlapping interval for seq1" + ); + assert_eq!( + subpath_map.get("sample#hap1#seq2").unwrap().len(), + 1, + "Expected 1 interval for seq2" + ); } #[test] @@ -1395,13 +2016,19 @@ mod tests { let path_aux = AbacusAuxilliary { groups: AbacusAuxilliary::load_groups("", false, false, &graph_aux).unwrap(), include_coords: None, - exclude_coords: Some(vec![PathSegment::from_str("a#1#h1"), - PathSegment::from_str("b#1#h1"), - PathSegment::from_str("b#1#h1")]), //duplicates do not cause any error + exclude_coords: Some(vec![ + PathSegment::from_str("a#1#h1"), + PathSegment::from_str("b#1#h1"), + PathSegment::from_str("b#1#h1"), + ]), //duplicates do not cause any error order: None, }; let ordered_paths = path_aux.get_path_order(&graph_aux.path_segments); - assert_eq!(ordered_paths.len(), 4, "Expected 4 paths in the final order"); + assert_eq!( + ordered_paths.len(), + 4, + "Expected 4 paths in the final order" + ); } #[test] diff --git a/src/cli.rs b/src/cli.rs index 036c52e..0f26e37 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -556,7 +556,7 @@ pub fn parse_threshold_cli( Ok(thresholds) } -// set number of threads can be run only once, otherwise it throws an error of the +// set number of threads can be run only once, otherwise it throws an error of the // GlobalPoolAlreadyInitialized, which unfortunately is not pub therefore we cannot catch it. // https://github.com/rayon-rs/rayon/issues/878 // We run this function in the main otherwise in the tests the second time we run the function @@ -909,10 +909,7 @@ mod tests { let threshold_str = "5.5,10,15"; let result = parse_threshold_cli(threshold_str, RequireThreshold::Absolute); assert!(result.is_err()); - assert_eq!( - result.unwrap_err().kind(), - ErrorKind::InvalidData - ); + assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidData); } #[test] @@ -920,10 +917,7 @@ mod tests { let threshold_str = "0.2,1.2,0.9"; // 1.2 is out of range for relative threshold let result = parse_threshold_cli(threshold_str, RequireThreshold::Relative); assert!(result.is_err()); - assert_eq!( - result.unwrap_err().kind(), - ErrorKind::InvalidData - ); + assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidData); } #[test] @@ -934,7 +928,6 @@ mod tests { ("group1", false, false, true), // Only groupby is set ("", true, false, true), // Only groupby_haplotype is set ("", false, true, true), // Only groupby_sample is set - // Invalid cases ("group1", true, false, false), // groupby and groupby_haplotype set ("group1", false, true, false), // groupby and groupby_sample set @@ -944,7 +937,11 @@ mod tests { for (test_groupby, test_groupby_haplotype, test_groupby_sample, should_pass) in test_cases { //let mut params = Params::test_default_histgrowth(); - let result = validate_single_groupby_option(test_groupby, test_groupby_haplotype, test_groupby_sample); + let result = validate_single_groupby_option( + test_groupby, + test_groupby_haplotype, + test_groupby_sample, + ); if should_pass { assert!( result.is_ok(), diff --git a/src/graph.rs b/src/graph.rs index 03458d6..2dc9a50 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -594,11 +594,6 @@ impl PathSegment { if let Some(c) = PATHID_PANSN.captures(s) { let segments: Vec<&str> = c.iter().filter_map(|x| x.map(|y| y.as_str())).collect(); // first capture group is the string itself - //log::debug!( - // "path id {} can be decomposed into capture groups {:?}", - // s, - // segments - //); match segments.len() { 4 => { res.sample = segments[1].to_string(); @@ -608,10 +603,10 @@ impl PathSegment { res.seqid = Some(segments[3][1..].to_string()); } Some(cc) => { - log::debug!("path has coodinates {:?}", cc); res.seqid = Some(cc.get(1).unwrap().as_str().to_string()); res.start = usize::from_str(cc.get(2).unwrap().as_str()).ok(); res.end = usize::from_str(cc.get(3).unwrap().as_str()).ok(); + log::debug!("path has coordinates {} ", res); } } } @@ -622,19 +617,19 @@ impl PathSegment { res.haplotype = Some(segments[2][1..].to_string()); } Some(cc) => { - log::debug!("path has coodinates {:?}", cc); res.haplotype = Some(cc.get(1).unwrap().as_str().to_string()); res.start = usize::from_str(cc.get(2).unwrap().as_str()).ok(); res.end = usize::from_str(cc.get(3).unwrap().as_str()).ok(); + log::debug!("path has coordinates {} ", res); } } } 2 => { if let Some(cc) = PATHID_COORDS.captures(segments[1]) { - log::debug!("path has coodinates {:?}", cc); res.sample = cc.get(1).unwrap().as_str().to_string(); res.start = usize::from_str(cc.get(2).unwrap().as_str()).ok(); res.end = usize::from_str(cc.get(3).unwrap().as_str()).ok(); + log::debug!("path has coordinates {}", res); } } _ => (), diff --git a/src/hist.rs b/src/hist.rs index 6051dcc..762bf5b 100644 --- a/src/hist.rs +++ b/src/hist.rs @@ -307,11 +307,11 @@ mod tests { fn test_hist_calc_growth_union() { let hist = Hist { count: CountType::Node, - coverage: vec![0,5,3,2], + coverage: vec![0, 5, 3, 2], }; let t_coverage = Threshold::Absolute(0); - let test_growth: Vec = vec![5.666666666666667, 8.333333333333334, 10.0]; + let test_growth: Vec = vec![5.666666666666667, 8.333333333333334, 10.0]; let growth = hist.calc_growth_union(&t_coverage); assert_eq!(growth, test_growth, "Wrong growth union"); } @@ -320,11 +320,11 @@ mod tests { fn test_hist_calc_growth_core() { let hist = Hist { count: CountType::Node, - coverage: vec![0,5,3,2], + coverage: vec![0, 5, 3, 2], }; let t_coverage = Threshold::Absolute(0); - let test_core: Vec = vec![5.666666666666666, 3.0, 2.0]; + let test_core: Vec = vec![5.666666666666666, 3.0, 2.0]; let core = hist.calc_growth_core(&t_coverage); assert_eq!(core, test_core, "Wrong growth core"); } @@ -333,13 +333,22 @@ mod tests { fn test_hist_calc_growth_quorum() { let hist = Hist { count: CountType::Node, - coverage: vec![0,5,3,2,3,5,0,4,2,1], + coverage: vec![0, 5, 3, 2, 3, 5, 0, 4, 2, 1], }; let t_coverage = Threshold::Absolute(0); let t_quorum = Threshold::Relative(0.9); - let test_growth: Vec = vec![11.88888888888889, 7.027777777777777, 4.761904761904761, - 3.4444444444444438, 2.5952380952380953, 2.0, 1.5555555555555545, 1.2222222222222217, 1.0]; + let test_growth: Vec = vec![ + 11.88888888888889, + 7.027777777777777, + 4.761904761904761, + 3.4444444444444438, + 2.5952380952380953, + 2.0, + 1.5555555555555545, + 1.2222222222222217, + 1.0, + ]; let growth = hist.calc_growth_quorum(&t_coverage, &t_quorum); assert_eq!(growth, test_growth, "Wrong growth quorum"); } diff --git a/src/html.rs b/src/html.rs index a8a0f94..ee8856b 100644 --- a/src/html.rs +++ b/src/html.rs @@ -648,7 +648,12 @@ fn bin_values(list: &Vec) -> (Vec, Vec) { if bin_size < 1 { bin_size = 1; } - log::debug!("Binning with min: {}, max: {}, bin_size: {}", min, max, bin_size); + log::debug!( + "Binning with min: {}, max: {}, bin_size: {}", + min, + max, + bin_size + ); let bins: Vec<_> = (min..max) .step_by(bin_size) .zip((min + (bin_size as u32)..max + 1).step_by(bin_size))