Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (37 sloc) 1.34 KB
import random
import dendropy
from dendropy import treesim
def generate(birth_rates, death_rates):
assert len(birth_rates) == len(death_rates)
tree = dendropy.Tree()
for i, br in enumerate(birth_rates):
tree = treesim.birth_death(birth_rates[i],
death_rates[i],
max_time=random.randint(1,8),
tree=tree,
assign_taxa=False,
repeat_until_success=True)
print(tree.as_string('newick'))
tree.randomly_assign_taxa(create_required_taxa=True)
return tree
tree = generate([0.1, 0.6, 0.1], [0.1, 0.6, 0.1])
print(tree.as_string('newick'))
import dendropy
citation = """\
@article{HeathHH2012,
Author = {Tracy A. Heath and Mark T. Holder and John P. Huelsenbeck},
Doi = {10.1093/molbev/msr255},
Journal = {Molecular Biology and Evolution},
Number = {3},
Pages = {939-955},
Title = {A {Dirichlet} Process Prior for Estimating Lineage-Specific Substitution Rates.},
Url = {http://mbe.oxfordjournals.org/content/early/2011/11/04/molbev.msr255.abstract},
Volume = {29},
Year = {2012}
}
"""
dataset = dendropy.DataSet.get_from_string(
"(A,(B,(C,(D,E))));",
"newick")
dataset.annotations.add_citation(citation)
print dataset.as_string("nexml")
You can’t perform that action at this time.