Class: ViennaRna::Package::Subopt

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

Instance Attribute Summary collapse

Attributes inherited from Base

#data, #response, #runtime

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

This class inherits a constructor from ViennaRna::Package::Base

Instance Attribute Details

#structuresObject (readonly)

Returns the value of attribute structures.



4
5
6
# File 'lib/vienna_rna/package/subopt.rb', line 4

def structures
  @structures
end

Instance Method Details

#bin(count = 1) ⇒ Object



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

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



6
7
8
# File 'lib/vienna_rna/package/subopt.rb', line 6

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