<commit_before>require_relative '../support'
require_relative '../data_models'

module Bioinform
  class PCM < PM
    def count
      matrix.first.inject(&:+)
    end

    def to_pcm
      self
    end

    def to_pwm(pseudocount = Math.log(count))
      mat = each_position.map do |pos|
        pos.each_index.map do |ind|
          Math.log((pos[ind] + probability[ind] * pseudocount) / (probability[ind]*(count + pseudocount)) )
        end
      end
      PWM.new(matrix: mat, name: name, tags: tags, background: background)
    end

    def to_ppm
      mat = each_position.map{|pos| pos.map{|el| el.to_f / count }}
      PPM.new(get_parameters.merge(matrix: mat))
    end
  end
end<commit_msg>fix error<commit_after>require_relative '../support'
require_relative '../data_models'

module Bioinform
  class PCM < PM
    def count
      matrix.first.inject(&:+)
    end

    def to_pcm
      self
    end

    def to_pwm(pseudocount = Math.log(count))
      mat = each_position.map do |pos|
        pos.each_index.map do |ind|
          Math.log((pos[ind] + probability[ind] * pseudocount) / (probability[ind]*(count + pseudocount)) )
        end
      end
      PWM.new(get_parameters.merge(matrix: mat))
    end

    def to_ppm
      mat = each_position.map{|pos| pos.map{|el| el.to_f / count }}
      PPM.new(get_parameters.merge(matrix: mat))
    end
  end
end
{'fraction_non_alphanumeric': 0.12207602339181287, 'fraction_numerical': 0.0, 'mean_word_length': 2.555844155844156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6937822', 'n_tokens_mistral': 478, 'n_tokens_neox': 459, 'n_words': 104}