Class: Wrnap::Package::Rnabor

Inherits:
Xbor
  • Object
show all
Defined in:
lib/wrnap/package/rnabor.rb

Constant Summary collapse

FLAGS =
{
  nodangle: :empty
}

Instance Attribute Summary

Attributes inherited from Base

#data, #flags, #response, #runtime

Instance Method Summary collapse

Methods inherited from Xbor

#expected_k, #full_distribution, #inspect, #k_p_points, parse, #quick_plot, #run_command, #to_csv, #to_csv!

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 Method Details

#countsObject



16
17
18
# File 'lib/wrnap/package/rnabor.rb', line 16

def counts
  (non_zero_counts = self.class.parse(response).map { |row| BigDecimal.new(row[2]).to_i }) + [0] * (data.len - non_zero_counts.length + 1)
end

#distribution(options = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/wrnap/package/rnabor.rb', line 20

def distribution(options = {})
  options = { precision: 4 }.merge(options)

  distribution_before_precision = (non_zero_distribution = non_zero_shells.map { |i| i / partition }) + [0.0] * (data.len - non_zero_distribution.length + 1)
  distribution_before_precision.map { |value| options[:precision].zero? ? value : (value * 10 ** options[:precision]).truncate / 10.0 ** options[:precision] }
end

#non_zero_shellsObject



27
28
29
# File 'lib/wrnap/package/rnabor.rb', line 27

def non_zero_shells
  self.class.parse(response).map { |row| BigDecimal.new(row[1]) }
end

#partitionObject



8
9
10
# File 'lib/wrnap/package/rnabor.rb', line 8

def partition
  non_zero_shells.inject(&:+)
end

#total_countObject



12
13
14
# File 'lib/wrnap/package/rnabor.rb', line 12

def total_count
  counts.inject(&:+)
end