Phylo.API
The Phylo.API submodule provides the API that must be extended for new AbstractTree, AbstractNode and AbstractBranch subtypes.
Usage
Providing additional code to extend the functionality of the system is simple:
using Phylo
struct SimplestTree <: AbstractTree{Int, Int}
nodes::OrderedDict{Int, BinaryNode{Int}}
branches::Dict{Int, Branch{Int}}
end
import Phylo.API: _addnode!
function _addnode!(tree::SimplestTree, num)
_setnode!(tree, num, BinaryNode{Int}())
return num
endcreates a new SimplestTree type (a subtype of AbstractTree) and extends Phylo.API._addnode!() (and therefore the directly accessible addnode!() interface) to handle the SimplestTree subtype of AbstractTree. See docs here to see which Phylo.API functions have to be extended for any new subtype, and which have default implementations.
Phylo.API — ModulePhylo.API submoduleThe Phylo.API submodule should be imported if you want to create a new phylogeny, node or branch subtype. Otherwise it can be ignored.
Phylo.API._addconnection! — Function_addconnection!(tree::AbstractTree, node::AbstractNode, branch)Add a connection to an unrooted node. Must be implemented for any unrooted AbstractNode subtype unless this happens when a branch is added.
Phylo.API._addinbound! — Function_addinbound!(tree::AbstractTree, node::AbstractNode, inbound)Adds a branch to the input of a rooted node. Must be implemented for any rooted AbstractNode subtype unless this happens when a branch is created.
Phylo.API._addoutbound! — Function_addoutbound!(tree::AbstractTree, node::AbstractNode, branch)Add an outbound branch to a rooted node. Must be implemented for any Rooted AbstractNode subtype unless this happens when a branch is created.
Phylo.API._branchdatatype — Function_branchdatatype(::Type{<:AbstractTree})Returns the type of the branch info data.
Phylo.API._branchdims — Function_branchdims(::Type{<:AbstractTree})Returns the dimensions of the branch lengths for the tree.
Phylo.API._clearrootheight! — Function_clearrootheight!(::AbstractTree)Phylo.API._conn — Function_conn(branch::AbstractBranch, exclude::AbstractNode)Return the connection for a branch that isn't the exclude node. May be implemented for any Unrooted AbstractBranch subtype, otherwise will use _conns.
Phylo.API._conns — Function_conns(tree::AbstractTree, branch::AbstractBranch)Return a vector of connections for a branch. Must be implemented for any Unrooted AbstractBranch subtype, otherwise can combine _src and _dst.
Phylo.API._createbranch! — Function_createbranch!(tree::AbstractTree, source, destination[,
length][, data])Create a new branch and add it to a tree. Must be implemented for any AbstractTree subtype.
Phylo.API._createnode! — Function_createnode!(tree::AbstractTree, nodename[, data])Must be implemented for any AbstractTree subtype.
Phylo.API._degree — Function_degree(tree::AbstractTree, node::AbstractNode)Degree of node. Must be implemented for Unrooted nodes, otherwise can be inferred from indegree and outdegree.
Phylo.API._deletebranch! — Function_deletebranch!(tree::AbstractTree, branch)Delete a branch, reoving it from a tree. Must be implemented for any AbstractTree subtype.
Phylo.API._deletenode! — Function_deletenode!(tree::AbstractTree, nodename)Must be implemented for any AbstractTree subtype.
Phylo.API._dst — Function_dst(branch::AbstractBranch)Return destination node for a branch. Must be implemented for any rooted AbstractBranch subtype.
Phylo.API._getbranch — Function_getbranch(::AbstractTree, id)Returns the branch or name associated with id (which could be a name or a branch) from a tree. Must be implemented for any PreferBranchObjects tree and branch label type.
Phylo.API._getbranches — Function_getbranches(tree::AbstractTree)Returns a vector of branches for a OneTree tree. Either _getbranches() or _getbranchnames() must be implemented for any OneTree tree type.
Phylo.API._getbranchname — Function_getbranchname(::AbstractTree, id)Returns the name of a branch associated with id (which could be a name or a branch) from a tree. Must be implemented for PreferBranchObjects tree types.
Phylo.API._getbranchnames — Function_getbranchnames(tree::AbstractTree)Returns a vector of branch names for a OneTree tree. Either _getbranches() or _getbranchnames() must be implemented for any OneTree tree type.
Phylo.API._getchildren — Function_getchildren(tree::AbstractTree, node)
_getchildren(tree::AbstractTree, nodename)Return the child node(s) for this node. May be implemented for any rooted AbstractNode subtype.
Phylo.API._getconnections — Function_getconnections(tree::AbstractTree, node::AbstractNode)Returns all of the connections of a node. Must be implemented for any unrooted AbstractNode subtype, can be inferred from _getinbound and _getoutbounds for a rooted node.
Phylo.API._getheight — Method_getheight(tree::AbstractTree, nodename)Phylo.API._getinbound — Function_getinbound(tree::AbstractTree, node::AbstractNode)Get the inbound connection. Must be implemented for any rooted AbstractNode subtype.
Phylo.API._getleafnames — Function_getleafnames(::AbstractTree, ::TraversalOrder)Returns the leaf names of a tree. May be implemented for any tree type (otherwise determined from _getnodenames() and _isleaf() functions).
Phylo.API._getleaves — Function_getleaves(::AbstractTree)Returns the leaves (tips) of a single tree. May be implemented for any OneTree type (otherwise determined from _getnodes() and _isleaf() functions).
Phylo.API._getlength — Function_getlengthReturn length of a branch. May be implemented for any AbstractBranch subtype.
Phylo.API._getnode — Function_getnode(::AbstractTree, id)Returns the node or name associated with id (which could be a name or a node) from a tree. Must be implemented for any PreferNodeObjects tree and node label type.
Phylo.API._getnodename — Function_getnodename(::AbstractTree, id)Returns the name of a node associated with id (which could be a name or a node) from a tree. Must be implemented for PreferNodeObjects tree types.
Phylo.API._getnodenames — Function_getnodenames(tree::AbstractTree{OneTree})Returns an iterable collection of node names for a OneTree tree. Can be implemented for any OneTree tree type, especially PreferNodeObjects trees.
Phylo.API._getnodes — Function_getnodes(tree::AbstractTree{OneTree}[, order::TraversalOrder])Returns an interable collection of nodes for a OneTree tree. _getnodes(tree) must be implemented for a OneTree tree type as a base mechanisms for extracting the node list.
Phylo.API._getoutbounds — Function_getoutbounds(tree::AbstractTree, node::AbstractNode)Returns the outbound connections of a rooted node. Must be implemented for any rooted AbstractNode subtype.
Phylo.API._getparent — Function_getparent(tree::AbstractTree, node)Return the parent node for this node. Can be implemented for Rooted node types.
Phylo.API._getroot — Function_getroot(::AbstractTree)Returns the unique root of a rooted tree. May be implemented for any OneTree type (otherwise determined from _getroots()).
Phylo.API._getrootheight — Function_getrootheight(::AbstractTree)Phylo.API._getroots — Method_getroots(::AbstractTree)Returns the root(s) of a tree. May be implemented for any OneTree type (otherwise determined from _getnodes() and _isroot() functions).
Phylo.API._getsiblings — Function_getsiblings(tree::AbstractTree, node::AbstractNode)Returns all of the siblings (actually immediate connections) of a node. May be implemented for any AbstractNode subtype, can be inferred from _getparent and _getchildren for a rooted node or _getconnections for an unrooted node.
Phylo.API._gettree — Function_gettree(::Pair{Label, AbstractTree})
_gettree(::AbstractTree, id)Returns a tree - either itself if it is a single tree, or the single tree in a set with label id. Must be implemented for any ManyTrees type.
Phylo.API._gettreeinfo — Function_gettreeinfo(tree::AbstractTree)
_gettreeinfo(tree::AbstractTree, treename)Returns the info data associated with the tree(s).
Phylo.API._gettreename — Function_gettreename(::AbstractTree)Returns the name for a single tree. Should be implemented for any OneTree type where they have names.
Phylo.API._gettreenames — Function_gettreenames(::AbstractTree)Returns the names for the trees. Can be implemented for any ManyTrees type.
Phylo.API._gettrees — Function_gettrees(::AbstractTree)Returns the trees in an object. Must be implemented for any ManyTrees type.
Phylo.API._hasbranch — Function_hasbranch(tree::AbstractTree, node[name])Does the tree contain this branch? Must be implemented for any PreferBranchObjects tree type with a branch label.
Phylo.API._hasheight — Method_hasheight(tree::AbstractTree, nodename)Phylo.API._hasinbound — Function_hasinbound(tree::AbstractTree, node::AbstractNode)Must be implemented for any AbstractNode subtype.
Phylo.API._hasinboundspace — Function_hasinboundspace(tree::AbstractTree, node::AbstractNode)Is there space for a new inbound connection on a node?
Phylo.API._haslength — Function_haslengthReturn length of a branch. May be implemented for any AbstractBranch subtype.
Phylo.API._hasnode — Function_hasnode(tree::AbstractTree, node[name])Does the tree contain this node? Must be implemented for any PreferNodeObjects tree type with a node label.
Phylo.API._hasoutboundspace — Function_hasoutboundspace(tree::AbstractTree, node::AbstractNode)Is there space for a new outbound connection on a node? Must be implemented if a node has a limit on the number of outbound connections (eg for a binary tree)
Phylo.API._hasrootheight — Method_hasrootheight(::AbstractTree)Phylo.API._hasspace — Function_hasspace(tree::AbstractTree, node::AbstractNode)Is there space for a new connection on a node? Must be implemented if a node has a limit on the number of connections (eg for a binary tree)
Phylo.API._indegree — Function_indegree(tree::AbstractTree, node)In degree of node. Can be implemented for rooted nodes, otherwise inferred from _hasinbound.
Phylo.API._invalidate! — Function_invalidate!(::AbstractTree, state)Confirm that the tree is no longer necessarily valid, and remove cache information.
Phylo.API._isinternal — Function_isinternal(tree::AbstractTree, node)Is the node internal to the tree?
Phylo.API._isleaf — Function_isleaf(tree::AbstractTree, node)Is the node a leaf? Does not need to be implemented for any node type – inferred from _outdegree or _degree - unless tree knows which nodes are leaves and not nodes.
Phylo.API._isroot — Function_isroot(tree::AbstractTree, node)Is the node a root node of the tree?
Phylo.API._isunattached — Method_isunattached(tree::AbstractTree, node)Does the node currently form its own (sub)tree?
Phylo.API._leafinfotype — Function_leafinfotype(::Type{<:AbstractTree})Returns the type of the leaf info data.
Phylo.API._matchbranchnodetype — Function_matchbranchnodetype(::Type{<:AbstractTree},
::Type{<:AbstractBranch},
::Type{<:AbstractNode})Does this tree type prefer the branch and node types provided?
Phylo.API._matchbranchtype — Function_matchbranchtype(::Type{<:AbstractTree}, ::Type{<:AbstractBranch})Does this tree type prefer the branch or branch label type provided?
Phylo.API._matchnodetype — Function_matchnodetype(::Type{<:AbstractTree{TT, RT, NL, N, B}}, ::Type{N})
_matchnodetype(::Type{<:AbstractTree{TT, RT, NL, N, B}}, ::Type{NL})Does this tree type prefer the node or node label type provided?
Phylo.API._matchtreenametype — Method_matchtreenametype(::Type{<:AbstractTree}, ::Type{X})Does this tree type prefer the node or node label type provided?
Phylo.API._nbranches — Method_nbranches(::AbstractTree)Returns the number of branches in a single tree. May be implemented for any OneTree tree type (otherwise infers from _getbranches()).
Phylo.API._newbranchlabel — Function_newbranchlabel(tree::AbstractTree)Returns a new unique branch name for a tree.
Phylo.API._newnodelabel — Function_newnodelabel(tree::AbstractTree)Returns a new unique node name for a tree.
Phylo.API._nleaves — Method_nleaves(::AbstractTree)Returns the number of leaves (tips) in a tree. May be implemented for any tree type (otherwise determined from the _getleafnames() function).
Phylo.API._nnodes — Method_nnodes(::AbstractTree)Returns the number of nodes (internal nodes and leaves) in a single tree. May be implemented for any OneTree tree type (otherwise infers from _getnodes()).
Phylo.API._nodedatatype — Function_nodedatatype(::Type{<:AbstractTree})Returns the type of the node info data.
Phylo.API._nroots — Function_nroots(::AbstractTree)Returns the number of roots (subtrees) in a OneTree tree. May be implemented for any ManyRoots type (otherwise infers from _getroots()).
Phylo.API._ntrees — Function_ntrees(::AbstractTree)Returns the number of trees in an object. Must be implemented for any ManyTrees type.
Phylo.API._outdegree — Function_outdegree(tree::AbstractTree, node::AbstractNode)Out degree of node.
Phylo.API._preferbranchobjects — Function_preferbranchobjects(::Type{<:AbstractTree})Does this tree or branch type prefer branches to be objects or names? Must be implemented for every branch type.
Phylo.API._prefernodeobjects — Function_prefernodeobjects(::Type{<:AbstractTree})Does this tree or node type prefer nodes to be objects or names? Must be implemented for every node type.
Phylo.API._removeconnection! — Function_removeconnection!(tree::AbstractTree, node::AbstractNode, branch)Remove a connection from an unrooted node. Must be implemented for any Unrooted AbstractNode subtype unless this happens when a branch is deleted.
Phylo.API._removeinbound! — Function_removeinbound!(tree::AbstractTree, node::AbstractNode, inbound)Removes a branch from the input of a rooted node. Must be implemented for any rooted AbstractNode subtype unless this happens when a branch is deleted.
Phylo.API._removeoutbound! — Function_removeoutbound!(tree::AbstractTree, node::AbstractNode, branch)Remove an outbound branch from a rooted node. Must be implemented for any AbstractNode subtype unless this happens when a branch is deleted.
Phylo.API._renamenode! — Function_renamenode!(tree::AbstractTree, oldnode[name], newname)Renames a node in a tree. Optional - not implemented for most tree types.
Phylo.API._resetleaves! — Function_resetleaves!(::AbstractTree)Fixes leaf naming after creation or deletion of nodes or branches. Must be implemented by tree types where this is handled separately.
Phylo.API._setheight! — Method_setheight!(::AbstractTree, nodename, value)Phylo.API._setrootheight! — Function_setrootheight!(::AbstractTree, value)Phylo.API._src — Function_src(tree, branch)Return source node for a branch. Must be implemented for any rooted branch type.
Phylo.API._traversal — Function_traversal(tree::AbstractTree, order::TraversalOrder, todo, sofar)Return an iterable object containing nodes in given order - preorder, inorder, postorder or breadthfirst
Phylo.API._treenametype — Function_treenametype(::Type{AbstractTree})Returns the label type for a tree type. Must be implemented for any tree type.
Phylo.API._validate! — Function_validate!(::AbstractTree)Check whether the tree is internally valid.
Phylo.APIPhylo.PhyloPhylo.BinaryNodePhylo.BinaryTreePhylo.BranchPhylo.BranchIteratorPhylo.BranchNameIteratorPhylo.BrownianTraitPhylo.DiscreteTraitPhylo.LinkBranchPhylo.LinkNodePhylo.LinkTreePhylo.NamedBinaryTreePhylo.NamedPolytomousTreePhylo.NamedTreePhylo.NewickPhylo.NexusPhylo.NodePhylo.NodeIteratorPhylo.NodeNameIteratorPhylo.NonultrametricPhylo.PolytomousTreePhylo.RecursiveEltPhylo.RecursiveTreePhylo.SymmetricDiscreteTraitPhylo.TreeSetPhylo.UltrametricBase.sortBase.sort!Graphs.degreeGraphs.dstGraphs.indegreeGraphs.outdegreeGraphs.srcPhylo.API._addconnection!Phylo.API._addinbound!Phylo.API._addoutbound!Phylo.API._branchdatatypePhylo.API._branchdimsPhylo.API._clearrootheight!Phylo.API._connPhylo.API._connsPhylo.API._createbranch!Phylo.API._createnode!Phylo.API._degreePhylo.API._deletebranch!Phylo.API._deletenode!Phylo.API._dstPhylo.API._getbranchPhylo.API._getbranchesPhylo.API._getbranchnamePhylo.API._getbranchnamesPhylo.API._getchildrenPhylo.API._getconnectionsPhylo.API._getheightPhylo.API._getinboundPhylo.API._getleafnamesPhylo.API._getleavesPhylo.API._getlengthPhylo.API._getnodePhylo.API._getnodenamePhylo.API._getnodenamesPhylo.API._getnodesPhylo.API._getoutboundsPhylo.API._getparentPhylo.API._getrootPhylo.API._getrootheightPhylo.API._getrootsPhylo.API._getsiblingsPhylo.API._gettreePhylo.API._gettreeinfoPhylo.API._gettreenamePhylo.API._gettreenamesPhylo.API._gettreesPhylo.API._hasbranchPhylo.API._hasheightPhylo.API._hasinboundPhylo.API._hasinboundspacePhylo.API._haslengthPhylo.API._hasnodePhylo.API._hasoutboundspacePhylo.API._hasrootheightPhylo.API._hasspacePhylo.API._indegreePhylo.API._invalidate!Phylo.API._isinternalPhylo.API._isleafPhylo.API._isrootPhylo.API._isunattachedPhylo.API._leafinfotypePhylo.API._matchbranchnodetypePhylo.API._matchbranchtypePhylo.API._matchnodetypePhylo.API._matchtreenametypePhylo.API._nbranchesPhylo.API._newbranchlabelPhylo.API._newnodelabelPhylo.API._nleavesPhylo.API._nnodesPhylo.API._nodedatatypePhylo.API._nrootsPhylo.API._ntreesPhylo.API._outdegreePhylo.API._preferbranchobjectsPhylo.API._prefernodeobjectsPhylo.API._removeconnection!Phylo.API._removeinbound!Phylo.API._removeoutbound!Phylo.API._renamenode!Phylo.API._resetleaves!Phylo.API._setheight!Phylo.API._setrootheight!Phylo.API._srcPhylo.API._traversalPhylo.API._treenametypePhylo.API._validate!Phylo.branchdatatypePhylo.branchdimsPhylo.branchfilterPhylo.branchfuturePhylo.branchhistoryPhylo.branchiterPhylo.branchnamefilterPhylo.branchnameiterPhylo.branchnametypePhylo.branchroutePhylo.branchtypePhylo.connPhylo.connsPhylo.createbranch!Phylo.createnode!Phylo.createnodes!Phylo.deletebranch!Phylo.deletenode!Phylo.distancePhylo.distancesPhylo.droptips!Phylo.getancestorsPhylo.getbranchPhylo.getbranchdataPhylo.getbranchesPhylo.getbranchnamePhylo.getbranchnamesPhylo.getchildrenPhylo.getconnectionsPhylo.getdescendantsPhylo.getheightPhylo.getinboundPhylo.getinternalnodesPhylo.getleafinfoPhylo.getleafnamesPhylo.getleavesPhylo.getlengthPhylo.getnodePhylo.getnodedataPhylo.getnodenamePhylo.getnodenamesPhylo.getnodesPhylo.getoutboundsPhylo.getparentPhylo.getrootPhylo.getrootheightPhylo.getrootsPhylo.getsiblingsPhylo.gettreePhylo.gettreeinfoPhylo.gettreenamePhylo.gettreenamesPhylo.gettreesPhylo.hasbranchPhylo.hasheightPhylo.hasinboundPhylo.hasinboundspacePhylo.haslengthPhylo.hasnodePhylo.hasoutboundspacePhylo.hasrootheightPhylo.heightstorootPhylo.heighttorootPhylo.invalidate!Phylo.isinternalPhylo.isleafPhylo.isrootPhylo.isunattachedPhylo.keeptips!Phylo.leafinfotypePhylo.map_depthfirstPhylo.mrcaPhylo.nbranchesPhylo.ninternalPhylo.nleavesPhylo.nnodesPhylo.nodedatatypePhylo.nodefilterPhylo.nodefuturePhylo.nodeheightsPhylo.nodehistoryPhylo.nodeiterPhylo.nodenamefilterPhylo.nodenameiterPhylo.nodenametypePhylo.noderoutePhylo.nodetypePhylo.nrootsPhylo.ntreesPhylo.parsenewickPhylo.parsenexusPhylo.renamenode!Phylo.roottypePhylo.setbranchdata!Phylo.setheight!Phylo.setleafinfo!Phylo.setnodedata!Phylo.setrootheight!Phylo.traversalPhylo.treenametypePhylo.treesettypePhylo.treetypePhylo.validate!