Sha256: 8449ef6e941da55adf8f74597a3955fd4ddb37e2bccebe6e70614cc08ddc5a17

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 Bytes

Contents

module Egor
  class Environment

    attr_accessor :amino_acids,
      :number,
      :label,
      :freq_array,
      :prob_array,
      :logo_array,
      :smooth_prob_array

    def initialize(number, label, amino_acids = "ACDEFGHIKLMNPQRSTVWYJ".split(''))
      @amino_acids        = amino_acids
      @number             = number
      @label              = label
      @freq_array         = $noweight ? NArray.int(@amino_acids.size) : NArray.float(@amino_acids.size)
      @prob_array         = NArray.float(@amino_acids.size)
      @logo_array         = NArray.float(@amino_acids.size)
      @smooth_prob_array  = NArray.float(@amino_acids.size)
    end

    def increase_residue_count(a, inc = 1.0)
      @freq_array[@amino_acids.index(a.upcase)] += inc
    end

    def label_set
      label.split("").map_with_index { |l, i| "#{i}#{l}" }.to_set
    end

    def to_s
      "#{number}-#{label}"
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
semin-egor-0.9.0 lib/egor/environment.rb
semin-egor-0.9.1 lib/egor/environment.rb
semin-egor-0.9.2 lib/egor/environment.rb
semin-egor-0.9.3 lib/egor/environment.rb
egor-0.9.0 lib/egor/environment.rb