Skip to content

Commit 7ccbe8b

Browse files
committed
Add n_hits to config in preparation
1 parent 6b4d34a commit 7ccbe8b

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

examples/compartments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fn main() {
5050
max_population: 1_000_000,
5151
dilution: 0.02,
5252
host_model: HostModel::SingleHost(host_fitness),
53+
n_hits: 1,
5354
};
5455

5556
let (mut attribute_definition, host_specs) =

examples/simulation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ fn main() {
6767
max_population: 1_000_000,
6868
dilution: 0.02,
6969
host_model: HostModel::SingleHost(HostFitness::new(Some(fitness_model), None)),
70+
n_hits: 1,
7071
};
7172
simulation_settings
7273
.write_to_file("parameters_example.yaml")

src/config/parameters.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,41 @@ use crate::simulation::BasicHost;
1313

1414
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
1515
pub struct Parameters {
16+
/// The mutation rate represents the probability of a mutation occurring in a virus at each
17+
/// time step.
1618
pub mutation_rate: f64,
19+
20+
/// The recombination rate represents the probability of recombination occurring between two
21+
/// viruses in the population.
1722
pub recombination_rate: f64,
23+
24+
/// The size of the host population in the simulation.
1825
pub host_population_size: usize,
26+
27+
/// The basic reproductive number represents the average burst size of a virus in the population.
1928
pub basic_reproductive_number: f64,
29+
30+
/// The maximum population size for number of viruses in the simulation.
2031
pub max_population: usize,
32+
33+
/// The dilution factor represents the fraction of the population that is diluted at each
34+
/// time step.
2135
pub dilution: f64,
36+
37+
/// The substitution matrix is a 4x4 matrix representing the probabilities of nucleotide
38+
/// substitutions.
2239
pub substitution_matrix: [[f64; 4]; 4],
40+
41+
/// The host model defines host population structure and fitness characteristics.
2342
pub host_model: HostModel,
43+
44+
/// The number of times a virus can hit hosts before it fails to infect.
45+
#[serde(default = "default_n_hits")]
46+
pub n_hits: usize,
47+
}
48+
49+
fn default_n_hits() -> usize {
50+
1
2451
}
2552

2653
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
@@ -188,6 +215,7 @@ mod tests {
188215
)),
189216
None,
190217
)),
218+
n_hits: 1,
191219
};
192220
settings.write(&mut buffer).unwrap();
193221
let read_settings = Parameters::read(&mut buffer.as_slice()).unwrap();
@@ -226,6 +254,7 @@ mod tests {
226254
)),
227255
None,
228256
)),
257+
n_hits: 1,
229258
};
230259
settings.write(&mut buffer).unwrap();
231260
let read_settings = Parameters::read(&mut buffer.as_slice()).unwrap();
@@ -256,6 +285,7 @@ mod tests {
256285
)),
257286
None,
258287
)),
288+
n_hits: 1,
259289
};
260290
settings.write_to_file(path).unwrap();
261291
let read_settings = Parameters::read_from_file(path).unwrap();

src/config/settings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ mod tests {
7373
)),
7474
None,
7575
)),
76+
n_hits: 1,
7677
}],
7778
schedule: Schedule::from_vec(vec![
7879
ScheduleRecord::new("0", "transmission", "migration_fwd"),

src/providers/fitness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl<S: Symbol> FitnessProvider<S> {
217217
.try_get_ancestor()
218218
.expect("Could not find ancestor during fitness update...")
219219
.get_or_compute_attribute_raw(self.name)
220-
.unwrap()
220+
.unwrap(),
221221
)
222222
.unwrap();
223223
let update = self.update_fitness(haplotype);

src/simulation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ mod tests {
579579
max_population: POPULATION_SIZE,
580580
dilution: 1.,
581581
host_model: HostModel::SingleHost(FITNESS_MODEL),
582+
n_hits: 1,
582583
};
583584

584585
fn setup_test_simulation() -> BasicSimulation<Nt> {

0 commit comments

Comments
 (0)