Skip to main content
`Ctrl`+`K`

# cogent3.core.tree.PhyloNode

class PhyloNode(name: str, children: Iterable[Self | str] | None = None, parent: Self | None = None, params: dict[str, Any] | None = None, name_loaded: bool = True, length: float | None = None, support: float | None = None)

  Store information about a tree node. Mutable.

  Parameters:

    name: label for the node, assumed to be unique. children: list of the node’s children. parent: parent to this node params: dict containing arbitrary parameters for the node. name_loaded: ?

  Attributes:
    children
    length
    name
    name_loaded
    params
    `parent`

      parent of this node

    source
    support

  Methods

  `ancestors`() | Returns all ancestors back to the root.
  `append`(i) | Appends i to self.children, in-place, cleaning up refs.
  `ascii_art`([show_internal, compact]) | Returns a string containing an ascii drawing of the tree.
  `balanced`() | Tree 'rooted' here with no neighbour having > 50% of the edges.
  `bifurcating`([eps, name_unnamed]) | Wrap multifurcating with a num of 2
  `child_parent_map`() | return dict of {<child name>: <parent name>, ...}
  `compare_by_names`(other) | Equality test for trees by name
  `compare_by_subsets`(other[, exclude_absent_taxa]) | Returns fraction of overlapping subsets where self and other differ.
  `compare_name`(other) | Compares PhyloNode by name
  `copy`([memo]) | Returns a copy of self using an iterative approach
  `deepcopy`([memo]) | Returns a copy of self using an iterative approach
  `descendant_array`([tip_list]) | Returns numpy array with nodes in rows and descendants in columns.
  `distance`(other) | Returns branch length between self and other.
  `extend`(items) | Extends self.children by items, in-place, cleaning up refs.
  `get_connecting_edges`(name1, name2) | returns a list of edges connecting two nodes.
  `get_connecting_node`(name1, name2) | Finds the last common ancestor of the two named edges.
  `get_edge_names`(tip_name_1, tip_name_2[, ...]) | Return the list of stem and/or sub tree (clade) edge name(s).
  `get_edge_vector`([include_root]) | Collect the list of edges in postfix order
  `get_figure`([style]) | gets Dendrogram for plotting the phylogeny
  `get_max_tip_tip_distance`() | Returns the max tip-to-tip distance between any pair of tips
  `get_newick`([with_distances, semicolon, ...]) | Return the newick string of node and its descendents
  `get_node_matching_name`(name) | find the edge with the name
  `get_node_names`([include_self, tips_only]) | Return a list of edges from this edge - may or may not include self.
  `get_nodes_dict`() | Returns a dict keyed by node name, value is node
  `get_param_value`(param, edge) | returns the parameter value for named edge
  `get_root`() | Returns root of the tree self is in.
  `get_sub_tree`(names[, ignore_missing, ...]) | A new instance of a sub tree that contains all the otus that are listed in name_list.
  `get_tip_names`([include_self]) | return the list of the names of all tips contained by this edge
  `index_in_parent`() | Returns index of self in parent.
  `insert`(index, i) | Inserts an item at specified position in self.children.
  `is_root`() | Returns True if the current is a root, i.e. has no parent.
  `is_tip`() | Returns True if the current node is a tip, i.e. has no children.
  `isroot`() | Returns True if root of a tree, i.e. no parent.
  `istip`() | Returns True if is tip, i.e. no children.
  `iter_nontips`([include_self]) | Iterates over nontips descended from self
  `iter_tips`([include_self]) | Iterates over tips descended from self, [] if self is a tip.
  `ladderise`() | Return an equivalent tree nodes using a ladderise sort.
  `ladderize`() | Return an equivalent tree nodes using a ladderise sort.
  `last_common_ancestor`(other) | Finds last common ancestor of self and other, or None.
  `lca`(other) | Finds last common ancestor of self and other, or None.
  `levelorder`([include_self]) | Performs levelorder iteration over tree
  `lin_rajan_moret`(tree2) | return the lin-rajan-moret distance between trees
  `lowest_common_ancestor`(tip_names) | Lowest common ancestor for a list of tipnames
  `make_tree_array`([dec_list]) | Makes an array with nodes in rows and descendants in columns.
  `max_tip_tip_distance`() | returns the max distance between any pair of tips
  `multifurcating`(num[, eps, name_unnamed]) | return a new tree with every node having num or few children
  `name_unnamed_nodes`() | sets the Data property of unnamed nodes to an arbitrary value
  `non_tip_children`() | Returns direct children in self that have descendants.
  `nontips`([include_self]) | Returns nontips descended from self.
  `pop`([index]) | Returns and deletes child of self at index (default: -1)
  `postorder`([include_self]) | performs postorder iteration over tree
  `pre_and_postorder`([include_self]) | Performs iteration over tree, visiting node before and after.
  `preorder`([include_self]) | Performs preorder iteration over tree.
  `prune`([keep_root, params_merge_callback]) | removes nodes with one child
  `reassign_names`(mapping[, nodes]) | Reassigns node names based on a mapping dict
  `remove`(target) | Removes node by name instead of identity.
  `remove_deleted`(should_delete) | Removes all nodes where should_delete tests true.
  `remove_node`(target) | Removes node by identity instead of value.
  `renamed_nodes`(name_map) | returns a copy of the tree with nodes renamed according to name_map
  `root_at_midpoint`() | return a new tree rooted at midpoint of the two tips farthest apart
  `rooted`(edge_name) | Returns a new tree with split at edge_name
  `rooted_at`(edge_name) | Return a new tree rooted at the provided node.
  `rooted_with_tip`(outgroup_name) | A new tree with the named tip as one of the root's children
  `same_shape`(other) | Ignores lengths and order, so trees should be sorted first
  `same_topology`(other) | Tests whether two trees have the same topology.
  `separation`(other) | Returns number of edges separating self and other.
  `set_param_value`(param, edge, value) | set's the value for param at named edge
  `siblings`() | Returns all nodes that are children of the same parent as self.
  `sorted`([sort_order]) | An equivalent tree with tips in sort_order.
  `subset`() | Returns set of names that descend from specified node
  `subsets`() | Returns all sets of names that come from specified node and its kids
  `tip_children`() | Returns direct children of self that are tips.
  `tip_to_root_distances`([names, ...]) | returns the cumulative sum of lengths from each tip to the root
  `tip_to_tip_distances`([names, default_length]) | Returns distance matrix between all pairs of tips, and a tip order
  `tips`([include_self]) | Returns tips descended from self, [] if self is a tip.
  `tips_within_distance`(distance) | Returns tips within specified distance from self
  `to_json`() | returns json formatted string {'newick': with edges and distances, 'edge_attributes': }
  `to_rich_dict`() | returns {'newick': with node names, 'edge_attributes': {'tip1': {'length': ...}, ...}}
  `total_descending_branch_length`() | Returns total descending branch length from self
  `total_length`() | returns the sum of all branch lengths in tree
  `tree_distance`(other[, method]) | Return the specified tree distance between this and another tree.
  `unrooted`() | A tree with at least 3 children at the root.
  `unrooted_deepcopy`([parent]) | Returns a deepcopy of the tree using unrooted traversal.
  `write`(filename[, with_distances, format_name]) | Save the tree to filename

  get_neighbours_except |
  parse_token |