Source code for emodpy_generic.interventions.emergence

from emod_api import schema_to_class as s2c
from emod_api.interventions.utils import *

schema_path =  None

[docs]def basicEmergenceEvent(camp, genome=0, clade=0, start_day=1, nods=[]): """ Seed infection at a particular time by importing a new infected individual. Note that this function imports 20 individuals age 5. This could be made configurable but is not yet because this was created with a particular use case in mind. All other values are set to schema defaults. :param genome: Genome of new infection. :param clade: Clade of new infection. :param start_day: WHEN: Day to start campaign event. :param nods: WHERE: List of nodes at which infections will be seeded. Returns: Campaign event that can be added to campaign. """ if camp is not None: schema_path = camp.schema_path event = s2c.get_class_with_defaults( "CampaignEvent", schema_path ) coordinator = s2c.get_class_with_defaults( "StandardInterventionDistributionEventCoordinator", schema_path ) if coordinator is None: print( "s2c.get_class_with_defaults returned None. Maybe no schema.json was provided." ) return "" try: coordinator.Max_Distributions_Per_Node = cases except Exception as ex: # This can be fine because this is a new parameter only in some branches. # Obviously this question is more general and needs a better general solution # if at all possible. Max_Distributions_Per_Node is an event coordinator optional param. print( str( ex ) ) event.Event_Coordinator_Config = coordinator # The intervention itself should be reused from another module intervention = s2c.get_class_with_defaults( "Outbreak", schema_path ) intervention.Genome=genome intervention.Clade=clade intervention.Import_Age=5*365 intervention.Number_Cases_Per_Node=20 coordinator.Intervention_Config = intervention event.Start_Day = float(start_day) if len(nods) > 0: nodelist = s2c.get_class_with_defaults( "NodeSetNodeList", schema_path ) nodelist.Node_List = nods event.Nodeset_Config = nodelist #event["Event_Name"] = Event_Name return event
[docs]def basicSIAEvent(camp, cov=1.0, genome=0, clade=0, start_day=1, nods=[]): """ Seed infection at a particular time by infected existing individuals (or agents really) in the simulation. Note that the targeted ages are 0-5 years, not configurable without code change. :param clade: Clade of new infection. :param genome: Genome of new infection. :param cov: WHO. Percentage of population to infect (given other targeting constrants). :param start_day: WHEN: Day to start campaign event. :param nods: WHERE: List of nodes at which infections will be seeded. Returns: Campaign event that can be added to campaign. """ if camp is not None: schema_path = camp.schema_path event = s2c.get_class_with_defaults( "CampaignEvent", schema_path ) coordinator = s2c.get_class_with_defaults( "StandardInterventionDistributionEventCoordinator", schema_path ) if coordinator is None: print( "s2c.get_class_with_defaults returned None. Maybe no schema.json was provided." ) return "" try: coordinator.Max_Distributions_Per_Node = cases except Exception as ex: # This can be fine because this is a new parameter only in some branches. # Obviously this question is more general and needs a better general solution # if at all possible. Max_Distributions_Per_Node is an event coordinator optional param. print( str( ex ) ) coordinator.Target_Age_Max=5 coordinator.Target_Age_Min=0 coordinator.Demographic_Coverage = cov event.Event_Coordinator_Config = coordinator # The intervention itself should be reused from another module # intervention = emodpy-generic.interventions.standard_generic_vaccine intervention = s2c.get_class_with_defaults( "OutbreakIndividual", schema_path ) intervention.Ignore_Immunity=0 intervention.Incubation_Period_Override=1 intervention.Genome=genome intervention.Clade=clade coordinator.Intervention_Config = intervention event.Start_Day = float(start_day) if len(nods) > 0: nodelist = do_nodes( camp, nods ) #event["Event_Name"] = Event_Name return event
[docs]def new_intervention_as_file( timestep, filename=None ): """ This function mostly exists for testing so one can exercise the functionality in a single function call. """ camp.add( basicEmergenceEvent( timestep, vaccine_type, iv_name ) ) if filename is None: filename = "emergence.json" camp.save( filename ) return filename