Class: BioDSL::Taxonomy::Search::TaxPath
- Inherits:
-
Object
- Object
- BioDSL::Taxonomy::Search::TaxPath
- Defined in:
- lib/BioDSL/taxonomy.rb
Overview
Class holding methods for manipulating tanomic paths.
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(node_id, kmers_observed, kmers_total, tax_index) ⇒ TaxPath
constructor
Constructor method for TaxPath objects.
-
#taxonomy_backtrack ⇒ Object
Method that returns a list of nodes for a given node_id and all parent ids up the taxonomy tree.
-
#to_s ⇒ Object
Returns formatted taxonomy string.
Constructor Details
#initialize(node_id, kmers_observed, kmers_total, tax_index) ⇒ TaxPath
Constructor method for TaxPath objects.
652 653 654 655 656 657 658 |
# 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 |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
649 650 651 |
# File 'lib/BioDSL/taxonomy.rb', line 649 def nodes @nodes end |
Instance Method Details
#taxonomy_backtrack ⇒ Object
Method that returns a list of nodes for a given node_id and all parent ids up the taxonomy tree.
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
# 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 ⇒ Object
Returns formatted taxonomy string.
679 680 681 682 683 684 685 686 687 |
# 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 |