class Bio::Tree::Node
Public Instance Methods
alignment()
click to toggle source
Return the alignment attached to the tree
# File lib/bio-alignment/tree.rb, line 109 def alignment @alignment end
children()
click to toggle source
Get the children of this Node
# File lib/bio-alignment/tree.rb, line 54 def children @tree.children(self) end
descendents()
click to toggle source
# File lib/bio-alignment/tree.rb, line 58 def descendents @tree.descendents(self) end
distance(other)
click to toggle source
Get the distance to another node
# File lib/bio-alignment/tree.rb, line 84 def distance other @tree.distance(self,other) end
inject_tree(tree, alignment)
click to toggle source
Add tree information to this node, so it can be queried
# File lib/bio-alignment/tree.rb, line 41 def inject_tree tree, alignment @tree = tree @tree.freeze @alignment = alignment self end
leaf?()
click to toggle source
Is this Node
a leaf?
# File lib/bio-alignment/tree.rb, line 49 def leaf? children.size == 0 end
leaves()
click to toggle source
Return the leaves of this node
# File lib/bio-alignment/tree.rb, line 73 def leaves @tree.leaves(self) end
nearest()
click to toggle source
Find the nearest and dearest, i.e. the leafs attached to the parent node
# File lib/bio-alignment/tree.rb, line 79 def nearest @tree.leaves(parent) - [self] end
nearest_child()
click to toggle source
Get child node with the shortest edge - note that if there are more than one, the first will be picked
# File lib/bio-alignment/tree.rb, line 90 def nearest_child c = nil children.each do |n| c=n if not c or distance(n)<distance(c) end c end
nearest_children()
click to toggle source
Get the child nodes with the shortest edge - returns an Array
# File lib/bio-alignment/tree.rb, line 99 def nearest_children min_distance = distance(nearest_child) cs = [] children.each do |n| cs << n if distance(n) == min_distance end cs end
parent()
click to toggle source
Get the parents of this Node
# File lib/bio-alignment/tree.rb, line 63 def parent @tree.parent(self) end
sequence()
click to toggle source
# File lib/bio-alignment/tree.rb, line 113 def sequence @alignment.find(name) end
siblings()
click to toggle source
Get the direct sibling nodes (i.e. parent.children)
# File lib/bio-alignment/tree.rb, line 68 def siblings parent.children - [self] end