Class: Bioinform::ConversionAlgorithms::PCM2PPMConverter
- Inherits:
-
Object
- Object
- Bioinform::ConversionAlgorithms::PCM2PPMConverter
- Defined in:
- lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb
Instance Method Summary collapse
Instance Method Details
#convert(pcm) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb', line 6 def convert(pcm) raise Error, "#{self.class}#convert accepts only models acting as PCM" unless MotifModel.acts_as_pcm?(pcm) matrix = pcm.each_position.map do |pos| count = pos.inject(0.0, &:+) pos.map {|el| el / count } end ppm = MotifModel::PPM.new(matrix) if pcm.respond_to? :name ppm.named(pcm.name) else ppm end end |