Пример #1
0
    def apply(cls, node):
        # when combine selection on multiple loci using MlSelector in
        # simuPOP, the class only works if every (Map/Ma)Selectors
        # have identical target population (sex and demes).
        #
        # This means that mulitple single locus selectors may be
        # provided even if a mode of selection on the particular locus
        # is neither sex- nor deme-specific.
        #
        # Do test what's the most general case upfront.
        mode = choose_most_specific_scenario(node, 'non-neutral loci', 'selection coefficient')

        selcoeff = node.getNodes('selection coefficient')
        # make sure there is a single specification of selection
        # coefficient per locus.
        if len(selcoeff) != 1:
            raise Error
        else:
            selcoeff = selcoeff[0]

        true_mode = get_scenario(node, 'selection coefficient')
        position = get_position(node)
        # selection must be specified locus-by-locus.
        if len(position) != 1:
            raise Error
        else:
            position = position[0]
        chromosome = get_chromosome(node)

        n_demes = len(node.root().get('population size'))
        return build_loci(selcoeff, chromosome, position, mode, true_mode, n_demes)
Пример #2
0
    def apply(cls, node):

        scenario = choose_most_specific_scenario(node, 'recombination', 'rate')

        recs = node.getNodes('recombination')
        loci = []
        n_demes = len(node.root().get('population size'))
        for r in recs:
            chromosome = get_chromosome(r)
            pos = get_list_of_values(r.descendent('at'))
            n_pos = len(pos)
            true_scenario = get_scenario(r, 'rate')

            rate = r.getNodes('rate')
            if len(rate) != 1:
                raise Error
            else:
                rate = rate[0]
            loci.extend(build_loci(rate, chromosome, pos, scenario, true_scenario, n_demes))

        new_loci = []
        for l in loci:
            new_loci.extend([Locus(v, l.chrom, p, l.subPops)
                             for v, p in zip(l.val, l.loci)])


        return new_loci