Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_decapitated_mutations(self):
ts = msprime.simulate(10, random_seed=5, mutation_rate=10)
from_ts = tsutil.decapitate(ts, ts.num_edges // 2)
self.assertGreater(from_ts.num_mutations, 0)
start_time = from_ts.tables.nodes.time.max()
final_ts = msprime.simulate(
from_ts=from_ts, start_time=start_time, random_seed=2)
self.verify_from_tables(from_ts, final_ts, start_time)
self.verify_simulation_completed(final_ts)
def test_many_trees(self):
ts = msprime.simulate(5, recombination_rate=4, random_seed=self.random_seed)
self.assertGreater(ts.num_trees, 2)
self.verify_single_childified(ts)
self.verify_multiroot_internal_samples(ts)
def test_two_populations_high_migration(self):
ts = msprime.simulate(
population_configurations=[
msprime.PopulationConfiguration(8),
msprime.PopulationConfiguration(8)],
migration_matrix=[[0, 1], [1, 0]],
recombination_rate=3,
random_seed=5)
self.assertGreater(ts.num_trees, 1)
self.verify(ts, [ts.samples(0), ts.samples(1)])
def test_single_tree_recurrent_mutations(self):
ts = msprime.simulate(6, random_seed=10)
for mutations_per_branch in [1, 2, 3]:
ts = tsutil.insert_branch_mutations(ts, mutations_per_branch)
for num_samples in range(1, ts.num_samples):
for samples in itertools.combinations(ts.samples(), num_samples):
self.verify_simplify_haplotypes(ts, samples)
msprime.MassMigration(
time=5, source=1, destination=0, proportion=1.0)
]
for n in [2, 10, 20]:
for mutrate in [0.0]:
for recrate in [0.0, 0.01]:
yield msprime.simulate(n, mutation_rate=mutrate,
recombination_rate=recrate,
length=200)
population_configurations =[
msprime.PopulationConfiguration(
sample_size=n, initial_size=100),
msprime.PopulationConfiguration(
sample_size=n, initial_size=100)
]
yield msprime.simulate(
population_configurations=population_configurations,
demographic_events=demographic_events,
recombination_rate=recrate,
mutation_rate=mutrate,
length=250)
def get_binary_example(self):
ts = msprime.simulate(
sample_size=25, recombination_rate=5, random_seed=self.random_seed)
return ts
def test_ancestors_file(self):
ts = msprime.simulate(10, mutation_rate=1, random_seed=1)
self.assertGreater(ts.num_sites, 1)
sample_data = tsinfer.SampleData.from_tree_sequence(ts)
ancestor_data = tsinfer.generate_ancestors(sample_data)
self.validate_file(ancestor_data)
def test_simplify(self):
ts = msprime.simulate(5, random_seed=1)
ts = ts.simplify()
prov = json.loads(ts.provenance(1).record)
tskit.validate_provenance(prov)
self.assertEqual(prov["parameters"]["command"], "simplify")
def test_wf_hudson_different_specifications(self):
Ne = 100
t = 100
ts1 = msprime.simulate(
sample_size=10,
model=msprime.DiscreteTimeWrightFisher(Ne),
recombination_rate=0.1,
demographic_events=[
msprime.SimulationModelChange(t, msprime.StandardCoalescent(Ne))],
random_seed=2)
ts2 = msprime.simulate(
sample_size=10, recombination_rate=0.1,
Ne=Ne, model="dtwf",
demographic_events=[msprime.SimulationModelChange(t, "hudson")],
random_seed=2)
ts3 = msprime.simulate(
sample_size=10, recombination_rate=0.1,
Ne=Ne, model="dtwf",
demographic_events=[msprime.SimulationModelChange(t)],
random_seed=2)
t1 = ts1.dump_tables()
t2 = ts2.dump_tables()
t3 = ts3.dump_tables()
t1.provenances.clear()
t2.provenances.clear()
t3.provenances.clear()
self.assertEqual(t1, t2)
self.assertEqual(t1, t3)
def test_single_tree_three_mutations_per_branch(self):
ts = msprime.simulate(8, random_seed=9)
self.verify_branch_mutations(ts, 3)