[docs]classDefaultZambiaData:""" This class contains the default data file paths for Zambia. """data_root=resources.files(zambia_data)historical_vmmc_data_file=data_root.joinpath("historical_vmmc_data.csv")initial_age_distribution_file=data_root.joinpath("initial_age_distribution.csv")initial_population_file=data_root.joinpath("initial_population.csv")female_mortality_file=data_root.joinpath("parsed_mortality--female.csv")male_mortality_file=data_root.joinpath("parsed_mortality--male.csv")fertility_file=data_root.joinpath("parsed_fertility.csv")
[docs]definitialize_campaign(self,schema_path,base_year):print(f"Telling emod-api to use {schema_path} as schema.")camp.set_schema(schema_path)camp.base_year=base_yearreturncamp
[docs]@staticmethoddefload_nchooser_distribution_data(file_path:str)->dict:""" Load target distribution data into a dataframe format that works for Nchooser and group by node_id. Args: file_path: path to the csv file that contains the data Returns: dict: a dictionary that has node_id as the key and a dataframe as the value. The dataframe contains the distribution data for Nchooser. """data=pd.read_csv(file_path)data_dict=defaultdict(pd.DataFrame)fornode_idinpd.unique(data['node_set']):node_data=data[data['node_set']==node_id]node_dict={'year':[],'min_age':[],'max_age':[],'n_circumcisions':[]}foryearinpd.unique(node_data['year']):year_data=node_data[node_data['year']==year]for_,rowinyear_data.iterrows():node_dict['year'].append(year)node_dict['min_age'].append(float(row['age_bin'].split(':')[0].replace('[','')))node_dict['max_age'].append(float(row['age_bin'].split(':')[1].replace(')',''))-0.00001)node_dict['n_circumcisions'].append(int(row['n_circumcisions']))data_dict[int(node_id)]=pd.DataFrame(node_dict)returndata_dict
[docs]defadd_male_circumcision(self,campaign,historical_vmmc_data_filepath,traditional_male_circumcision_coverages_per_node):# ---- Add historical vmmc NChooser events to campaign ----self.add_historical_vmmc_nchooser(campaign,historical_vmmc_data_filepath)# ---- Add traditional male circumcision to campaign ----self.add_traditional_male_circumcision(campaign,traditional_male_circumcision_coverages_per_node)# ---- Add (VMMC) reference tracking to campaign ----self.add_vmmc_reference_tracking(campaign)
[docs]defadd_historical_vmmc_nchooser(self,campaign,historical_vmmc_data_filepath:str,historical_vmmc_reduced_acquire=0.6,historical_vmmc_start_year=2008):# Load historical vmmc data into data framehistorical_vmmc_data=self.load_nchooser_distribution_data(historical_vmmc_data_filepath)fornode_idinhistorical_vmmc_data:coc.add_historical_vmmc_nchooser(campaign=campaign,historical_vmmc_distributions_by_time=historical_vmmc_data[node_id],historical_vmmc_reduced_acquire=historical_vmmc_reduced_acquire,historical_vmmc_property_restrictions=None,historical_vmmc_start_year=historical_vmmc_start_year,historical_vmmc_node_ids=[node_id],has_intervention_name_exclusion=coc.ANY_MC,event_name=f"NChooser to produce specified number of program VMMCs in node"f" {node_id}, {self.country_name}")
[docs]defadd_vmmc_reference_tracking(self,campaign):vmmc_time_value_map={"Times":[2015.9999,2016,2021],"Values":[0,0.54,0.9]}coc.add_vmmc_reference_tracking(campaign=campaign,vmmc_time_value_map=vmmc_time_value_map,vmmc_reduced_acquire=0.6,vmmc_target_min_age=15,vmmc_target_max_age=29.999999,vmmc_start_year=2015,vmmc_node_ids=None,# all nodesupdate_period=30.4166666666667)
[docs]defseed_infections(self,campaign):# add outbreak individual interventions with coverage 0.1 to all nodes with Risk:HIGH# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!# DMB Removing "Risk:HIGH" and increasing coverage to 0.2. Anna had some plots from 2016# that showed prevalence closer to 20% for gender-based age bins 25-45 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!coc.seed_infections(campaign=campaign,seeding_node_ids=None,# all nodesseeding_start_year=1982,seeding_coverage=0.2,seeding_target_property_restrictions=[])
[docs]defadd_pmtct(self,campaign):self.add_state_TestingOnANC(campaign)# Testing of children at 6 weeks of ageself.add_state_TestingOnChild6w(campaign)
[docs]defadd_ART_cascade(self,campaign,art_cascade_start_year:float=1990):start_day=coc.timestep_from_year(art_cascade_start_year,self.base_year)self.add_state_TestingOnSymptomatic(campaign=campaign,start_day=start_day)## ---- BEGIN ART STAGING SECTION ----#self.add_state_ARTStagingDiagnosticTest(campaign=campaign,start_day=start_day)self.add_state_ARTStaging(campaign=campaign,start_day=start_day)## ---- BEGIN PRE-ART ----## chance of linking to pre-ARTself.add_state_LinkingToPreART(campaign=campaign,start_day=start_day)# ensuring each agent continues this cascade once per timestepself.add_state_OnPreART(campaign=campaign,start_day=start_day)## ---- BEGIN ART LINKING ----#self.add_state_LinkingToART(campaign=campaign,start_day=start_day)# decide to initiate ART now or laterself.add_state_OnART(campaign=campaign,start_day=start_day)#self.add_state_LostForever(campaign=campaign,start_day=start_day)
[docs]defbuild_campaign(self,schema_path:str,base_year:float,historical_vmmc_data_filepath:Union[str,Traversable],traditional_male_circumcision_coverages_per_node:dict):""" A method to pass into EMODTask to build campaign events for Emod. Args: schema_path(str): file path to the schema file. base_year(float): base year for the Simulation. historical_vmmc_data_filepath(str): file path to the historical vmmc data csv file. traditional_male_circumcision_coverages_per_node(Dict[int: float]): coverage of traditional male circumcision per node. Returns: """# ---- Initialize a campaign object -----campaign=self.initialize_campaign(schema_path,base_year)# ---- Add male circumcision to campaign -----# This block contains 3 chunk of events: historical vmmc NChooser, traditional male circumcision and VMMC with# reference tracking.self.add_male_circumcision(campaign,historical_vmmc_data_filepath,traditional_male_circumcision_coverages_per_node)# ---- Add prevention of mother-to-child transmission (PMTCT) to campaign ----# This pmtct block contains 2 Cascade states: TestingOnANC and TestingOnChild6wself.add_pmtct(campaign)# ---- Add OutbreakIndividual interventions to campaign ----self.seed_infections(campaign)# ---- Add commercial sex worker (CSW) uptake and dropout (with delays) for men and women to campaign ----self.add_csw(campaign)# ---- Add co-infections post sexual debut to campaign ----self.add_post_debut_coinfection(campaign)# ---- Add health care testing loops to campaign ----# This health care testing block contains 3 Cascade states: HCTUptakeAtDebut, HCTUptakePostDebut and# HCTTestingLoopself.add_health_care_testing(campaign)# ---- Add Antiretroviral Therapy (ART) Cascade to campaign ----# This ART Cascade block contains 8 Cascade states: TestingOnSymptomatic, ARTStagingDiagnosticTest, ARTStaging# LinkingToPreART, OnPreART, LinkingToART, OnART and LostForeverself.add_ART_cascade(campaign)returncampaign
[docs]classZambia(Country):""" Zambia country model class. This class is a subclass of the Country class and implements the build_campaign method to build campaign object to be used with EMODTask. Example: >>> from emodpy_hiv.country_model import Zambia >>> from emodpy.emod_task import EMODTask >>> import manifest >>> from functools import partial >>> zambia = Zambia() >>> # Define a campaign_builder function to pass in the required arguments for the zambia.build_campaign() method. >>> def campaign_builder(): >>> return zambia.build_campaign(schema_path=manifest.schema_file, base_year=1960.5) >>> # Alternatively, you can use the partial function to pass in the required arguments for the >>> # zambia.build_campaign() method. For example: >>> # campaign_builder = partial(zambia.build_campaign, schema_path=manifest.schema_file, base_year=1960.5) >>> # Create an EMODTask object using the campaign_builder function >>> task = EMODTask.from_default2(config_path="config.json", >>> eradication_path=manifest.eradication_path, >>> campaign_builder=campaign_builder, ...) """def__init__(self,country_name="Zambia"):super().__init__(country_name)
[docs]defbuild_config(self,config):config.parameters.Simulation_Type="HIV_SIM"config.parameters.Simulation_Duration=99.5*365config.parameters.Simulation_Timestep=30.4166666666667# Reduce the initial population so tutorial can double itconfig.parameters.x_Base_Population=0.002#0.005config.parameters.Start_Time=0config.parameters.AIDS_Duration_In_Months=9config.parameters.AIDS_Stage_Infectivity_Multiplier=4.5config.parameters.Acute_Duration_In_Months=2.9config.parameters.Acute_Stage_Infectivity_Multiplier=26config.parameters.Age_Initialization_Distribution_Type="DISTRIBUTION_COMPLEX"config.parameters.Base_Individual_Sample_Rate=1config.parameters.Base_Infectivity=0.00031382269992254885config.parameters.Base_Year=1960.5config.parameters.Birth_Rate_Dependence="INDIVIDUAL_PREGNANCIES_BY_AGE_AND_YEAR"config.parameters.Birth_Rate_Time_Dependence="NONE"config.parameters.CD4_At_Death_LogLogistic_Heterogeneity=0.7config.parameters.CD4_At_Death_LogLogistic_Scale=2.96config.parameters.CD4_Post_Infection_Weibull_Heterogeneity=0.2756config.parameters.CD4_Post_Infection_Weibull_Scale=560.43config.parameters.Coital_Dilution_Factor_2_Partners=0.75config.parameters.Coital_Dilution_Factor_3_Partners=0.6config.parameters.Coital_Dilution_Factor_4_Plus_Partners=0.45config.parameters.Condom_Transmission_Blocking_Probability=0.8config.parameters.Days_Between_Symptomatic_And_Death_Weibull_Heterogeneity=0.5config.parameters.Days_Between_Symptomatic_And_Death_Weibull_Scale=618.341625config.parameters.Death_Rate_Dependence="NONDISEASE_MORTALITY_BY_YEAR_AND_AGE_FOR_EACH_GENDER"config.parameters.Enable_Aging=1config.parameters.Enable_Birth=1config.parameters.Enable_Coital_Dilution=1config.parameters.Enable_Default_Reporting=1config.parameters.Enable_Demographics_Reporting=0config.parameters.Enable_Demographics_Birth=0config.parameters.Enable_Infectivity_Reservoir=0config.parameters.Enable_Maternal_Protection=0config.parameters.Enable_Natural_Mortality=1config.parameters.HIV_Adult_Survival_Scale_Parameter_Intercept=21.182config.parameters.HIV_Adult_Survival_Scale_Parameter_Slope=-0.2717config.parameters.HIV_Adult_Survival_Shape_Parameter=2config.parameters.HIV_Age_Max_for_Adult_Age_Dependent_Survival=50config.parameters.HIV_Age_Max_for_Child_Survival_Function=15config.parameters.HIV_Child_Survival_Rapid_Progressor_Fraction=0.57config.parameters.HIV_Child_Survival_Rapid_Progressor_Rate=1.52config.parameters.HIV_Child_Survival_Slow_Progressor_Scale=16config.parameters.HIV_Child_Survival_Slow_Progressor_Shape=2.7config.parameters.Heterogeneous_Infectiousness_LogNormal_Scale=0config.parameters.Incubation_Period_Constant=0config.parameters.Incubation_Period_Distribution="CONSTANT_DISTRIBUTION"config.parameters.Individual_Sampling_Type="FIXED_SAMPLING"config.parameters.Infection_Updates_Per_Timestep=1config.parameters.Infectivity_Scale_Type="CONSTANT_INFECTIVITY"config.parameters.Male_To_Female_Relative_Infectivity_Ages=[0,15,25]config.parameters.Male_To_Female_Relative_Infectivity_Multipliers=[2.9976868182763963,2.9976868182763963,2.936393464131044]config.parameters.Maternal_Infection_Transmission_Probability=0.3config.parameters.Maternal_Transmission_ART_Multiplier=0.03334config.parameters.Migration_Model="NO_MIGRATION"config.parameters.Min_Days_Between_Adding_Relationships=0config.parameters.Node_Grid_Size=0.009config.parameters.PFA_Burnin_Duration_In_Days=5475config.parameters.PFA_Cum_Prob_Selection_Threshold=0.2config.parameters.Population_Density_Infectivity_Correction="CONSTANT_INFECTIVITY"config.parameters.Population_Scale_Type="FIXED_SCALING"config.parameters.Run_Number=1config.parameters.STI_Coinfection_Acquisition_Multiplier=5.5config.parameters.STI_Coinfection_Transmission_Multiplier=5.5config.parameters.Serialized_Population_Reading_Type="NONE"config.parameters.Serialized_Population_Writing_Type="NONE"config.parameters.Sexual_Debut_Age_Setting_Type="WEIBULL"config.parameters.Sexual_Debut_Age_Female_Weibull_Heterogeneity=0.22002507694706103config.parameters.Sexual_Debut_Age_Female_Weibull_Scale=15.092122890359025config.parameters.Sexual_Debut_Age_Male_Weibull_Heterogeneity=0.1268087803455056config.parameters.Sexual_Debut_Age_Male_Weibull_Scale=15.582384534190258config.parameters.Sexual_Debut_Age_Min=13config.parameters["logLevel_InfectionHIV"]="ERROR"config.parameters["logLevel_Instrumentation"]="INFO"config.parameters["logLevel_Memory"]="INFO"config.parameters["logLevel_OutbreakIndividual"]="ERROR"config.parameters["logLevel_Simulation"]="INFO"config.parameters["logLevel_SusceptibilityHIV"]="ERROR"config.parameters["logLevel_AntiretroviralTherapy"]="ERROR"config.parameters["logLevel_default"]="WARNING"returnconfig