Class: ViennaRna::Subopt

Inherits:
Base
  • Object
show all
Defined in:
lib/vienna_rna/modules/subopt.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#data, #response, #runtime

Instance Method Summary collapse

Methods inherited from Base

batch, bootstrap, #debugger, debugger, exec_exists?, #exec_name, #exec_sequence_format, #initialize, method_added, #pre_run_check, run, #run, #run_with_hooks, #stringify_flags

Constructor Details

This class inherits a constructor from ViennaRna::Base

Instance Attribute Details

#structuresObject (readonly)

Returns the value of attribute structures.



3
4
5
# File 'lib/vienna_rna/modules/subopt.rb', line 3

def structures
  @structures
end

Instance Method Details

#bin(count = 1) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/vienna_rna/modules/subopt.rb', line 9

def bin(count = 1)
  run(p: count).structures.inject(Hash.new { |hash, key| hash[key] = 0 }) do |hash, structure|
    hash.tap do
      hash[structure] += 1
    end
  end
end

#post_processObject



5
6
7
# File 'lib/vienna_rna/modules/subopt.rb', line 5

def post_process
  @structures = @response.split(/\n/)[1..-1].map { |output| Rna.init_from_string(data.seq, output.split(/\s+/).first) }
end