def get_species_tree(self, ntax=10): _RNG = RepeatedRandom() ages = [random.randint(1000,10000) for age in range(ntax)] ages.sort() pop_sizes = [random.randint(1000,10000) for pop in range(2*ntax+1)] taxon_set = dendropy.new_taxon_set(ntax) species_tree = treesim.pop_gen_tree(taxon_set=taxon_set, ages=ages, num_genes=4, pop_sizes=pop_sizes, rng=_RNG) ages2 = [] for node in species_tree.postorder_node_iter(): distance_from_tip = node.distance_from_tip() if distance_from_tip > 0: ages2.append(distance_from_tip) ages2.sort() for index in range(len(ages2)): assert (ages[index] - ages2[index]) < 10e-6 pop_sizes2 = [] for edge in species_tree.postorder_edge_iter(): pop_sizes2.append(edge.pop_size) pop_sizes2.sort() return species_tree
def get_species_tree(self, ntax=10): _RNG = RepeatedRandom() ages = [random.randint(1000, 10000) for age in range(ntax)] ages.sort() pop_sizes = [ random.randint(1000, 10000) for pop in range(2 * ntax + 1) ] taxon_set = dendropy.new_taxon_set(ntax) species_tree = treesim.pop_gen_tree(taxon_set=taxon_set, ages=ages, num_genes=4, pop_sizes=pop_sizes, rng=_RNG) ages2 = [] for node in species_tree.postorder_node_iter(): distance_from_tip = node.distance_from_tip() if distance_from_tip > 0: ages2.append(distance_from_tip) ages2.sort() for index in range(len(ages2)): assert (ages[index] - ages2[index]) < 10e-6 pop_sizes2 = [] for edge in species_tree.postorder_edge_iter(): pop_sizes2.append(edge.pop_size) pop_sizes2.sort() return species_tree
def runTest(self): """PureCoalescentTreeTest -- tree generation without checking [TODO: checks]""" _RNG = RepeatedRandom() t = treesim.pure_kingman(dendropy.new_taxon_set(100), rng=_RNG) assert t._debug_tree_is_valid()