def setUpClass(self): # TODO add neutral variants self.N = 1000 self.demography = np.array([self.N] * self.N, dtype=np.uint32) self.rho = 1. self.theta = 100. self.nreps = 500 self.mu = self.theta / (4 * self.N) self.r = self.rho / (4 * self.N) self.GSS = fwdpy11.GSS(VS=1, opt=0) a = fwdpy11.Additive(2.0, self.GSS) self.p = { 'nregions': [], 'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)], 'recregions': [fwdpy11.Region(0, 1, 1)], 'rates': (0.0, 0.025, self.r), 'gvalue': a, 'prune_selected': False, 'demography': self.demography } self.params = fwdpy11.ModelParams(**self.p) self.rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) self.pop = fwdpy11.DiploidPopulation(self.N, 1.0) self.all_samples = [i for i in range(2 * self.N)] fwdpy11.evolvets(self.rng, self.pop, self.params, 100) self.dm = fwdpy11.data_matrix_from_tables(self.pop.tables, self.all_samples, True, True) self.neutral = np.array(self.dm.neutral) self.npos = np.array(self.dm.neutral.positions) self.selected = np.array(self.dm.selected) self.spos = np.array(self.dm.selected.positions)
def runsim(args): popsizes = np.array([args.popsize] * 20 * args.popsize, dtype=np.int32) locus_boundaries = [(i, i + 11) for i in range(0, 10 * 11, 11)] sregions = [fwdpy11.GaussianS(i[0] + 5, i[0] + 6, 1, args.sigma) for i in locus_boundaries] recregions = [fwdpy11.PoissonInterval( *i, args.rho / (4 * args.popsize)) for i in locus_boundaries] recregions.extend([fwdpy11.BinomialPoint(i[1], 0.5) for i in locus_boundaries[:-1]]) pop = fwdpy11.DiploidPopulation(args.popsize, locus_boundaries[-1][1]) optima = fwdpy11.GSSmo( [(0, 0, args.VS), (10 * args.popsize, args.opt, args.VS)]) p = {'nregions': [], # No neutral mutations -- add them later! 'gvalue': fwdpy11.Additive(2.0, optima), 'sregions': sregions, 'recregions': recregions, 'rates': (0.0, args.mu, None), # Keep mutations at frequency 1 in the pop if they affect fitness. 'prune_selected': False, 'demography': np.array(popsizes, dtype=np.uint32) } params = fwdpy11.ModelParams(**p) rng = fwdpy11.GSLrng(args.seed) s = Recorder(args.popsize) fwdpy11.evolvets(rng, pop, params, 100, s, suppress_table_indexing=True, track_mutation_counts=True) return pop
def runsim(args): rng = fwdpy11.GSLrng(args.seed) pdict = {'gvalue': fwdpy11.Multiplicative(FITNESS_SCALING), 'rates': (0., args.mu, None), 'nregions': [], 'sregions': [fwdpy11.GammaS(0., GENOME_LENGTH, 1.0-args.proportion, args.mean, args.shape, FITNESS_SCALING/2.0, scaling=2*args.popsize, label=1), fwdpy11.ConstantS(0, GENOME_LENGTH, args.proportion, TWONS, FITNESS_SCALING/2.0, label=2, scaling=2*args.popsize)], 'recregions': [fwdpy11.PoissonInterval(0, GENOME_LENGTH, args.recrate)], 'demography': np.array([args.popsize]*SIMLEN*args.popsize, dtype=np.uint32), # This could easily be True for these sims: 'prune_selected': False } params = fwdpy11.ModelParams(**pdict) pop = fwdpy11.DiploidPopulation(args.popsize, GENOME_LENGTH) sampler = fwdpy11.RandomAncientSamples( args.seed, args.popsize, [i for i in range(10*pop.N, SIMLEN*pop.N)]) # With a lot of ancient samples: # 1. RAM use already skyrockets # 2. Simplification slows down # So, we should do it a little less often: fwdpy11.evolvets(rng, pop, params, 1000, sampler, suppress_table_indexing=True) return pop
def runsim(args): popsizes = np.array([args.popsize] * 20 * args.popsize, dtype=np.int32) pop = fwdpy11.DiploidPopulation(args.popsize, 1.0) sregions = [fwdpy11.GaussianS(0, 1, 1, args.sigma)] recregions = [fwdpy11.PoissonInterval(0, 1, args.recrate)] optima = fwdpy11.GSSmo([(0, 0, args.VS), (10 * args.popsize, args.opt, args.VS)]) p = { 'nregions': [], # No neutral mutations -- add them later! 'gvalue': fwdpy11.Additive(2.0, optima), 'sregions': sregions, 'recregions': recregions, 'rates': (0.0, args.mu, None), # Keep mutations at frequency 1 in the pop if they affect fitness. 'prune_selected': False, 'demography': np.array(popsizes, dtype=np.uint32) } params = fwdpy11.ModelParams(**p) rng = fwdpy11.GSLrng(args.seed) s = Recorder(args.popsize) fwdpy11.evolvets(rng, pop, params, 100, s, suppress_table_indexing=True, track_mutation_counts=True) return pop
def test_mutation_counts_with_indexing_suppressed_no_neutral_muts_in_genomes( self): """ A sim w/ and w/o putting neutral variants in genomes should give the same mutation counts. """ pop2 = copy.deepcopy(self.pop) rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) # Use same seed!!! self.params.prune_selected = False params = copy.deepcopy(self.params) fwdpy11.evolvets(rng, pop2, params, 100, suppress_table_indexing=True) fwdpy11.evolvets(self.rng, self.pop, self.params, 100, suppress_table_indexing=True) ti = fwdpy11.TreeIterator(self.pop.tables, [i for i in range(2 * self.pop.N)]) mc = _count_mutations_from_diploids(self.pop) for t in ti: for m in t.mutations(): # Have to skip neutral mutations b/c they won't # end up in mc b/c it is obtained from genomes if pop2.mutations[m.key].neutral is False: self.assertEqual(mc[m.key], self.pop.mcounts[m.key]) self.assertEqual(t.leaf_counts(m.node), pop2.mcounts[m.key])
def test_neutral_mut_locations(self): fwdpy11.evolvets(self.rng, self.pop, self.params, 100) pos = [ self.pop.tables.sites[i.site].position for i in self.pop.tables.mutations if i.neutral ] self.assertTrue(all([i < 0.25 or i >= 0.5 for i in pos]))
def test_mutation_counts_with_indexing(self): """ Tests atypical use case where neutral mutations are placed into genomes """ fwdpy11.evolvets(self.rng, self.pop, self.params, 100) mc = _count_mutations_from_diploids(self.pop) self.assertTrue(_compare_counts_for_nonneutral_variants(self.pop, mc))
def setUp(self): self.N = 1000 self.demography = np.array([self.N] * 100, dtype=np.uint32) self.rho = 1. self.theta = 100. self.nreps = 500 self.mu = self.theta / (4 * self.N) self.r = self.rho / (4 * self.N) self.GSS = fwdpy11.GSS(VS=1, opt=0) a = fwdpy11.Additive(2.0, self.GSS) self.p = { 'nregions': [], 'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)], 'recregions': [fwdpy11.Region(0, 1, 1)], 'rates': (0.0, 0.025, self.r), 'gvalue': a, 'prune_selected': False, 'demography': self.demography } self.params = fwdpy11.ModelParams(**self.p) self.rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) self.pop = fwdpy11.DiploidPopulation(self.N, 1.0) self.recorder = fwdpy11.RandomAncientSamples( seed=42, samplesize=10, timepoints=[i for i in range(1, 101)]) fwdpy11.evolvets(self.rng, self.pop, self.params, 100, self.recorder)
def setUpClass(self): self.params, self.rng, self.pop = set_up_quant_trait_model() self.stimes = [i for i in range(1, 101)] self.recorder = Recorder(42, 10, self.stimes) fwdpy11.evolvets(self.rng, self.pop, self.params, 100, self.recorder) assert max(self.pop.mcounts) == 2 * \ self.pop.N, "Nothing fixed, so test case is not helpful"
def testPopGenSim(self): N = 1000 demography = np.array([N] * 10 * N, dtype=np.uint32) rho = 1. r = rho / (4 * N) a = fwdpy11.Multiplicative(2.0) p = { 'nregions': [], 'sregions': [fwdpy11.ExpS(0, 1, 1, 0.01)], 'recregions': [fwdpy11.Region(0, 1, 1)], 'rates': (0.0, 0.00005, r), 'gvalue': a, 'prune_selected': True, 'demography': demography } params = fwdpy11.ModelParams(**p) rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) pop = fwdpy11.DiploidPopulation(N, 1.0) fwdpy11.evolvets(rng, pop, params, 100, track_mutation_counts=True) mc = fwdpy11.count_mutations(pop.tables, pop.mutations, [i for i in range(2 * pop.N)]) assert len(pop.fixations) > 0, "Test is meaningless without fixations" fixations = np.where(mc == 2 * pop.N)[0] self.assertEqual(len(fixations), 0) # Brute-force calculation of fixations brute_force = np.zeros(len(pop.mutations), dtype=np.int32) for g in pop.haploid_genomes: if g.n > 0: for k in g.smutations: brute_force[k] += g.n self.assertTrue(np.array_equal(brute_force, mc)) self.assertTrue(np.array_equal(brute_force, pop.mcounts))
def setUp(self): import fwdpy11 import numpy as np self.N = 1000 self.demography = np.array([self.N] * self.N, dtype=np.uint32) self.rho = 1. self.theta = 100. self.nreps = 500 self.mu = self.theta / (4 * self.N) self.r = self.rho / (4 * self.N) self.GSS = fwdpy11.GSS(VS=1, opt=0) a = fwdpy11.Additive(2.0, self.GSS) self.p = { 'nregions': [], 'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)], 'recregions': [fwdpy11.Region(0, 1, 1)], 'rates': (0.0, 0.025, self.r), 'gvalue': a, 'prune_selected': False, 'demography': self.demography } self.params = fwdpy11.ModelParams(**self.p) self.rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) self.pop = fwdpy11.DiploidPopulation(self.N, 1.0) fwdpy11.evolvets(self.rng, self.pop, self.params, 100)
def setUpClass(self): class CountSamplesPerTimePoint(object): def __init__(self): self.sample_timepoints = [] self.sample_sizes = [] self.timepoint_seen = {} def __call__(self, pop): assert len(pop.tables.preserved_nodes)//2 == \ len(pop.ancient_sample_metadata) # Get the most recent ancient samples # and record their number. We do this # by a "brute-force" approach for t, n, m in pop.sample_timepoints(False): if t not in self.timepoint_seen: self.timepoint_seen[t] = 1 else: self.timepoint_seen[t] += 1 if t not in self.sample_timepoints: self.sample_timepoints.append(t) self.sample_sizes.append(len(n) // 2) # simplify to each time point tables, idmap = fwdpy11.simplify_tables(pop.tables, n) for ni in n: assert idmap[ni] != fwdpy11.NULL_NODE assert tables.nodes[idmap[ni]].time == t self.N = 1000 self.demography = np.array([self.N] * 101, dtype=np.uint32) self.rho = 1. self.r = self.rho / (4 * self.N) self.GSS = fwdpy11.GSS(VS=1, opt=0) a = fwdpy11.Additive(2.0, self.GSS) self.p = { 'nregions': [], 'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)], 'recregions': [fwdpy11.Region(0, 1, 1)], 'rates': (0.0, 0.025, self.r), 'gvalue': a, 'prune_selected': False, 'demography': self.demography } self.params = fwdpy11.ModelParams(**self.p) self.rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) self.pop = fwdpy11.DiploidPopulation(self.N, 1.0) self.all_samples = [i for i in range(2 * self.N)] self.ancient_sample_recorder = \ fwdpy11.RandomAncientSamples(seed=42, samplesize=10, timepoints=[i for i in range(1, 101)]) self.resetter = CountSamplesPerTimePoint() fwdpy11.evolvets(self.rng, self.pop, self.params, 5, recorder=self.ancient_sample_recorder, post_simplification_recorder=self.resetter)
def test_mutation_counts_with_indexing_suppressed(self): fwdpy11.evolvets(self.rng, self.pop, self.params, 100, suppress_table_indexing=True) mc = _count_mutations_from_diploids(self.pop) self.assertTrue(_compare_counts_for_nonneutral_variants(self.pop, mc)) self.assertEqual(len(np.where(mc == 2 * self.pop.N)[0]), 0)
def setUpClass(self): self.params, self.rng, self.pop = set_up_standard_pop_gen_model() fwdpy11.evolvets(self.rng, self.pop, self.params, 100, track_mutation_counts=True) assert len(self.pop.fixations ) > 0, "Nothing fixed, so test case is not helpful"
def runsim(argtuple): seed = argtuple rng = fwdpy11.GSLrng(seed) pdict = { 'gvalue': fwdpy11.Multiplicative(2.), 'rates': (0., U / 2., R), # The U/2. is from their eqn. 2. 'nregions': [], 'sregions': [ fwdpy11.ConstantS(0, 1. / 3., 1, -0.02, 1.), fwdpy11.ConstantS(2. / 3., 1., 1, -0.02, 1.) ], 'recregions': [fwdpy11.Region(0, 1. / 3., 1), fwdpy11.Region(2. / 3., 1., 1)], 'demography': np.array([N] * 20 * N, dtype=np.uint32) } params = fwdpy11.ModelParams(**pdict) pop = fwdpy11.DiploidPopulation(N, GENOME_LENGTH) fwdpy11.evolvets(rng, pop, params, 100, suppress_table_indexing=True) rdips = np.random.choice(N, NSAM, replace=False) md = np.array(pop.diploid_metadata, copy=False) rdip_nodes = md['nodes'][rdips].flatten() nodes = np.array(pop.tables.nodes, copy=False) # Only visit trees spanning the # mutation-free segment of the genome tv = fwdpy11.TreeIterator(pop.tables, rdip_nodes, begin=1. / 3., end=2. / 3.) plist = np.zeros(len(nodes), dtype=np.int8) sum_pairwise_tmrca = 0 for t in tv: for i in range(len(rdip_nodes) - 1): u = rdip_nodes[i] while u != fwdpy11.NULL_NODE: plist[u] = 1 u = t.parent(u) for j in range(i + 1, len(rdip_nodes)): u = rdip_nodes[j] while u != fwdpy11.NULL_NODE: if plist[u] == 1: sum_pairwise_tmrca += 2 * \ (pop.generation-nodes['time'][u]) u = fwdpy11.NULL_NODE else: u = t.parent(u) plist.fill(0) return 2 * sum_pairwise_tmrca / (len(rdip_nodes) * (len(rdip_nodes) - 1))
def test_stop(self): rng = fwdpy11.GSLrng(42) def generation(pop, simplified): if pop.generation >= 50: return True return False fwdpy11.evolvets( rng, self.pop, self.params, 100, stopping_criterion=generation) self.assertEqual(self.pop.generation, 50)
def setUpClass(self): self.params, self.rng, self.pop = set_up_quant_trait_model() self.params.demography = np.array([self.pop.N] * 200, dtype=np.uint32) self.pop2 = copy.deepcopy(self.pop) self.rng2 = fwdpy11.GSLrng(101 * 45 * 110 * 210) params2 = copy.deepcopy(self.params) fwdpy11.evolvets(self.rng, self.pop, self.params, 100) fwdpy11.evolvets(self.rng2, self.pop2, params2, 100, remove_extinct_variants=False)
def setUpClass(self): self.params, self.rng, self.pop = set_up_standard_pop_gen_model() self.stimes = [i for i in range(1, 101)] self.recorder = Recorder(42, 10, self.stimes) fwdpy11.evolvets(self.rng, self.pop, self.params, 100, self.recorder, track_mutation_counts=True) assert len(self.pop.fixations ) > 0, "Nothing fixed, so test case is not helpful"
def test_github_issue_310(self): fwdpy11.evolvets(self.rng, self.pop, self.params, 100) nonmutants = 0 md = np.array(self.pop.diploid_metadata, copy=False) for i, j in enumerate(self.pop.diploids): n0 = len(self.pop.haploid_genomes[j.first].smutations) n1 = len(self.pop.haploid_genomes[j.second].smutations) if md['w'][i] != 1.: self.assertTrue(n0 + n1 > 0) elif n1 + n0 == 0: nonmutants += 1 if nonmutants == 0: self.fail("Test invalid: zero individuals were mutation-free")
def test_with_table_indexing(self): fwdpy11.evolvets(self.rng, self.pop, self.params, 1, self.ft, track_mutation_counts=True) assert len( self.pop.fixations) > 0, \ "Nothing fixed, so test case is not helpful" for i, j in zip(self.pop.fixations, self.pop.fixation_times): self.assertTrue(i.key in self.ft.freqs) self.assertEqual(self.ft.freqs[i.key][-1][0], j)
def runsim(args, simseed, npseed): dg = demes.load(args.yaml) final_demes = get_final_demes(dg) demog = fwdpy11.discrete_demography.from_demes(dg, burnin=args.burnin) final_deme_ids = sorted([ i for i in demog.metadata["deme_labels"] if demog.metadata["deme_labels"][i] in final_demes ]) initial_sizes = [ demog.metadata["initial_sizes"][i] for i in sorted(demog.metadata["initial_sizes"].keys()) ] recrate = RHO / (4.0 * initial_sizes[0]) pdict = { "nregions": [], "sregions": [], "recregions": [fwdpy11.PoissonInterval(0, 1, recrate)], "gvalue": fwdpy11.Multiplicative(2.0), "rates": (0.0, 0.0, None), "simlen": demog.metadata["total_simulation_length"], "demography": demog, } params = fwdpy11.ModelParams(**pdict) pop = fwdpy11.DiploidPopulation(initial_sizes, 1.0) # FIXME: need seed as input argument to this fxn rng = fwdpy11.GSLrng(simseed) np.random.seed(npseed) fwdpy11.evolvets(rng, pop, params, 100) nmuts = fwdpy11.infinite_sites(rng, pop, THETA / (4.0 * initial_sizes[0])) md = np.array(pop.diploid_metadata, copy=False) sample_nodes = [] for i in final_deme_ids: w = np.where(md["deme"] == i) s = np.random.choice(w[0], args.nsam, replace=False) sample_nodes.append(md["nodes"][s].flatten()) fs = pop.tables.fs(sample_nodes) return fs
def runsim(model, num_subsamples, nsam, seed): rng = fwdpy11.GSLrng(seed) pop = fwdpy11.DiploidPopulation(model["Nref"], model["genome_length"]) fwdpy11.evolvets(rng, pop, fwdpy11.ModelParams(**model["pdict"]), 100) if model["mutations_are_neutral"] is True: fwdpy11.infinite_sites(rng, pop, model["theta"] / 4 / model["Nref"]) mean_fst = 0.0 deme_zero_fs = np.zeros(2 * args.nsam - 1) deme_one_fs = np.zeros(2 * args.nsam - 1) for _ in range(num_subsamples): fs = testutils.analysis_tools.tskit_fs(pop, nsam) fs = moments.Spectrum(fs) mean_fst += fs.Fst() deme_zero_fs += fs.marginalize([1]).data[1:-1] deme_one_fs += fs.marginalize([0]).data[1:-1] mean_fst /= num_subsamples deme_zero_fs /= num_subsamples deme_one_fs /= num_subsamples return mean_fst, deme_zero_fs, deme_one_fs
def runsim(args): """ Run the simulation and deliver output to files. """ pop = fwdpy11.DiploidPopulation(args.popsize, GENOME_LENGTH) rng = fwdpy11.GSLrng(args.seed) GSSmo = fwdpy11.GSSmo([(0, 0, args.VS), (10 * args.popsize, args.opt, args.VS)]) popsizes = [args.popsize ] * (10 * args.popsize + int(args.time * float(args.popsize))) p = { 'nregions': [], # No neutral mutations -- add them later! 'gvalue': fwdpy11.Additive(2.0, GSSmo), 'sregions': [fwdpy11.GaussianS(0, GENOME_LENGTH, 1, args.sigma)], 'recregions': [fwdpy11.Region(0, GENOME_LENGTH, 1)], 'rates': (0.0, args.mu, args.rho / float(4 * args.popsize)), # Keep mutations at frequency 1 in the pop if they affect fitness. 'prune_selected': False, 'demography': np.array(popsizes, dtype=np.uint32) } params = fwdpy11.ModelParams(**p) r = Recorder(args.record, args.preserve, args.num_ind) fwdpy11.evolvets(rng, pop, params, 100, r, suppress_table_indexing=True) with lzma.open(args.filename, 'wb') as f: pickle.dump(pop, f) if args.statfile is not None: stats = pd.DataFrame(r.data, columns=DATA._fields) # Write the statistics to an sqlite3 database, # which can be processed in R via dplyr. conn = sqlite3.connect(args.statfile) stats.to_sql('data', conn)
def testQtraitSim(self): N = 1000 demography = np.array([N] * 10 * N, dtype=np.uint32) rho = 1. r = rho / (4 * N) GSS = fwdpy11.GSS(VS=1, opt=1) a = fwdpy11.Additive(2.0, GSS) p = { 'nregions': [], 'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)], 'recregions': [fwdpy11.PoissonInterval(0, 1, r)], 'rates': (0.0, 0.005, None), 'gvalue': a, 'prune_selected': False, 'demography': demography } params = fwdpy11.ModelParams(**p) rng = fwdpy11.GSLrng(101 * 45 * 110 * 210) pop = fwdpy11.DiploidPopulation(N, 1.0) class Recorder(object): """ Records entire pop every 100 generations """ def __call__(self, pop, recorder): if pop.generation % 100 == 0.0: recorder.assign(np.arange(pop.N, dtype=np.int32)) r = Recorder() fwdpy11.evolvets(rng, pop, params, 100, r) ancient_sample_metadata = np.array(pop.ancient_sample_metadata, copy=False) alive_sample_metadata = np.array(pop.diploid_metadata, copy=False) metadata = np.hstack((ancient_sample_metadata, alive_sample_metadata)) nodes = np.array(pop.tables.nodes, copy=False) metadata_nodes = metadata['nodes'].flatten() metadata_node_times = nodes['time'][metadata_nodes] metadata_record_times = nodes['time'][metadata['nodes'][:, 0]] genetic_trait_values_from_sim = [] genetic_values_from_ts = [] for u in np.unique(metadata_node_times): samples_at_time_u = metadata_nodes[np.where( metadata_node_times == u)] vi = fwdpy11.VariantIterator(pop.tables, samples_at_time_u) sum_esizes = np.zeros(len(samples_at_time_u)) for variant in vi: g = variant.genotypes r = variant.records[0] mutant = np.where(g == 1)[0] sum_esizes[mutant] += pop.mutations[r.key].s ind = int(len(samples_at_time_u) / 2) temp_gvalues = np.zeros(ind) temp_gvalues += sum_esizes[0::2] temp_gvalues += sum_esizes[1::2] genetic_values_from_ts.extend(temp_gvalues.tolist()) genetic_trait_values_from_sim.extend(metadata['g'][np.where( metadata_record_times == u)[0]].tolist()) for i, j in zip(genetic_trait_values_from_sim, genetic_values_from_ts): self.assertAlmostEqual(i, j)
import fwdpy11 print(fwdpy11.__file__) import numpy as np import FixedCrossoverInterval N = 1000 pdict = { 'demography': fwdpy11.DiscreteDemography(), 'simlen': 100, 'nregions': [], 'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)], 'recregions': [FixedCrossoverInterval.FixedCrossoverInterval(0, 1, 2)], 'rates': (0., 5e-3, None), 'gvalue': fwdpy11.Additive(2., fwdpy11.GSS(VS=1, opt=1)), 'prune_selected': False } params = fwdpy11.ModelParams(**pdict) print(params.recregions) pop = fwdpy11.DiploidPopulation(N, 1.0) rng = fwdpy11.GSLrng(42) fwdpy11.evolvets(rng, pop, params, 100)
def testEvolve(self): # TODO: actually test something here :) fwdpy11.evolvets(self.rng, self.pop, self.params, 1, self.recorder) samples = [i for i in range(2*self.pop.N)] + \ self.pop.tables.preserved_nodes vi = fwdpy11.TreeIterator(self.pop.tables, samples)
def setUpClass(self): self.params, self.rng, self.pop = set_up_quant_trait_model() fwdpy11.evolvets(self.rng, self.pop, self.params, 100) assert max(self.pop.mcounts) == 2 * \ self.pop.N, "Nothing fixed, so test case is not helpful"
def test_no_mutations(self): self.params.rates = (0, 0, 0) fwdpy11.evolvets(self.rng, self.pop, self.params, 100)
import sys import fwdpy11 N = int(sys.argv[1]) seed = int(sys.argv[2]) pdict = { "nregions": [], "sregions": [], "recregions": [], "rates": [0, 0, 0], "gvalue": fwdpy11.Multiplicative(2.0), "simlen": 5 * N, } mp = fwdpy11.ModelParams(**pdict) pop = fwdpy11.DiploidPopulation(N, 1.0) rng = fwdpy11.GSLrng(seed) fwdpy11.evolvets(rng, pop, mp, 100, suppress_table_indexing=True) ts = pop.dump_tables_to_tskit() # Copies all data from C++ to Python ts.dump("fwdpy11.trees")