Sha256: ba6c0487ea9c5aa8ff8ca97819b42d0cf09811ec9cec4cc46ca49837d4917bd5

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

module Ulla
  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(''))
      @number             = number
      @label              = label
      @amino_acids        = amino_acids
      @freq_array         = 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)] += inc
    end

    def label_set
      if $direction == 0
        label.split("").each_with_index.map { |l, i| "#{i}#{l}" }.to_set
      else
        label.gsub('-', '').split("").each_with_index.map { |l, i| "#{i}#{l}" }.to_set
      end
    end

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
ulla-0.9.9.2 lib/ulla/environment.rb
semin-ulla-0.9.9.1 lib/ulla/environment.rb
ulla-0.9.9.1 lib/ulla/environment.rb