From 83b4adde5dfc5d215278f300c7673031caea3def Mon Sep 17 00:00:00 2001 From: Francesco Terenzi Date: Thu, 4 Apr 2024 11:47:36 +0100 Subject: [PATCH] fix saving timepoints when we simulate 1 year only --- src/clap_app.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/clap_app.rs b/src/clap_app.rs index 9563deaa..5d52928b 100644 --- a/src/clap_app.rs +++ b/src/clap_app.rs @@ -181,19 +181,19 @@ pub struct Cli { subsamples: Option>, } -impl Cli { - fn build_snapshots_from_time(n_snapshots: usize, time: f32) -> Vec { - let dx = time / ((n_snapshots - 1) as f32); - let mut x = vec![0.; n_snapshots]; - for i in 1..n_snapshots - 1 { - x[i] = x[i - 1] + dx; - } - - x.shrink_to_fit(); - x[n_snapshots - 1] = time; - x +fn build_snapshots_from_time(n_snapshots: usize, time: f32) -> Vec { + let dx = time / ((n_snapshots - 1) as f32); + let mut x = vec![0.; n_snapshots]; + for i in 1..n_snapshots - 1 { + x[i] = x[i - 1] + dx; } + x.shrink_to_fit(); + x[n_snapshots - 1] = time; + x +} + +impl Cli { pub fn normalise_mutation_rate(rate: F) -> F { rate / NumCast::from(2).unwrap() } @@ -255,7 +255,7 @@ impl Cli { } } (None, None) => VecDeque::from_iter( - Cli::build_snapshots_from_time(10usize, years as f32 - 1.) + build_snapshots_from_time(10usize, if years > 1 { years as f32 - 1. } else { 0.9 }) .into_iter() .map(|t| Snapshot { cells2sample: cli.cells as usize,