src/phylogeni/tree

    Dark Mode
Search:
Group by:
  Source   Edit

Types

Node[T] = ref object
  parent*: Node[T]
  children*: seq[Node[T]]
  label*: string
  length*: float
  data*: T
  Source   Edit
Tree[T] = ref object
  root*: Node[T]
  rooted*: bool
  Source   Edit
TreeError = object of CatchableError
  Source   Edit
TreeSeq[T] = seq[Tree[T]]
  Source   Edit

Procs

func `$`[T](node: Node[T]): string
Returns ascii string representation of tree.   Source   Edit
func `$`[T](tree: Tree[T]): string
Returns ascii string representation of tree.   Source   Edit
func addChild[T](parent: Node[T]; newChild: Node[T])
Add child node to parent.   Source   Edit
func addSister[T](node: Node[T]; newSister: Node[T])
Add sister node.   Source   Edit
func ascii[T](node: Node[T]; char1 = "-"; showInternal = true): string
Returns ascii string representation of tree.   Source   Edit
func ascii[T](tree: Tree[T]; char1 = "-"; showInternal = true): string
Returns ascii string representation of tree.   Source   Edit
func calcTreeLength[T](node: Node[T]; includeRoot = true): float
Calculate total length of tree.   Source   Edit
func calcTreeLength[T](tree: Tree[T]): float
Calculate total length of tree.   Source   Edit
func hash[T](n: Node[T]): Hash
  Source   Edit
func isLeaf[T](node: Node[T]): bool
Check if node is leaf.   Source   Edit
func ladderize[T](root: Node[T]; order: SortOrder = Ascending)
Ladderize subtree.   Source   Edit
func ladderize[T](tree: Tree[T]; order: SortOrder = Ascending)
Ladderize tree.   Source   Edit
func newNode(label: string; length: float; typ: typedesc = void): Node[typ]
Create new Node.   Source   Edit
func newTree(typ: typedesc = void): Tree[typ]
Create new Tree.   Source   Edit
func prune[T](tree: Tree[T]; node: Node[T])
Prune node from tree.   Source   Edit
func prune[T](tree: Tree[T]; nodes: seq[Node[T]])
Prune nodes from tree.   Source   Edit
proc treeFromFile(path: string; typ: typedesc = void): Tree[typ]
Read tree from file.   Source   Edit
proc treeFromString(str: string; typ: typedesc = void): Tree[typ]
Read tree from string.   Source   Edit
func treeHeight[T](node: Node[T]; includeRoot = true): float
Calculate the height of subtree.   Source   Edit
func treeHeight[T](tree: Tree[T]; includeRoot = true): float
Calculate the height of tree.   Source   Edit

Iterators

iterator inorder[T](root: Node[T]): Node[T]
Inorder traverse. Tree must be strictly bifurcating.   Source   Edit
iterator inorder[T](tree: Tree[T]): Node[T]
Inorder traverse. Tree must be strictly bifurcating.   Source   Edit
iterator iterleaves[T](root: Node[T]): Node[T]
Iter over leaves.   Source   Edit
iterator iterleaves[T](tree: Tree[T]): Node[T]
Iter over leaves.   Source   Edit
iterator levelorder[T](root: Node[T]): Node[T]
Levelorder traverse.   Source   Edit
iterator levelorder[T](tree: Tree[T]): Node[T]
Levelorder traverse.   Source   Edit
iterator newickorder[T](root: Node[T]): tuple[node: Node[T], firstVisit: bool]
Newick order traverse. All internal nodes are visited twice.   Source   Edit
iterator newickorder[T](tree: Tree[T]): tuple[node: Node[T], firstVisit: bool]
Newick order traverse. All internal nodes are visited twice.   Source   Edit
iterator postorder[T](root: Node[T]): Node[T]
Postorder traverse.   Source   Edit
iterator postorder[T](tree: Tree[T]): Node[T]
Postorder traverse.   Source   Edit
iterator preorder[T](root: Node[T]): Node[T]
Preorder traverse.   Source   Edit
iterator preorder[T](tree: Tree[T]): Node[T]
Preorder traverse.   Source   Edit