Skip to content

Mutation

Mutation

Bases: Event

This events aims to reproduce a mutation effect. It was originally implemented to model the new Covid19 variant detected in the UK around November 2020. The idea is that a percentage of the active infections (which can vary region to region) is converted to the new variant, with different epidemiological charactersitics. Note: currently we only change the infection transmission charactersitics, but leaving the symptoms trajectory intact.

Source code in june/event/mutation.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Mutation(Event):
    """This events aims to reproduce a mutation effect.
    It was originally implemented to model the new Covid19 variant
    detected in the UK around November 2020. The idea is that a percentage
    of the active infections (which can vary region to region) is converted
    to the new variant, with different epidemiological charactersitics.
    Note: currently we only change the infection transmission charactersitics,
    but leaving the symptoms trajectory intact.

    """

    def __init__(
        self,
        start_time: Union[str, datetime.datetime],
        end_time: Union[str, datetime.datetime],
        regional_probabilities: Dict[str, float],
        mutation_id=B117.infection_id(),
    ):
        super().__init__(start_time=start_time, end_time=end_time)
        self.regional_probabilities = regional_probabilities
        self.mutation_id = mutation_id

    def initialise(self, world=None):
        """

        Args:
            world: (Default value = None)

        """
        pass

    def apply(self, world, simulator, activities=None, day_type=None):
        """

        Args:
            world: 
            simulator: 
            activities: (Default value = None)
            day_type: (Default value = None)

        """
        selector = simulator.epidemiology.infection_selectors.infection_id_to_selector[
            self.mutation_id
        ]
        for person in world.people:
            if person.infected:
                probability = self.regional_probabilities.get(person.region.name, 0)
                if random() < probability:
                    new_infection = selector._make_infection(
                        person, time=person.infection.start_time
                    )
                    new_infection.time_of_testing = person.infection.time_of_testing
                    new_infection.start_time = person.infection.start_time
                    new_infection.symptoms = person.infection.symptoms
                    person.infection = new_infection

apply(world, simulator, activities=None, day_type=None)

Parameters:

Name Type Description Default
world
required
simulator
required
activities

(Default value = None)

None
day_type

(Default value = None)

None
Source code in june/event/mutation.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def apply(self, world, simulator, activities=None, day_type=None):
    """

    Args:
        world: 
        simulator: 
        activities: (Default value = None)
        day_type: (Default value = None)

    """
    selector = simulator.epidemiology.infection_selectors.infection_id_to_selector[
        self.mutation_id
    ]
    for person in world.people:
        if person.infected:
            probability = self.regional_probabilities.get(person.region.name, 0)
            if random() < probability:
                new_infection = selector._make_infection(
                    person, time=person.infection.start_time
                )
                new_infection.time_of_testing = person.infection.time_of_testing
                new_infection.start_time = person.infection.start_time
                new_infection.symptoms = person.infection.symptoms
                person.infection = new_infection

initialise(world=None)

Parameters:

Name Type Description Default
world

(Default value = None)

None
Source code in june/event/mutation.py
31
32
33
34
35
36
37
38
def initialise(self, world=None):
    """

    Args:
        world: (Default value = None)

    """
    pass