def __init__(self, tree_sequence, breakpoints=None): self._tree_sequence = tree_sequence self._num_samples = tree_sequence.get_num_samples() self._breakpoints = breakpoints self._sites = [] def make_mutation(id_): site, node, derived_state, parent, metadata = tree_sequence.get_mutation( id_) return msprime.Mutation(id_=id_, site=site, node=node, derived_state=derived_state, parent=parent, metadata=metadata) for j in range(tree_sequence.get_num_sites()): pos, ancestral_state, ll_mutations, id_, metadata = tree_sequence.get_site( j) self._sites.append( msprime.Site(id_=id_, position=pos, ancestral_state=ancestral_state, mutations=[ make_mutation(ll_mut) for ll_mut in ll_mutations ], metadata=metadata))
def test_single_tree_regular_mutations(self): ts = msprime.simulate(self.num_test_sites, length=self.num_test_sites) # TODO change this to use branch_mutations from tsutil. sites = [ msprime.Site( position=j, index=j, ancestral_state="0", mutations=[msprime.Mutation(site=j, node=j, derived_state="1")]) for j in range(self.num_test_sites)] ts = ts.copy(sites) self.verify_matrix(ts) self.verify_max_distance(ts)
def recurrent_mutation_example(): ts = msprime.simulate(10, recombination_rate=1, length=10, random_seed=2) sites = [ msprime.Site(position=j, index=j, ancestral_state="0", mutations=[ msprime.Mutation(site=j, node=k, derived_state="1") for k in range(j + 1) ]) for j in range(ts.sample_size) ] return ts.copy(sites)
def test_tree_sequence_regular_mutations(self): ts = msprime.simulate(self.num_test_sites, recombination_rate=1, length=self.num_test_sites) self.assertGreater(ts.get_num_trees(), 10) sites = [ msprime.Site(position=j, index=j, ancestral_state="0", mutations=[ msprime.Mutation(site=j, node=j, derived_state="1") ]) for j in range(self.num_test_sites) ] ts = ts.copy(sites) self.verify_matrix(ts) self.verify_max_distance(ts)