#################################################################
#
# MASH
# R6-ified
# SimBite module for PfMOI
# David Smith, Hector Sanchez, Sean Wu
# June 9, 2017
#
#################################################################
#' Initialize SimBite PfMOI Module
#'
#' Generate a list of parameters PfMOI_PAR in \code{\link{HumanPop}} and public methods in \code{\link{Human}}
#'
#' @param PfMOI_PAR optional parameter list generated by \code{\link{PfMOI.Parameters}}, if \code{NULL} this will be set to default values
#' @return Defines a field (list) PfMOI_PAR in \code{\link{HumanPop}} and public methods in \code{\link{Human}}
#' @examples
#' SimBitePfMOI.Setup()
#' @export
SimBitePfMOI.Setup <- function(PfMOI_PAR = NULL, overwrite = TRUE){
message("Initializing PfMOI SimBite Module")
###################################################################
# Simulated biting on 'Human' Class
###################################################################
# probeHost_PfMOI
Human$set(which = "public",name = "probeHost_PfMOI",
value = probeHost_SimBitePfMOI,
overwrite = overwrite
)
# add2Q_SimBitePfMOI
Human$set(which = "public",name = "add2Q_SimBitePfSI",
value = add2Q_SimBitePfMOI,
overwrite = overwrite
)
# event_SimBitePfMOI
Human$set(which = "public",name = "event_SimBitePfMOI",
value = event_SimBitePfMOI,
overwrite = overwrite
)
Human$set(which = "public",name = "SimBitePfMOI",
value = SimBitePfMOI,
overwrite = overwrite
)
###################################################################
# Tools to initialize simulated biting for 'HumanPop' class
###################################################################
# queueBites
HumanPop$set(which = "public",name = "queueBites_SimBitePfMOI",
value = queueBites_SimBitePfMOI,
overwrite = overwrite
)
HumanPop$set(which = "public",name = "queueVaccination_SimBitePfMOI",
value = queueVaccination_SimBitePfMOI,
overwrite = overwrite
)
}
###################################################################
# PfMOI Simulated Host Probing
###################################################################
#' PfMOI \code{Human} Method: Simulated Host Probing
#'
#' This method is a filler for a host probing event in called in \code{\link{SimBitePfMOI}}.
#' If the bite is infectious, the method calls \code{\link{infectiousBite_PfMOI}}, otherwise does nothing.
#' This method is bound to \code{Human$probeHost_PfMOI()} after correct initialization with \code{\link{SimBitePfMOI.Setup}}.
#'
#' @param tBite time of bite
#' @param mosquitoPfMOI \code{\link{mosquitoPfMOI}} object passed from mosquito to human
probeHost_SimBitePfMOI <- function(tBite, mosquitoPfMOI){
MOI = mosquitoPfMOI$get_MOI()
if(MOI>0){
N = self$get_PfMOI_PAR("MosyMaxI")
infNum = max(MOI,N)
for(i in 1:infNum){
infNum = infNum - 1L
PAR = mosquitoPfMOI$get_InfectionIx(i)
self$infectiousBite_PfMOI(tBite, PAR)
}
}
}
###################################################################
# PfMOI SimBite methods for 'Human'
###################################################################
#' PfMOI SimBite \code{Human} Event: Add PfMOI Simulated Bite Event to Event Queue
#'
#' Simulate a PfMOI infectious bite.
#' This method is bound to \code{Human$add2Q_SimBitePfMOI()}
#' This method adds event \code{\link{event_SimBitePfMOI}} to the event queue.
#' This method is bound to \code{Human$add2Q_SimBitePfMOI()}
#'
#' @param tEvent time of bite
#' @param PAR write me!
add2Q_SimBitePfMOI <- function(tEvent, PAR = NULL){
PAR = list()
PAR$mosquitoPfMOI = mosquitoPfMOI(PfID = -1L, tInf = -1L, MOI = 1L, damID = -1L, sireID = -1L)
private$EventQueue$addEvent2Q(event = self$event_SimBitePfMOI(tEvent = tEvent, PAR = PAR))
}
#' PfMOI SimBite \code{Human} Event: Generate PfMOI Simulated Bite Event
#'
#' Generate PfMOI Simulated Bite event to place in event queue.
#' This method is called from \code{\link{add2Q_SimBitePfMOI}}
#' This method is bound to \code{Human$event_SimBitePfMOI()}
#' * tag: \code{\link{SimBitePfMOI}}
#' @md
#' @param tEvent time of bite
#' @param PAR named list
#' * mosquitoPfSI: object of class \code{\link{mosquitoPfMOI}}
#' @md
event_SimBitePfMOI <- function(tEvent, PAR = NULL){
list(tEvent = tEvent, PAR = PAR, tag = "SimBitePfMOI")
}
#' PfMOI SimBite \code{Human} Event: PfMOI Simulated Bite Event
#'
#' Simulate a PfMOI Simulated Bite. This calls \code{\link{probeHost_PfMOI}} to simulate host probing by an infectious mosquito.
#' This method is bound to \code{Human$SimBitePfMOI()}
#' @param tEvent time of bite
#' @param PAR named list
#' * mosquitoPfSI: object of class \code{\link{mosquitoPfMOI}}
#' @md
SimBitePfMOI <- function(tEvent, PAR){
self$probeHost_PfMOI(tEvent, PAR$mosquitoPfMOI)
}
###################################################################
# PfMOI SimBite methods for 'HumanPop'
###################################################################
#' PfMOI SimBite \code{HumanPop} Method: Queue SimBites for Population
#'
#' Add queued bite times to a population; bite times can be generated from \code{\link{SimBite_WaitingTime}}, \code{\link{SimBite_MeanBites}}
#' This method is bound to \code{HumanPop$queueBites_SimBitePfMOI()}
#' @param bites a list of length equal to number of humans where each element is a vector of biting times to add to queue with \code{\link{add2Q_SimBitePfMOI}}.
#' @export
queueBites_SimBitePfMOI <- function(bites){
for(ixH in 1:self$nHumans){
print(paste0("queueing simulated bites for human: ",ixH))
for(tBite in bites[[ixH]]){
private$pop[[ixH]]$add2Q_SimBitePfSI(tEvent = tBite)
}
}
}
#' PfMOI SimBite \code{HumanPop} Method: Queue Vaccination for Population
#'
#' Queue vaccination for a population, calling \code{\link{add2Q_pevaccinatePfMOI}}.
#' If \code{tTreat} is given, queue follow up treatment by calling \code{\link{add2Q_treatPfMOI}}.
#' This method is bound to \code{HumanPop$queueVaccination_SimBitePfMOI()}
#' @param tVaccine time of vaccination
#' @param tTreat time of follow up treatment (if \code{NULL} no treatment)
#' @param fracPop fraction of population that recieves vaccination
#' @export
queueVaccination_SimBitePfMOI <- function(tVaccine, tTreat = NULL, fracPop){
for(ixH in 1:floor(fracPop*self$nHumans)){
print(paste0("queueing vaccination for human: ",ixH))
private$pop[[ixH]]$add2Q_pevaccinatePfMOI(tEvent = tVaccine)
if(!is.null(tTreat)){
private$pop[[ixH]]$add2Q_treatPfMOI(tEvent = tTreat)
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.