Esempio n. 1
0
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import FFPopSim as h

# specify parameters
L = 4  # number of loci
N = 1e10  # population size
mu = 1e-5  # mutation rate
r = 1e-4  # recombination rate
f = [0.3, 0.2, 0.1, 0.05]  # fitness (additive effects)

# Script
if __name__ == '__main__':

    pop = h.haploid_lowd(L)  # produce an instance of haploid_lowd with L loci
    pop.set_genotypes([0], [N])  # start with a wildtype population

    pop.set_recombination_rates(r)  # set recombination rate
    pop.set_mutation_rates(mu)  # set mutation rate
    pop.set_fitness_additive(f)  # set fitness landscape

    # evolve while tracking genotype frequencies
    times = []
    genotype_frequencies = []
    while (pop.get_genotype_frequency(0b1111) < 0.99) and (pop.generation <
                                                           1e7):
        pop.evolve()

        # get genotype frequencies and time
        genotype_frequencies.append(pop.get_genotype_frequencies())
sys.path.insert(0, '../pkg/python')

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import FFPopSim as h


# specify parameters
N = 500000                          # Population size
L = 4                               # number of loci
mu = 0.0                            # no new mutations
r = [0.01, 0.03, 0.05]              # recombination rates

### set up
pop = h.haploid_lowd(L)             # produce an instance of haploid_lowd with L loci
pop.carrying_capacity = N           # set the steady-state population size
pop.set_recombination_rates(r, h.CROSSOVERS)      # assign the recombination rate
pop.set_mutation_rates(mu)          # assign the mutation rate

# initialize the population with
#    - N/2 individuals with genotype 0, that is ----
#    - N/2 with the opposite genotype, that is ++++
pop.set_genotypes([0, 2**L - 1],
                  [N/2, N/2])

# evolve for some time
pop.evolve(50)

# copy the population and evolve the two in parallel
pop2 = pop.copy()
Esempio n. 3
0
'''
author:     Fabio Zanini
date:       14/05/12
content:    Test script for the python bindings to the low-dimensional
            simulation
'''

# Import module
import sys
sys.path.insert(0, '../pkg/python')
import numpy as np
import matplotlib.pyplot as plt
import FFPopSim as h

# Construct class
pop = h.haploid_lowd(4)

# Test initialization
#pop.set_allele_frequencies([0,0.3,0.6,0.9], 1000)
pop.set_genotypes([1,2],[400,800])

# Test setting the recombination/mutation rates
pop.set_recombination_rates([0.01, 0.03, 0.02], h.SINGLE_CROSSOVER)
pop.set_mutation_rates([0.003,0.002,0.004,0.005],
                       [0.006,0.004,0.008,0.010])

# Test getting the mutation rate
print pop.get_mutation_rates(direction=0)
print pop.get_mutation_rates(direction=1)

# Test setting / getting fitness
Esempio n. 4
0
'''
author:     Fabio Zanini
date:       14/05/12
content:    Test script for the python bindings to the low-dimensional
            simulation
'''

# Import module
import sys
sys.path.insert(0, '../pkg/python')
import numpy as np
import matplotlib.pyplot as plt
import FFPopSim as h

# Construct class
pop = h.haploid_lowd(4)

# Test initialization
#pop.set_allele_frequencies([0,0.3,0.6,0.9], 1000)
pop.set_genotypes([1, 2], [400, 800])

# Test setting the recombination/mutation rates
pop.set_recombination_rates([0.01, 0.03, 0.02], h.SINGLE_CROSSOVER)
pop.set_mutation_rates([0.003, 0.002, 0.004, 0.005],
                       [0.006, 0.004, 0.008, 0.010])

# Test getting the mutation rate
print pop.get_mutation_rates(direction=0)
print pop.get_mutation_rates(direction=1)

# Test setting / getting fitness