Class: Bioinform::MotifModel::PCM
- Defined in:
- lib/bioinform/data_models/pcm.rb
Instance Attribute Summary
Attributes inherited from PM
Instance Method Summary collapse
Methods inherited from PM
#==, #complemented, #each_position, from_file, from_string, #initialize, #length, #named, #reverse_complemented, #reversed, #to_s
Constructor Details
This class inherits a constructor from Bioinform::MotifModel::PM
Instance Method Details
#count ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/bioinform/data_models/pcm.rb', line 16 def count counts = each_position.map{|pos| pos.inject(0.0, &:+)} count = counts.first diffs = counts.map{|pos_count| (pos_count - count).abs } counts_are_same = (diffs.max < count * 1e-3) raise Error, 'Different columns have different count' unless counts_are_same count end |
#validation_errors ⇒ Object
10 11 12 13 14 |
# File 'lib/bioinform/data_models/pcm.rb', line 10 def validation_errors errors = super errors << "elements of PCM should be non-negative" unless matrix.all?{|pos| pos.all?{|el| el >= 0 } } errors end |