emodpy_malaria.vector_config module#

emodpy_malaria.vector_config.set_team_defaults(config, manifest)[source]#

Set configuration defaults using team-wide values, including drugs and vector species.

Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path

Returns:

configured config

emodpy_malaria.vector_config.get_species_params(config, species: str = None)[source]#

Returns the species parameters dictionary with the matching species Name

Args:

config: schema-backed config smart dict species: Species to look up

Returns:

Dictionary of species parameters with the matching name

emodpy_malaria.vector_config.set_species_param(config, species, parameter, value, overwrite=False)[source]#

Sets a parameter value for a specific species. Raises value error if species not found

Args:

config: schema-backed config smart dict species: name of species for which to set the parameter parameter: parameter to set value: value to set the parameter to overwrite: if set to True and parameter is a list, overwrites the parameter with value, appends by default

Returns:

Nothing

emodpy_malaria.vector_config.configure_linear_spline(manifest, max_larval_capacity: float = 100000000, capacity_distribution_number_of_years: int = 1, capacity_distribution_over_time: dict = None)[source]#

Configures and returns a ReadOnlyDict of the LINEAR_SPLINE habitat parameters

Args:

manifest: manifest file containing the schema path max_larval_capacity: The maximum larval capacity. Sets Max_Larval_Capacity capacity_distribution_number_of_years: The total length of time in

years for the scaling. If the simulation goes longer than this time, the pattern will repeat. Ideally, this value times 365 is the last value in ‘Capacity_Distribution_Over_Time’. Sets Capacity_Distribution_Number_Of_Years

capacity_distribution_over_time: “This allows one to scale the larval

capacity over time. The Times and Values arrays must be the same length where Times is in days and Values are a scale factor per degrees squared. The value is multiplied times the max capacity and ‘Node_Grid_Size’ squared/4. Ideally, you want the last value to equal the first value if they are one day apart. A point will be added if not. Sets Capacity_Distribution_Over_Time

Example:

{
    "Times": [0,  30,  60,   91,  122, 152, 182, 213, 243, 274, 304, 334, 365 ],
    "Values": [3, 0.8, 1.25, 0.1, 2.7, 8,    4,   35, 6.8, 6.5, 2.6, 2.1, 2]
}
Returns:

Configured Habitat_Type: “LINEAR_SPLINE” parameters to be passed directly to “set_species_params” function

emodpy_malaria.vector_config.add_species(config, manifest, species_to_select)[source]#

Adds species with preset parameters from ‘malaria_vector_species_params.py’, if species name not found - “gambiae” parameters are added and the new species name assigned.

Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path species_to_select: a list of species or a name of a single species you’d like to set from

malaria_vector_species_params.py

Returns:

configured config

emodpy_malaria.vector_config.add_genes_and_alleles(config, manifest, species: str = None, alleles: list = None)[source]#

Adds alleles to a species

Example:

"Genes": [
    {
        "Alleles": [
            {
                "Name": "X1",
                "Initial_Allele_Frequency": 0.5,
                "Is_Y_Chromosome": 0
            },
            {
                "Name": "X2",
                "Initial_Allele_Frequency": 0.25,
                "Is_Y_Chromosome": 0
            },
            {
                "Name": "Y1",
                "Initial_Allele_Frequency": 0.15,
                "Is_Y_Chromosome": 1
            },
            {
                "Name": "Y2",
                "Initial_Allele_Frequency": 0.1,
                "Is_Y_Chromosome": 1
            }
        ],
        "Is_Gender_Gene": 1,
        "Mutations": []
    }
]
Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path species: species to which to assign the alleles alleles: List of tuples of (Name, Initial_Allele_Frequency, Is_Y_Chromosome) for a set of alleles

or (Name, Initial_Allele_Frequency), 1/0 or True/False can be used for Is_Y_Chromosome, third parameter is assumed False (0). If the third parameter is set to 1 in any of the tuples, we assume, this is a gender gene. Example:

[("X1", 0.25), ("X2", 0.35), ("Y1", 0.15), ("Y2", 0.25)]
[("X1", 0.25, 0), ("X2", 0.35, 0), ("Y1", 0.15, 1), ("Y2", 0.25, 1)]
Returns:

configured config

emodpy_malaria.vector_config.add_mutation(config, manifest, species, mutate_from, mutate_to, probability)[source]#

Adds to Mutations parameter in a Gene which has the matching Alleles

Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path species: Name of vector species to which we’re adding mutations mutate_from: The allele in the gamete that could mutate mutate_to: The allele that this locus will change to during gamete generation probability: The probability that the allele will mutate from one allele to the other during the

creation of the gametes

Returns:

configured config

emodpy_malaria.vector_config.create_trait(manifest, trait: str = None, modifier: float = None, sporozoite_barcode_string: str = None, gametocyte_a_barcode_string: str = None, gametocyte_b_barcode_string: str = None)[source]#

Configures and returns a modifier trait.

Args:

manifest: manifest file containing the schema path trait: The trait to be modified of vectors with the given allele combination.

Available traits are: “INFECTED_BY_HUMAN”, “FECUNDITY”, “FEMALE_EGG_RATIO”, “STERILITY”, “TRANSMISSION_TO_HUMAN”, “ADJUST_FERTILE_EGGS”, “MORTALITY”, “INFECTED_PROGRESS”, “OOCYST_PROGRESSION”, “SPOROZOITE_MORTALITY”

modifier: The multiplier to use to modify the given trait for vectors with the given allele combination. sporozoite_barcode_string: TBD gametocyte_a_barcode_string: TBD gametocyte_b_barcode_string: TBD

Returns:

trait parameters that can be added to a list and passed to add_trait() function

emodpy_malaria.vector_config.add_trait(config, manifest, species, allele_combo: list = None, trait_modifiers: list = None)[source]#

Use this function to add traits as part of vector genetics configuration, the trait is assigned to the species’ Gene_To_Trait_Modifiers parameter Should produce something like Example:

{
    "Allele_Combinations" : [
        [  "X",  "X" ],
        [ "a0", "a1" ]
    ],
    "Trait_Modifiers" : [
        {
            "Trait" : "FECUNDITY",
            "Modifier": 0.7
        }
    ]
}
Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path species: Name of species for which to add this Gene_To_Trait_Modifiers allele_combo: List of lists, This defines a possible subset of allele pairs that a vector could have.

Each pair are alleles from one gene. If the vector has this subset, then the associated traits will be adjusted. Order does not matter. ‘*’ is allowed when only the occurrence of one allele is important. Example:

[[  "X",  "X" ], [ "a0", "a1" ]]

trait_modifiers: list of trait modifier parameters created with create_trait() function.

Returns:

configured config

emodpy_malaria.vector_config.add_blood_meal_mortality(config, manifest, default_probability_of_death: float = 0.0, species: str = '', allele_combo: list = None, probability_of_death_for_allele_combo: float = 0.0)[source]#

Add a probability of death after a mosquito has a blood meal. There are some genetically modified mosquitoes that have a fitness cost associated with the digestion of a blood meal. This affects vectors whether this is a human or animal blood meal. This is a GeneticProbability such that the probability used can depend on the genetic makeup of the mosquito. The deaths from this are added to the “die after feeding” numbers for vectors that have fed on humans and “die before feeding on a human” for vectors that die after animal blood meal.

If you need to add multiple allele combos for the same species, call this method once for each allele combo and associated probability. If you do, please note that the default probability will be combined by OR’ing the different values together [1-((1-p1)*(1-p2))]. Also note that the default probabilities for each species will be OR’d together.

The probability selected for given genome will depend on the “complexity” of the allele combinations. If an entry has more genes/loci positions than another, the combination with more will be considered first. If they have the same number of genes and one has fewer possible genomes, the one with fewer possible genomes will be considered first. For example, if you add a1-a1 in one call and b1-b0 in a second call, EMOD will first check if the genome has a1-a1. If it has a1-a1, it will get that probability. If it does not, it will check if the genome has b1-b0 or b0-b1. The entered values are not combined in any way. It is up to the user to specify the probability for specific combinations.

Args:

config: schema-backed config smart dict manifest: manifest module containing the schema path default_probability_of_death: The probability used if the genome of the mosquito does not

match any of the defined allele combinations in Genetic_Probabilities.

species: Name of the species of vectors to give the specific probability to. allele_combo: The combination of alleles that a mosquito’s genome must have in order to

apply associated Probability. You do not need to specify alleles for every locus. The ones not defined are not considered in the match This should be a two-dimensional array where each internal array has two strings representing two alleles of the same locus. Each separate internal array represents locus and you can only have one entry per locus. You can use ‘*’ for an allele to say any allele. For example, [ [“a1”, “a1”], [“b1, “*”] ] says any mosquito with a1-a1 in the first locus and b1 in either chromosome of the second locus.

probability_of_death_for_allele_combo: The probability to use if the genome of the mosquito

has the matching Allele_Combinations. The default is zero.

Returns:

configured config

emodpy_malaria.vector_config.add_insecticide_resistance(config, manifest, insecticide_name: str = '', species: str = '', allele_combo: list = None, blocking: float = 1.0, killing: float = 1.0, repelling: float = 1.0, larval_killing: float = 1.0)[source]#

Use this function to add to the list of Resistances parameter for a specific insecticide Add each resistance separately. Example:

Insecticides = [
{
  "Name": "pyrethroid",
  "Resistances": [
    {
      "Allele_Combinations": [
      [
        "a1",
        "a1"
      ]
     ],
    "Blocking_Modifier": 1.0,
    "Killing_Modifier": 0.85,
    "Repelling_Modifier": 0.72,
    "Larval_Killing_Modifier": 0,
    "Species": "gambiae"
  }
 ]
},
{..}
Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path insecticide_name: The name of the insecticide to which attach the resistance. species: Name of the species of vectors. allele_combo: List of combination of alleles that vectors must have in order to be resistant. blocking: The value used to modify (multiply) the blocking effectivity of an intervention. killing: The value used to modify (multiply) the killing effectivity of an intervention. repelling: The value used to modify (multiply) the repelling effectivity of an intervention. larval_killing: The value used to modify (multiply) the larval killing effectivity of an intervention.

Returns:

configured config

emodpy_malaria.vector_config.add_species_drivers(config, manifest, species: str = None, driving_allele: str = None, driver_type: str = 'CLASSIC', to_copy: str = None, to_replace: str = None, likelihood_list: list = None, shredding_allele_required: str = None, allele_to_shred: str = None, allele_to_shred_to: str = None, allele_shredding_fraction: float = None, allele_to_shred_to_surviving_fraction: float = None)[source]#

Add a gene drive that propagates a particular set of alleles. Adds one Alleles_Driven item to the Alleles_Driven list, using ‘driving_allele’ as key if matching one already exists.

Example:

{
    "Driver_Type": "INTEGRAL_AUTONOMOUS",
    "Driving_Allele": "Ad",
    "Alleles_Driven": [
        {
            "Allele_To_Copy": "Ad",
            "Allele_To_Replace": "Aw",
            "Copy_To_Likelihood": [
                {
                    "Copy_To_Allele": "Aw",
                    "Likelihood": 0.1
                },
                {
                    "Copy_To_Allele": "Ad",
                    "Likelihood": 0.3
                },
                {
                    "Copy_To_Allele": "Am",
                    "Likelihood": 0.6
                }
            ]
        },
{
    "Driver_Type" : "X_SHRED",
    "Driving_Allele" : "Ad",
    "Driving_Allele_Params" : {
        "Allele_To_Copy"    : "Ad",
        "Allele_To_Replace" : "Aw",
        "Copy_To_Likelihood" : [
            {
                "Copy_To_Allele" : "Ad",
                "Likelihood" : 1.0
            },
            {
                "Copy_To_Allele" : "Aw",
                "Likelihood" : 0.0
            }
        ]
    },
    "Shredding_Alleles" : {
        "Allele_Required"    : "Yw",
        "Allele_To_Shred"    : "Xw",
        "Allele_To_Shred_To" : "Xm",
        "Allele_Shredding_Fraction": 0.97,
        "Allele_To_Shred_To_Surviving_Fraction" : 0.05
    }
    ]
}
Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path species: Name of the species for which we’re setting the drivers driving_allele: This is the allele that is known as the driver driver_type: This indicates the type of driver.

CLASSIC - The driver can only drive if the one gamete has the driving allele and the other has a specific allele to be replaced INTEGRAL_AUTONOMOUS - At least one of the gametes must have the driver. Alleles can still be driven if the driving allele is in both gametes or even if the driving allele cannot replace the allele in the other gamete X_SHRED, Y_SHRED - cannot be used in the same species during one simulation/realization. The driving_allele must exist at least once in the genome for shredding to occur. If there is only one, it can exist in either half of the genome. DAISY_CHAIN - can be used for drives that do not drive themselves but can be driven by another allele.

to_copy: The main allele to be copied Allele_To_Copy to_replace: The allele that must exist and will be replaced by the copy Allele_To_Replace likelihood_list: A list of tuples in format: [(Copy_To_Allele, Likelihood),(),()] to assign to

Copy_To_Likelyhood list

shredding_allele_required: The genome must have this gender allele in order for shredding to occur.

If the driver is X_SHRED, then the allele must be designated as a Y chromosome. If the driver is Y_SHRED, then the allele must NOT be designated as a Y chromosome

allele_to_shred: The genome must have this gender allele in order for shredding to occur. If the driver is

X_SHRED, then the allele must NOT be designated as a Y chromosome. If the driver is Y_SHRED, then the allele must be designated as a Y chromosome

allele_to_shred_to: This is a gender allele that the ‘shredding’ will change the allele_to_shred into. It can

be a temporary allele that never exists in the output or could be something that appears due to resistance/failures

allele_shredding_fraction: This is the fraction of the alleles_to_Shred that will be converted to

allele_to_shred_to. Values 0 to 1. If this value is less than 1, then some of the allele_to_shred will remain and be part of the gametes.

allele_to_shred_to_surviving_fraction: A trait modifier will automatically generated for

[ Allele_To_Shred_To, * ], the trait ADJUST_FERTILE_EGGS, and this value as its modifier. Values 0 to 1. A value of 0 implies perfect shredding such that no allele_to_Shred_To survive in the eggs. A value of 1 means all of the ‘shredded’ alleles survive.

Returns:

configured config

emodpy_malaria.vector_config.add_maternal_deposition(config, manifest, species: str, cas9_grna_from: str, allele_to_cut: str, likelihood_list: list)[source]#

Adds a maternal deposition element for the specified species. After meiosis and fertilization, maternal deposition of Cas9 and gRNA can form additional resistance alleles in the zygote or early embryo from wildtype alleles. These elements define the likelihoods of forming additional resistance alleles.

Args:

config: schema-backed config smart dict manifest: manifest file containing the schema path species: Name of the species for which we’re adding the maternal deposition element. cas9_grna_from: This is an allele for presence of which in the mother we will be checking to see if additional

resistance alleles will be formed. This is the allele must be one of the ‘driving_alleles’ from vector_config.add_species_drivers() function.

allele_to_cut: The allele from which resistance alleles might be formed due to maternal deposition. This must

be one of the ‘to_replace’ alleles defined in the vector_config.add_species_drivers() function.

likelihood_list: A list of tuples in format: [(<cut_to_allele>, <likelihood>),(),()] which will be converted

to an array of allele-to-likelihood dictionaries to be applied to the ‘allele_to_cut’ for each ‘cas9_grna_from’ present in the mother. The sum of likelihoods should be equal to 1.

Returns:

Config object with maternal deposition parameters added for the specified species.

emodpy_malaria.vector_config.set_max_larval_capacity(config, species_name, habitat_type, max_larval_capacity)[source]#

Set the Max_Larval_Capacity for a given species and habitat. Effectively doing something like: simulation.task.config.parameters.Vector_Species_Params[i][“Habitats”][j][“Max_Larval_Capacity”] = max_larval_capacity where i is index of species_name and j is index of habitat_type.

Args:

config: schema-backed config smart dict species_name: string. Species_Name to target. habitat_type: enum. Habitat_Type to target. max_larval_capacity: integer. New value of Max_Larval_Capacity.

Returns:

Nothing.

emodpy_malaria.vector_config.add_microsporidia(config, manifest, species_name: str = None, strain_name: str = 'Strain_A', female_to_male_probability: float = 0, female_to_egg_probability: float = 0, male_to_female_probability: float = 0, male_to_egg_probability: float = 0, duration_to_disease_acquisition_modification: dict = None, duration_to_disease_transmission_modification: dict = None, larval_growth_modifier: float = 1, female_mortality_modifier: float = 1, male_mortality_modifier: float = 1)[source]#

Adds microsporidia parameters to the named species’ parameters.

Args:

config: schema-backed config dictionary, written to config.json manifest: file that contains path to the schema file species_name: Species to target, Name parameter strain_name: Strain_Name The name/identifier of the collection of transmission parameters.

Cannot be empty string

female_to_male_probability: Microsporidia_Female_to_Male_Transmission_Probability The probability

an infected female will infect an uninfected male.

female_to_egg_probability: Microsporidia_Female_To_Egg_Transmission_Probability The probability

an infected female will infect her eggs when laying them.

male_to_female_probability: Microsporidia_Male_To_Female_Transmission_Probability The probability

an infected male will infect an uninfected female

male_to_egg_probability: Microsporidia_Male_To_Egg_Transmission_Probability The probability a female that

mated with an infected male will infect her eggs when laying them, independent of her being infected and transmitting to her offspring.

duration_to_disease_acquisition_modification: Microsporidia_Duration_To_Disease_Acquisition_Modification,

A dictionary for “Times” and “Values” as an age-based modification that the female will acquire malaria. Times is an array of days in ascending order that represent the number of days since the vector became infected. Values is an array of probabilities with values from 0 to 1 where each probability is the probability that the vector will acquire malaria due to Microsporidia.

Example:

{
    "Times": [    0,   3,   6,   9 ],
    "Values": [ 1.0, 1.0, 0.5, 0.0 ]
}
duration_to_disease_transmission_modification: Microsporidia_Duration_To_Disease_Transmission_Modification,

A dictionary for “Times” and “Values” as an age-based modification that the female will transmit malaria. Times is an array of days in ascending order that represent the number of days since the vector became infected. Values is an array of probabilities with values from 0 to 1 where each probability is the probability that the vector will acquire malaria due to Microsporidia.

Example:

{
    "Times": [    0,   3,   6,   9 ],
    "Values": [ 1.0, 1.0, 0.75, 0.5]
}
larval_growth_modifier: Microsporidia_Larval_Growth_Modifier A multiplier modifier to the daily, temperature

dependent, larval growth progress.

female_mortality_modifier: Microsporidia_Female_Mortality_Modifier A multiplier modifier on the death

rate for female vectors due to general life expectancy, age, and dry heat

male_mortality_modifier: Microsporidia_Male_Mortality_Modifier A multiplier modifier on the death rate for

male vectors due to general life expectancy, age, and dry heat

Returns:

Nothing

class emodpy_malaria.vector_config.ModifierEquationType(*values)[source]#

Bases: Enum

EXPONENTIAL = 'EXPONENTIAL'#
LINEAR = 'LINEAR'#
emodpy_malaria.vector_config.add_vector_migration(task, species: str = None, vector_migration_filename_path: str = None, x_vector_migration: float = 1, vector_migration_modifier_equation: ModifierEquationType = ModifierEquationType.LINEAR, vector_migration_habitat_modifier: float = 0, vector_migration_food_modifier: float = 0, vector_migration_stay_put_modifier: float = 0)[source]#

Adds vector migration parameters to the named species’ parameters and adds the migration file to the common_assets in task

Args:

task: contains config to edit and assets to add migration file to species: Species to target, Name parameter vector_migration_filename_path: Path with the filename of the migration file to use for

Vector_Migration_Filename

x_vector_migration: Scale factor for the rate of vector migration to other nodes. vector_migration_modifier_equation: Functional form of vector migration modifiers.

This applies only to female migrating vectors. Default is ModifierEquationType.LINEAR.

vector_migration_habitat_modifier: Preference of a vector to migrate toward a node with more habitat. This

applies only to female migrating vectors.

vector_migration_food_modifier: Preference of a vector to migrate toward a node currently occupied by humans,

independent of the number of humans in the node. This only applies to female migrating vectors.

vector_migration_stay_put_modifier: Preference of a vector to remain in its current node rather than migrate

to another node. This applies only to female migrating vectors.

Returns: