Documentation
¶
Overview ¶
Package gotree implements a simple library for handling phylogenetic trees in go
Index ¶
- func CommonEdges(edges1 []*Edge, edges2 []*Edge, tipEdges bool) (tree1 int, common int, err error)
- func NewNodeIndex(t *Tree) *nodeIndex
- type Bucket
- type Edge
- func (e *Edge) Bitset() *bitset.BitSet
- func (e *Edge) DumpBitSet() string
- func (e *Edge) FindEdge(edges []*Edge) (*Edge, error)
- func (e *Edge) Id() int
- func (e *Edge) Left() *Node
- func (e *Edge) Length() float64
- func (e *Edge) NumTips() uint
- func (e *Edge) Right() *Node
- func (e *Edge) SameBipartition(e2 *Edge) bool
- func (e *Edge) SetId(id int)
- func (e *Edge) SetLength(length float64)
- func (e *Edge) SetSupport(support float64)
- func (e *Edge) Support() float64
- func (e *Edge) TipPresent(id uint) bool
- func (e *Edge) TopoDepth() (int, error)
- type EdgeIndex
- type KeyValue
- type Node
- func (n *Node) AddComment(comment string)
- func (n *Node) Depth() (int, error)
- func (n *Node) EdgeIndex(e *Edge) (int, error)
- func (n *Node) Edges() []*Edge
- func (n *Node) Name() string
- func (n *Node) Neigh() []*Node
- func (n *Node) Newick(parent *Node, newick *bytes.Buffer)
- func (n *Node) Nneigh() int
- func (n *Node) NodeIndex(next *Node) (int, error)
- func (n *Node) Parent() (*Node, error)
- func (n *Node) ParentEdge() (*Edge, error)
- func (n *Node) SetDepth(depth int)
- func (n *Node) SetName(name string)
- func (n *Node) Tip() bool
- type NodeIndex
- type Tree
- func (t *Tree) AllTipNames() []string
- func (t *Tree) ClearBitSets() error
- func (t *Tree) CollapseShortBranches(length float64)
- func (t *Tree) CommonEdges(t2 *Tree, tipEdges bool) (tree1 int, common int, err error)
- func (t *Tree) CompareTipIndexes(t2 *Tree) error
- func (t *Tree) ComputeDepths()
- func (t *Tree) ConnectNodes(parent *Node, child *Node) *Edge
- func (t *Tree) Edges() []*Edge
- func (t *Tree) ExistsTip(name string) (bool, error)
- func (t *Tree) GraftTipOnEdge(n *Node, e *Edge) (*Edge, *Edge, *Node, error)
- func (t *Tree) MeanBrLength() float64
- func (t *Tree) MeanSupport() float64
- func (t *Tree) MedianSupport() float64
- func (t *Tree) NbTips() (int, error)
- func (t *Tree) NewEdge() *Edge
- func (t *Tree) NewNode() *Node
- func (t *Tree) Newick() string
- func (t *Tree) Nodes() []*Node
- func (t *Tree) RemoveEdges(edges ...*Edge)
- func (t *Tree) RemoveTips(names ...string) error
- func (t *Tree) Rename(namemap map[string]string) error
- func (t *Tree) Reroot(n *Node) error
- func (t *Tree) RerootFirst() error
- func (t *Tree) Root() *Node
- func (t *Tree) Rooted() bool
- func (t *Tree) SetRoot(r *Node)
- func (t *Tree) ShuffleTips()
- func (t *Tree) String() string
- func (t *Tree) SumBranchLengths() float64
- func (t *Tree) TipEdges() []*Edge
- func (t *Tree) TipIndex(name string) (uint, error)
- func (t *Tree) Tips() []*Node
- func (t *Tree) UnRoot()
- func (t *Tree) UpdateBitSet() error
- func (t *Tree) UpdateTipIndex()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommonEdges ¶
This function compares 2 trees and output the number of edges in common It does not check if the trees have different sets of tip names, but just compare the bitsets If applied on two tree with the same number of tips with different names, it will give results anyway It assumes that functions
tree.UpdateTipIndex() tree.ClearBitSets() tree.UpdateBitSet()
If tipedges is false: does not take into account tip edges Have been called before, otherwise will output an error
func NewNodeIndex ¶
func NewNodeIndex(t *Tree) *nodeIndex
Types ¶
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
func (*Edge) DumpBitSet ¶
func (*Edge) FindEdge ¶
Return the given edge in the array of edges comparing bitsets fields Return nil if not found
func (*Edge) SameBipartition ¶
func (*Edge) SetSupport ¶
func (*Edge) TipPresent ¶
Tests wether the tip with index id in the bitset is Set or not The index corresponds to tree.Tipindex(tipname)
type EdgeIndex ¶
func NewEdgeIndex ¶
Initializes an Edge Count Index
func (*EdgeIndex) AddEdgeCount ¶
Increment edge count for an edge if it already exists in the map Otherwise adds it with count 1
func (*EdgeIndex) PutEdgeValue ¶
Adds the edge in the map, with given value If the edge already exists in the index The old value is erased
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) AddComment ¶
func (*Node) Parent ¶
Retrieve the parent node If several parents: Error Parent is defined as the node n2 connected to n by an edge e with e.left == n2 and e.right == n
func (*Node) ParentEdge ¶
Retrieve the Edge going to Parent node If several parents: Error Parent is defined as the node n2 connected to n by an edge e with e.left == n2 and e.right == n
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func RandomBinaryTree ¶
Creates a Random Binary tree nbtips : Number of tips of the random binary tree to create
func (*Tree) AllTipNames ¶
Returns all the tip name in the tree Starts with n==nil (root)
func (*Tree) ClearBitSets ¶
func (*Tree) CollapseShortBranches ¶
func (*Tree) CommonEdges ¶
This function compares 2 trees and output the number of edges in common If the trees have different sets of tip names, returns an error It assumes that functions
tree.UpdateTipIndex() tree.ClearBitSets() tree.UpdateBitSet()
If tipedges is false: does not take into account tip edges Have been called before, otherwise will output an error
func (*Tree) CompareTipIndexes ¶
This function compares the tip name indexes of 2 trees If the tipindexes have the same size (!=0) and have the same set of tip names, The returns nil, otherwise returns an error
func (*Tree) ComputeDepths ¶
func (t *Tree) ComputeDepths()
func (*Tree) ExistsTip ¶
Return true if the tip with given name exists in the tree May return an error if tip index has not been initialized With UpdateTipIndex
func (*Tree) GraftTipOnEdge ¶
This function graft the Node n at the middle of the Edge e It divides the branch lenght by 2 It returns the added edges and the added nodes
func (*Tree) MeanBrLength ¶
func (*Tree) MeanSupport ¶
func (*Tree) MedianSupport ¶
func (*Tree) RemoveEdges ¶
Removes branches from the tree if they are not tip edges And if they do not connects the root of a rooted tree Merges the 2 nodes and creates multifurcations At the end, bitsets should not need to be updated
func (*Tree) RemoveTips ¶
Removes a set of tips from the tree, from tip names
func (*Tree) Rename ¶
This function renames nodes of the tree based on the map in argument If a name in the map does not exist in the tree, then returns an error If a node/tip in the tree does not have a name in the map: OK After rename, tip index is updated, as well as bitsets of the edges
func (*Tree) Reroot ¶
This function takes a node and reroot the tree on that node It reorients edges left-edge-right : see ReorderEdges The node must be one of the tree nodes, otherwise it returns an error
func (*Tree) RerootFirst ¶
This function takes the first node having 3 neighbors and reroot the tree on this node
func (*Tree) ShuffleTips ¶
func (t *Tree) ShuffleTips()
This function shuffles the tips of the tree and recompute tipindex and bitsets
func (*Tree) SumBranchLengths ¶
func (*Tree) TipIndex ¶
Return the tip index if the tip with given name exists in the tree May return an error if tip index has not been initialized With UpdateTipIndex or if the tip does not exist
func (*Tree) UpdateBitSet ¶
Updates bitsets of all edges in the tree Assumes that the hashmap tip name : index is initialized with UpdateTipIndex function
func (*Tree) UpdateTipIndex ¶
func (t *Tree) UpdateTipIndex()
Updates the tipindex which maps tip names To index in the bitsets Bitset indexes correspond to the position of the tip in the alphabetically ordered tip name list