Class: BioDSL::Taxonomy::Index::TaxNode
- Inherits:
-
Object
- Object
- BioDSL::Taxonomy::Index::TaxNode
- Defined in:
- lib/BioDSL/taxonomy.rb
Overview
Class for the nodes used for constructing the taxonomic tree.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#kmers ⇒ Object
Returns the value of attribute kmers.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#seq_id ⇒ Object
readonly
Returns the value of attribute seq_id.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Getter method for node children.
-
#[]=(key, value) ⇒ Object
Setter method for node children.
-
#children_ids ⇒ Object
Returns an array of children node ids.
-
#initialize(parent, level, name, seq_id, node_id) ⇒ TaxNode
constructor
Constructor for TaxNode objects.
-
#parent_id ⇒ Object
Returns parent node id if a parent exist, else nil.
Constructor Details
#initialize(parent, level, name, seq_id, node_id) ⇒ TaxNode
Constructor for TaxNode objects.
258 259 260 261 262 263 264 265 266 |
# File 'lib/BioDSL/taxonomy.rb', line 258 def initialize(parent, level, name, seq_id, node_id) @parent = parent # Parent node. @level = level # Taxonomic level. @name = name # Taxonomic name. @kmers = Set.new # Kmer set. @seq_id = seq_id # Sequ id (a representative seq for debugging). @node_id = node_id # Node id. @children = {} # Child node hash. end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
255 256 257 |
# File 'lib/BioDSL/taxonomy.rb', line 255 def children @children end |
#kmers ⇒ Object
Returns the value of attribute kmers.
254 255 256 |
# File 'lib/BioDSL/taxonomy.rb', line 254 def kmers @kmers end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
255 256 257 |
# File 'lib/BioDSL/taxonomy.rb', line 255 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
255 256 257 |
# File 'lib/BioDSL/taxonomy.rb', line 255 def name @name end |
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
255 256 257 |
# File 'lib/BioDSL/taxonomy.rb', line 255 def node_id @node_id end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
255 256 257 |
# File 'lib/BioDSL/taxonomy.rb', line 255 def parent @parent end |
#seq_id ⇒ Object (readonly)
Returns the value of attribute seq_id.
255 256 257 |
# File 'lib/BioDSL/taxonomy.rb', line 255 def seq_id @seq_id end |
Instance Method Details
#[](key) ⇒ Object
Getter method for node children.
283 284 285 |
# File 'lib/BioDSL/taxonomy.rb', line 283 def [](key) @children[key] end |
#[]=(key, value) ⇒ Object
Setter method for node children.
288 289 290 |
# File 'lib/BioDSL/taxonomy.rb', line 288 def []=(key, value) @children[key] = value end |
#children_ids ⇒ Object
Returns an array of children node ids.
274 275 276 277 278 279 280 |
# File 'lib/BioDSL/taxonomy.rb', line 274 def children_ids ids = [] @children.each_value { |child| ids << child.id } ids end |
#parent_id ⇒ Object
Returns parent node id if a parent exist, else nil.
269 270 271 |
# File 'lib/BioDSL/taxonomy.rb', line 269 def parent_id @parent.node_id if @parent end |