class BioDSL::Taxonomy::Search::TaxPath

Class holding methods for manipulating tanomic paths.

Attributes

nodes[R]

Public Class Methods

new(node_id, kmers_observed, kmers_total, tax_index) click to toggle source

Constructor method for TaxPath objects.

# File lib/BioDSL/taxonomy.rb, line 652
def initialize(node_id, kmers_observed, kmers_total, tax_index)
  @node_id        = node_id
  @kmers_observed = kmers_observed
  @kmers_total    = kmers_total
  @tax_index      = tax_index
  @nodes          = taxonomy_backtrack
end

Public Instance Methods

taxonomy_backtrack() click to toggle source

Method that returns a list of nodes for a given node_id and all parent ids up the taxonomy tree.

# File lib/BioDSL/taxonomy.rb, line 662
def taxonomy_backtrack
  nodes = []

  node_id = @node_id

  while (node = @tax_index[node_id])
    nodes << node

    break if node.level == :r # At root level

    node_id = node.parent_id
  end

  nodes.reverse
end
to_s() click to toggle source

Returns formatted taxonomy string.

# File lib/BioDSL/taxonomy.rb, line 679
def to_s
  levels = []

  @nodes[1..-1].each do |node|
    levels << "#{node.level.upcase}##{node.name}"
  end

  levels.join(';')
end