Class: Bioinform::ConversionAlgorithms::PPM2PCMConverter
- Inherits:
-
Object
- Object
- Bioinform::ConversionAlgorithms::PPM2PCMConverter
- Defined in:
- lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #convert(ppm) ⇒ Object
-
#initialize(options = {}) ⇒ PPM2PCMConverter
constructor
A new instance of PPM2PCMConverter.
Constructor Details
#initialize(options = {}) ⇒ PPM2PCMConverter
Returns a new instance of PPM2PCMConverter.
9 10 11 |
# File 'lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb', line 9 def initialize( = {}) @count = .fetch(:count, 100) end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
7 8 9 |
# File 'lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb', line 7 def count @count end |
Instance Method Details
#convert(ppm) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb', line 13 def convert(ppm) raise Error, "#{self.class}#convert accepts only models acting as PPM" unless MotifModel.acts_as_ppm?(ppm) matrix = ppm.each_position.map do |pos| pos.map do |el| el * @count end end pcm = MotifModel::PCM.new(matrix) if ppm.respond_to? :name pcm.named(ppm.name) else pcm end end |