Class: TreeClusters::Clade
- Inherits:
-
Object
- Object
- TreeClusters::Clade
- Defined in:
- lib/tree_clusters/clade.rb
Overview
Represents a clade in a NewickTree
Instance Attribute Summary collapse
-
#all_leaves ⇒ Object
Returns the value of attribute all_leaves.
-
#all_sibling_leaves ⇒ Object
Returns the value of attribute all_sibling_leaves.
-
#all_tags ⇒ Object
Returns the value of attribute all_tags.
-
#each_sibling_leaf_set ⇒ Object
Returns the value of attribute each_sibling_leaf_set.
-
#left_leaves ⇒ Object
Returns the value of attribute left_leaves.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node ⇒ Object
Returns the value of attribute node.
-
#non_parent_leaves ⇒ Object
Returns the value of attribute non_parent_leaves.
-
#other_leaves ⇒ Object
Returns the value of attribute other_leaves.
-
#parent_leaves ⇒ Object
Returns the value of attribute parent_leaves.
-
#right_leaves ⇒ Object
Returns the value of attribute right_leaves.
-
#single_tag_info ⇒ Object
Returns the value of attribute single_tag_info.
Instance Method Summary collapse
-
#==(clade) ⇒ Object
Compares two Clades field by field.
-
#eql?(clade) ⇒ Boolean
Alias for ==.
-
#initialize(node, tree, metadata = nil) ⇒ Clade
constructor
A new instance of Clade.
Constructor Details
#initialize(node, tree, metadata = nil) ⇒ Clade
If a node name is quoted, then those quotes are removed first.
Returns a new instance of Clade.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tree_clusters/clade.rb', line 22 def initialize node, tree, = nil tree_taxa = tree.unquoted_taxa @node = node @name = unquote node.name @all_leaves = descendant_leaves node if (children = node.children).count == 2 lchild, rchild = node.children @left_leaves = descendant_leaves lchild @right_leaves = descendant_leaves rchild end siblings = node.siblings # assert siblings.count == 1, # "Node #{node.name} has more than one sibling." @each_sibling_leaf_set = siblings. map {|node| descendant_leaves node} @all_sibling_leaves = @each_sibling_leaf_set.flatten.uniq parent = node.parent assert parent, "Noge #{node.name} has no parent. Is it the root?" @parent_leaves = descendant_leaves parent @other_leaves = Object::Set.new(tree_taxa) - Object::Set.new(all_leaves) @non_parent_leaves = Object::Set.new(tree_taxa) - Object::Set.new(parent_leaves) if = ||= @single_tag_info ||= get_single_tag_info else @single_tag_info = nil end end |
Instance Attribute Details
#all_leaves ⇒ Object
Returns the value of attribute all_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def all_leaves @all_leaves end |
#all_sibling_leaves ⇒ Object
Returns the value of attribute all_sibling_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def all_sibling_leaves @all_sibling_leaves end |
#all_tags ⇒ Object
Returns the value of attribute all_tags.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def end |
#each_sibling_leaf_set ⇒ Object
Returns the value of attribute each_sibling_leaf_set.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def each_sibling_leaf_set @each_sibling_leaf_set end |
#left_leaves ⇒ Object
Returns the value of attribute left_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def left_leaves @left_leaves end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def name @name end |
#node ⇒ Object
Returns the value of attribute node.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def node @node end |
#non_parent_leaves ⇒ Object
Returns the value of attribute non_parent_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def non_parent_leaves @non_parent_leaves end |
#other_leaves ⇒ Object
Returns the value of attribute other_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def other_leaves @other_leaves end |
#parent_leaves ⇒ Object
Returns the value of attribute parent_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def parent_leaves @parent_leaves end |
#right_leaves ⇒ Object
Returns the value of attribute right_leaves.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def right_leaves @right_leaves end |
#single_tag_info ⇒ Object
Returns the value of attribute single_tag_info.
4 5 6 |
# File 'lib/tree_clusters/clade.rb', line 4 def single_tag_info @single_tag_info end |
Instance Method Details
#==(clade) ⇒ Object
Compares two Clades field by field.
If all instance variables are == than the two clades are == as well.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/tree_clusters/clade.rb', line 70 def == clade ( self.name == clade.name && self.all_leaves == clade.all_leaves && self.left_leaves == clade.left_leaves && self.right_leaves == clade.right_leaves && self.all_sibling_leaves == clade.all_sibling_leaves && self.each_sibling_leaf_set == clade.each_sibling_leaf_set && self.parent_leaves == clade.parent_leaves && self.other_leaves == clade.other_leaves && self.single_tag_info == clade.single_tag_info && self. == clade. ) end |
#eql?(clade) ⇒ Boolean
Alias for ==
86 87 88 |
# File 'lib/tree_clusters/clade.rb', line 86 def eql? clade self == clade end |