Exemplo n.º 1
0
    def get_species_tree(self, ntax=10):
        _RNG = MockRandom()
        ages = [_RNG.randint(1000,10000) for age in range(ntax)]
        ages.sort()
        pop_sizes = [_RNG.randint(1000,10000) for pop in range(2*ntax+1)]
        taxon_namespace = dendropy.TaxonNamespace(["t{}".format(i+1) for i in range(ntax)])
        species_tree = popgensim.pop_gen_tree(taxon_namespace=taxon_namespace,
                                                 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
Exemplo n.º 2
0
    def get_species_tree(self, ntax=10):
        _RNG = MockRandom()
        ages = [_RNG.randint(1000, 10000) for age in range(ntax)]
        ages.sort()
        pop_sizes = [_RNG.randint(1000, 10000) for pop in range(2 * ntax + 1)]
        taxon_namespace = dendropy.TaxonNamespace(
            ["t{}".format(i + 1) for i in range(ntax)])
        species_tree = popgensim.pop_gen_tree(taxon_namespace=taxon_namespace,
                                              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
Exemplo n.º 3
0
def pop_gen_tree(*args, **kwargs):
    deprecate.dendropy_deprecation_warning(
        preamble="Deprecated since DendroPy 4: The 'dendropy.treesim.pop_gen_tree()' function has moved to 'dendropy.simulate.popgensim.pop_gen_tree()'.",
        old_construct="from dendropy import treesim\ntree = treesim.pop_gen_tree(...)",
        new_construct="from dendropy.simulate import popgensim\ntree = popgensim.pop_gen_tree(...)",
    )
    return popgensim.pop_gen_tree(*args, **kwargs)
Exemplo n.º 4
0
def pop_gen_tree(*args, **kwargs):
    deprecate.dendropy_deprecation_warning(
        preamble=
        "Deprecated since DendroPy 4: The 'dendropy.treesim.pop_gen_tree()' function has moved to 'dendropy.simulate.popgensim.pop_gen_tree()'.",
        old_construct=
        "from dendropy import treesim\ntree = treesim.pop_gen_tree(...)",
        new_construct=
        "from dendropy.simulate import popgensim\ntree = popgensim.pop_gen_tree(...)"
    )
    return popgensim.pop_gen_tree(*args, **kwargs)