Followed DendroPy's tutorial and I was able to prune a phylogenetic tree
in 50 minutes. DendroPy's example scripts can be found both on its website and in the examples/ folder in the downloaded source code package.
The interactive mode of Python is also very useful in
this learning experience. It should be noted that DendroPy does not support Python3.0, which is a problem shared by most other bioinformatics related python projects, such as biopython.
import dendropy
dir(dendropy)
help(dendropy.Tree)
tree_str = "[&R] ((A, (B, (C, (D, E)))),(F, (G, H)));"
tree = dendropy.Tree.get_from_string(
tree_str,
"newick")
dir(tree)
print("Before:")
print(tree.as_string('newick'))
print(tree.as_ascii_plot())
tree.prune_taxa_with_labels(["A", "C", "G"])
print("After:")
print(tree.as_string('newick'))
print(tree.as_ascii_plot())
Later, I found that DendroPy cannot parse nodes with multiple labels, such as those output by codeml.
No comments:
Post a Comment