Class: Bioinform::Frequencies
- Inherits:
-
Object
- Object
- Bioinform::Frequencies
- Includes:
- Background, FrequencyCalculations
- Defined in:
- lib/bioinform/background.rb
Constant Summary
Constants included from Background
Background::Uniform, Background::Wordwise
Instance Attribute Summary collapse
-
#frequencies ⇒ Object
readonly
Returns the value of attribute frequencies.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #counts ⇒ Object
-
#initialize(frequencies) ⇒ Frequencies
constructor
A new instance of Frequencies.
- #to_s ⇒ Object
- #volume ⇒ Object
- #wordwise? ⇒ Boolean
Methods included from Background
from_frequencies, from_gc_content, from_string, uniform, wordwise
Methods included from FrequencyCalculations
#mean, #mean_square, #symmetric?
Constructor Details
#initialize(frequencies) ⇒ Frequencies
Returns a new instance of Frequencies.
51 52 53 54 55 56 |
# File 'lib/bioinform/background.rb', line 51 def initialize(frequencies) @frequencies = frequencies raise Error, 'Frequencies should have 4 components' unless frequencies.length == 4 raise Error, 'Frequencies should be in [0;1]' unless frequencies.all?{|el| (0..1).include?(el) } raise Error, 'Sum of Background frequencies should be equal to 1' unless (frequencies.inject(0.0, &:+) - 1.0).abs < 1e-4 end |
Instance Attribute Details
#frequencies ⇒ Object (readonly)
Returns the value of attribute frequencies.
58 59 60 |
# File 'lib/bioinform/background.rb', line 58 def frequencies @frequencies end |
Instance Method Details
#==(other) ⇒ Object
64 65 66 |
# File 'lib/bioinform/background.rb', line 64 def ==(other) self.class == other.class && frequencies == other.frequencies end |
#counts ⇒ Object
59 |
# File 'lib/bioinform/background.rb', line 59 def counts; frequencies; end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/bioinform/background.rb', line 68 def to_s counts.join(',') end |
#volume ⇒ Object
60 |
# File 'lib/bioinform/background.rb', line 60 def volume; 1; end |
#wordwise? ⇒ Boolean
61 |
# File 'lib/bioinform/background.rb', line 61 def wordwise?; false; end |