Project: s41467-024-44907-x | Function: __init__ (python)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Initialize individual mosquito agent with genotype, sex, and calculate survival probabilities for different life stages based on gene drive and anti-drive alleles

**KEY TERMS:** {
  "genotype1": "dsx locus genotype",
  "genotype2": "anti-drive locus genotype",
  "nucl_from_father": "nuclease inherited from father",
  "nucl_from_mother": "nuclease inherited from mother",
  "hatching": "hatching probability",
  "larval": "larval survival probability",
  "pupal": "pupal survival probability"
}

**CONTEXT CODE:**     '''Individual mosquito model

    Two loci are modelled in this simulation:
    - locus 1: dsx
    - locus 2: presence/absence of antidote

    Individuals are in the egg stage upon object creation,
    and the time to reach each stage is predetermined by drawing
    random variables from predefined distributions

    Mating, egg deposition probabilities, number of eggs produced
    and similar quantities are also drawn from predefined distributions

    Example 1: wild-type male
    >>> Individual('m', ['W', 'W'], ['W', 'W'])
    
    Example 2: het. drive male (nuclease received from father)
    >>> Individual('m', ['D', 'W'], ['W', 'W'], nucl_from_father=True)
    
    Example 3: hom. drive female (nuclease received from both parents)
    >>> Individual('f', ['D', 'D'], ['W', 'W'],
                   nucl_from_father=True,
                   nucl_from_mother=True)
    
    Example 4: het. drive/resistant female, het. antidrive (nuclease received from mother)
    >>> Individual('f', ['D', 'R'], ['A', 'W'],
                   nucl_from_mother=True)

    Useful methods:

    Increase the age of the individual by 1 day. Change of stage is automatically
    set by the method (including death)
    >>> i.change_age(1)

    Is this individual still alive?
    >>> i.is_alive()
    False

    Is this individual going to develop into an adult?
    >>> i.will_develop()
    True

    Form gamete for locus 1 (dsx)
    >>> i.form_gamete1()
    D

    Form gamete for locus 2 (antidote)
    >>> i.form_gamete2()
    W
    '''
    def __init__(self, sex, genotype1, genotype2,
                 nucl_from_father=False, nucl_from_mother=False,
                 hatching_mod=1, parameters=None):
        '''Create a new individual for the simulation
        Starts from the egg stage

        Args:
            sex (str)
                Sex: one of ['f', 'm']
            genotype1 (iterable)
                All unique alleles at the dsx locus
            genotype2 (iterable)
                All unique alleles at the antidote locus
            nucl_from_father (bool)
                Wether the father passes the nuclease to the egg
            nucl_from_mother (bool)
                Wether the mother passes the nuclease to the egg
            hatching_mod (float)
                Modifier for the hatching probability
            parameters (dict)
                parameters dictionary
        '''
        # MASKED: Initialize individual mosquito agent with genotype, sex, and calculate survival probabilities for different life stages based on gene drive and anti-drive alleles implementation
        raise NotImplementedError("This function is masked for testing purposes.")

    def get_genotype(self):
        '''Get the full genotype at both loci

        Returns
           genotype (str)
               The first two chars are the dsx locus, the last the antidote

        Examples
        >>> i.get_genotype() # wild-type
        WWWW
        >>> i.get_genotype() # hom. drive, het. antidote
        DDAW
        >>> i.get_genotype() # het. drive, hom. antidote
        DWAA
        '''
        gt = ''
        for genotype in (self.genotype1, self.genotype2):
            if len(genotype) == 1:
                gt += list(genotype)[0]
                gt += list(genotype)[0]
            else:
                gt += ''.join(sorted(genotype))
        return gt

    def _is_intersex(self):
        if self.p['DRIVE'] in self.genotype1 and (self.nucl_from_father and self.nucl_from_mother):
            intersex = 0
        elif self.p['DRIVE'] in self.genotype1 and self.nucl_from_father and self.sex == 'f':
            intersex = get_rvs('norm', (self.p['INTERSEX_NUCL_FROM_FATHER']['loc'],
                                        self.p['INTERSEX_NUCL_FROM_FATHER']['scale']))
        elif self.p['DRIVE'] in self.genotype1 and self.nucl_from_mother and self.sex == 'f':
            intersex = get_rvs('norm', (self.p['INTERSEX_NUCL_FROM_MOTHER']['loc'],
                                        self.p['INTERSEX_NUCL_FROM_MOTHER']['scale']))
        else:
            intersex = 0
        if random.random() <= intersex:
            return True
        return False

    def _mating_probability(self):
        if self.sex == 'm':
            mating_probability = self.p['MATING_PROBABILITY_MALE']
        else:
            mating_probability = self.p['MATING_PROBABILITY']
        return mating_probability * self.p['MATING_MOD'][self.sex
                ].get(self.get_genotype(), 1)

    def get_mating(self):
        '''Generate the probability that this individual will mate

        Returns
            mating (bool)
               Wether the individual will mate

        The decision is based on sex, genotype and intersex phenotype
        '''
        # MASKED: Calculate mating probability based on genotype, sex, and fitness costs associated with gene drive and anti-drive alleles implementation
        raise NotImplementedError("This function is masked for testing purposes.")

    def deposes_eggs(self, modifier):
        '''Generate the probability that this individual will depose eggs

        Args:
            modifier (float)
               Modifier for the eggs deposition modifier

        Returns
            deposes (bool)
               Wether the individual will depose eggs

        The decision is based on sex and modifier
        '''
        if self.sex == 'm':
            return None
        elif random.random() <= self.p['EGG_DEPOSITION_PROBABILITY'] * modifier:


Complete the function implementation replacing "raise NotImplementedError".