Class: Wrnap::Package::Subopt

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

Instance Attribute Summary collapse

Attributes inherited from Base

#data, #flags, #response, #runtime

Instance Method Summary collapse

Methods inherited from Base

bootstrap, #debugger, #initialize, #inspect

Methods included from Global::Yaml

#deserialize, #serialize

Methods included from Global::Chainer

included

Methods included from Global::Runner

included

Constructor Details

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

Instance Attribute Details

#structuresObject (readonly)

Returns the value of attribute structures.



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

def structures
  @structures
end

Instance Method Details

#bin(count = 1) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/wrnap/package/subopt.rb', line 17

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
9
10
11
12
13
14
15
# File 'lib/wrnap/package/subopt.rb', line 6

def post_process
  @structures = response.split(/\n/)[1..-1].map do |output|
    structure, mfe = output.split(/\s+/)

    RNA.from_string(data.seq, structure).tap do |rna|
      rna.instance_variable_set(:@mfe, mfe.to_f)
      rna.class_eval { attr_reader :mfe }
    end
  end
end