def __init__(self, tree_sequence, breakpoints=None): self._tree_sequence = tree_sequence self._sites = [] # TODO this code here is expressed in terms of the low-level # tree sequence for legacy reasons. It probably makes more sense # to describe it in terms of the tables now if we want to have an # independent implementation. ll_ts = self._tree_sequence._ll_tree_sequence def make_mutation(id_): site, node, derived_state, parent, metadata = ll_ts.get_mutation(id_) return tskit.Mutation( id_=id_, site=site, node=node, derived_state=derived_state, parent=parent, metadata=metadata, ) for j in range(tree_sequence.num_sites): pos, ancestral_state, ll_mutations, id_, metadata = ll_ts.get_site(j) self._sites.append( tskit.Site( id_=id_, position=pos, ancestral_state=ancestral_state, mutations=[make_mutation(ll_mut) for ll_mut in ll_mutations], metadata=metadata, ) )
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 tskit.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( tskit.Site(id_=id_, position=pos, ancestral_state=ancestral_state, mutations=[ make_mutation(ll_mut) for ll_mut in ll_mutations ], metadata=metadata))