Class: BioDSL::Taxonomy::Index::TaxNode

Inherits:
Object
  • Object
show all
Defined in:
lib/BioDSL/taxonomy.rb

Overview

Class for the nodes used for constructing the taxonomic tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenObject (readonly)

Returns the value of attribute children.



255
256
257
# File 'lib/BioDSL/taxonomy.rb', line 255

def children
  @children
end

#kmersObject

Returns the value of attribute kmers.



254
255
256
# File 'lib/BioDSL/taxonomy.rb', line 254

def kmers
  @kmers
end

#levelObject (readonly)

Returns the value of attribute level.



255
256
257
# File 'lib/BioDSL/taxonomy.rb', line 255

def level
  @level
end

#nameObject (readonly)

Returns the value of attribute name.



255
256
257
# File 'lib/BioDSL/taxonomy.rb', line 255

def name
  @name
end

#node_idObject (readonly)

Returns the value of attribute node_id.



255
256
257
# File 'lib/BioDSL/taxonomy.rb', line 255

def node_id
  @node_id
end

#parentObject (readonly)

Returns the value of attribute parent.



255
256
257
# File 'lib/BioDSL/taxonomy.rb', line 255

def parent
  @parent
end

#seq_idObject (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_idsObject

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_idObject

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