PhyloTree¶
- class PhyloTree(tree, tree_format='newick', copy=False)[source]¶
Main class responsible for working with phylogenetic trees.
Constructor for
PhyloTree.- Parameters
tree (Union[str, _io.StringIO, pmaf.phylo.tree._metakit.PhyloTreeMetabase, ete3.coretype.tree.TreeNode]) – Tree data can be string, IO stream, any tree class from module
ete3tree_format (str) – If tree is string-like then tree_format should be tree format
copy (bool) – if tree is
PhyloTreeor any tree class from moduleete3, then should copy made prior to construction or not.
Attributes
internal_node_namesList of internal node names.
internal_nodesList of internal node instances.
node_namesList of all node names.
nodesList of all nodes.
tip_namesList of all tip names.
tipsList of all tips.
total_internal_nodesTotal number of internal nodes.
total_nodesTotal number of nodes.
total_tipsTotal number of tips.
Methods
annotate_nodes_by_map(node_mapping[, only_tips])Annotate nodes by inserting annotation text based on node_mapping
Delete internal node names.
copy()Create a copy of self.
Get ASCII tree art.
get_mcra_for_nodes(node_names)Get MRCA node for the given list of node names.
get_newick_str(**kwargs)Get Newick string of the tree.
get_node_by_name(node_name)Get node instance by its name.
Sort branches of the tree from shortest to longest.
merge_nodes(tip_names)Merge given tips into single node.
prune_by_ids(node_ids)Prune the tree and keep the nodes/tips in node_ids
remove_node(node)Delete the node.
remove_node_by_name(node_name)Delete nodes by name
render(output_fp)Render tree to the file.
replace_nodes_by_map(node_mapping[, only_tips])Replace node names by map node_mapping
Resolve all polytomies and create a dicotomic tree structure.
Sort tips by names.
to_skbio([rooted])Convert tree to
skbioTreeNodeunroot()Unroot the tree.
write(tree_fp, **kwargs)Write tree to file.