Skip to content

Commit

Permalink
Merge pull request #249 from mrc-ide/vivax_pre_eryth_imm
Browse files Browse the repository at this point in the history
Vivax pre eryth imm
  • Loading branch information
RJSheppard authored Jul 21, 2023
2 parents 7e5af02 + 8d99d2d commit 37aa34f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 97 deletions.
8 changes: 6 additions & 2 deletions R/human_infection.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ calculate_infections <- function(
source_humans <- variables$state$get_index_of(
c('S', 'A', 'U'))$and(bitten_humans)

b <- blood_immunity(variables$ib$get_values(source_humans), parameters)

if(parameters$parasite == "falciparum"){ ## P. falciparum models blood immunity
b <- blood_immunity(variables$ib$get_values(source_humans), parameters)
} else if (parameters$parasite == "vivax"){ ## P. vivax does not model blood immunity
b <- parameters$b
}

source_vector <- source_humans$to_vector()

# calculate prophylaxis
Expand Down
4 changes: 0 additions & 4 deletions data-raw/parasite_parameters.csv
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ vivax,rb,3650,TO BE REMOVED: NOT VIVAX: Job 4: Immunity
vivax,rid,3650,
vivax,rc,10950,
vivax,rva,10950,TO BE REMOVED: NOT VIVAX: Job 4: Immunity
vivax,b0,0.59,TO BE REMOVED: NOT VIVAX: Job 2: FOI
vivax,b1,0.5,TO BE REMOVED: NOT VIVAX: Job 2: FOI
vivax,ib0,43.9,TO BE REMOVED: NOT VIVAX: Job 2: FOI
vivax,kb,2.16,TO BE REMOVED: NOT VIVAX: Job 2: FOI
vivax,b,0.5,
vivax,fd0,0.007055,TO BE REMOVED: NOT VIVAX: Job 4: Immunity/detectability
vivax,ad,7993.5,TO BE REMOVED: NOT VIVAX: Job 4: Immunity/detectability
Expand Down
Binary file modified data/parasite_parameters.rda
Binary file not shown.
4 changes: 3 additions & 1 deletion man/get_parameters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 0 additions & 90 deletions tests/testthat/test-vivax.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,93 +24,3 @@ test_that('Test difference between falciparum and vivax parameter lists', {
expect_true(all(names(vivax_parameters[!names(vivax_parameters) %in% names(falciparum_parameters)]) %in%
c("du_max","du_min","ku","au50","b","phi0lm","phi1lm","ic0lm","kclm","d0","ca","init_idm","f","gammal")))
})

test_that('Test age structure should not change vivax infectivity', {

# Set all individuals to asymptomatic
# And ID immunity to not 0 (ID impacts age-specific asymptomatic infectivity)
parameters <- get_parameters(overrides = list(s_proportion = 0,
d_proportion = 0,
a_proportion = 1,
u_proportion = 0,
t_proportion = 0,
init_id = 0.5))

vivax_parameters <- get_parameters(parasite = "vivax",
overrides = list(s_proportion = 0,
d_proportion = 0,
a_proportion = 1,
u_proportion = 0,
t_proportion = 0,
init_id = 0.5))

# Generate different age structure
year <- 365
ages <- round(c(0.083333, 1, 5, 10, 15, 20, 25, 30, 35, 40, 45,
50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 200) * year)

deathrates <- rep(.1, length(ages)) / 365

dem_parameters <- set_demography(
parameters,
agegroups = ages,
timesteps = 0,
deathrates = matrix(deathrates, nrow = 1)
)

vivax_dem_parameters <- set_demography(
vivax_parameters,
agegroups = ages,
timesteps = 0,
deathrates = matrix(deathrates, nrow = 1)
)

# vivax asymptomatic infectivity should equal ca
expect_true(all(
c(create_variables(vivax_parameters)$infectivity$get_values(),
create_variables(vivax_dem_parameters)$infectivity$get_values())==vivax_parameters$ca))

# falciparum asymptomatic infectivity should not equal ca
expect_false(any(
c(create_variables(parameters)$infectivity$get_values(),
create_variables(dem_parameters)$infectivity$get_values())==vivax_parameters$ca))

# falciparum asymptomatic infectivity should change with age structure
expect_false(any(
c(create_variables(parameters)$infectivity$get_values() == create_variables(dem_parameters)$infectivity$get_values())))
})

test_that('vivax schedule_infections correctly schedules new infections', {
parameters <- get_parameters(list(human_population = 20), parasite = "vivax")
variables <- create_variables(parameters)

infections <- individual::Bitset$new(20)$insert(1:20)
clinical_infections <- individual::Bitset$new(20)$insert(5:15)
treated <- individual::Bitset$new(20)$insert(7:12)

infection_mock <- mockery::mock()

mockery::stub(schedule_infections, 'update_infection', infection_mock)

schedule_infections(
variables,
clinical_infections,
treated,
infections,
parameters,
42
)

actual_infected <- mockery::mock_args(infection_mock)[[1]][[5]]$to_vector()
actual_asymp_infected <- mockery::mock_args(infection_mock)[[2]][[5]]$to_vector()

expect_equal(
actual_infected,
c(5, 6, 13, 14, 15)
)

expect_equal(
actual_asymp_infected,
c(1, 2, 3, 4, 16, 17, 18, 19, 20)
)
})

0 comments on commit 37aa34f

Please sign in to comment.