Documentation ¶
Overview ¶
Package tree implements tree structure and newick parsing.
Index ¶
- func IsSpecial(c rune) bool
- func NewickSplit(data []byte, atEOF bool) (advance int, token []byte, err error)
- type Mode
- type Node
- func (node *Node) AddChild(subNode *Node)
- func (node *Node) BrString() (s string)
- func (node *Node) ChildNodes() []*Node
- func (node *Node) ClassString() (s string)
- func (node *Node) Copy() *Node
- func (node *Node) FullString() string
- func (node *Node) IsRoot() bool
- func (node *Node) IsTerminal() bool
- func (node *Node) LongString() (s string)
- func (node *Node) NSubNodes() (size int)
- func (node *Node) ShortClassString() (s string)
- func (node *Node) String() (s string)
- func (node *Node) Walk(ch chan *Node, filter func(*Node) bool)
- type Tree
- func (tree *Tree) ClassNodes(class int) <-chan *Node
- func (tree *Tree) ClearCache()
- func (tree *Tree) Copy() (newTree *Tree)
- func (tree *Tree) IsRooted() bool
- func (tree *Tree) MaxNodeID() (maxID int)
- func (tree *Tree) NLeaves() (i int)
- func (tree *Tree) NNodes() int
- func (tree *Tree) NodeIDArray() []*Node
- func (tree *Tree) NodeOrder() []*Node
- func (tree *Tree) NonTerminals() <-chan *Node
- func (tree *Tree) Root(branchID int) error
- func (tree *Tree) Terminals() <-chan *Node
- func (tree *Tree) Unroot() (int, error)
- func (tree *Tree) Walker(filter func(*Node) bool) <-chan *Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
type Node struct { // Name is the node label. Name string // BranchLength is the length of the branch going to the node. BranchLength float64 // Parent is the parent node (nil for the root). Parent *Node // Id is the node ID. ID int // LeafId is the leaf id. LeafID int // Class is a node class (specified by # symbol in newick). Class int // contains filtered or unexported fields }
Node is a node of a tree.
func (*Node) BrString ¶
BrString returns a newick string with branch labels for a node and its' subnodes.
func (*Node) ChildNodes ¶
ChildNodes returns a children nodes slice.
func (*Node) ClassString ¶
ClassString returns a newick string with class labels for a node and its' subnodes.
func (*Node) FullString ¶
FullString returns extended string for the whole tree.
func (*Node) IsTerminal ¶
IsTerminal returns true if node is a leaf.
func (*Node) LongString ¶
LongString returns an extended string with all the ids, classes, etc for one node.
func (*Node) ShortClassString ¶
ShortClassString returns a newick string with class labels for a node and its' subnodes without branch lengths.
type Tree ¶
type Tree struct { // Node is the root node. *Node // contains filtered or unexported fields }
Tree is a tree structure.
func ParseNewick ¶
ParseNewick parses a newick formatted reader into the Tree type.
func (*Tree) ClassNodes ¶
ClassNodes returns a channel with all the nodes of a given class.
func (*Tree) ClearCache ¶
func (tree *Tree) ClearCache()
ClearCache clears all precomputed parameters.
func (*Tree) NodeIDArray ¶
NodeIDArray returns an array (slice). This array allows addressing nodes by their ids.
func (*Tree) NonTerminals ¶
NonTerminals returns a channel with all the non-terminal nodes of a tree.