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 ete3

  • tree_format (str) – If tree is string-like then tree_format should be tree format

  • copy (bool) – if tree is PhyloTree or any tree class from module ete3, then should copy made prior to construction or not.

Attributes

internal_node_names

List of internal node names.

internal_nodes

List of internal node instances.

node_names

List of all node names.

nodes

List of all nodes.

tip_names

List of all tip names.

tips

List of all tips.

total_internal_nodes

Total number of internal nodes.

total_nodes

Total number of nodes.

total_tips

Total number of tips.

Methods

annotate_nodes_by_map(node_mapping[, only_tips])

Annotate nodes by inserting annotation text based on node_mapping

clear_internal_node_names()

Delete internal node names.

copy()

Create a copy of self.

get_ascii_art()

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.

ladderize()

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_polytomy()

Resolve all polytomies and create a dicotomic tree structure.

sort_by_name()

Sort tips by names.

to_skbio([rooted])

Convert tree to skbioTreeNode

unroot()

Unroot the tree.

write(tree_fp, **kwargs)

Write tree to file.