Sha256: 1cd3d87ffa077d099b7138ddea4d740e9e1893e2da3fd7a6e896861a2e840c75

Contents?: true

Size: 1001 Bytes

Versions: 6

Compression:

Stored size: 1001 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("").map_with_index { |l, i| "#{i}#{l}" }.to_set
      else
        label.gsub('-', '').split("").map_with_index { |l, i| "#{i}#{l}" }.to_set
      end
    end

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
semin-ulla-0.9.7 lib/ulla/environment.rb
semin-ulla-0.9.8 lib/ulla/environment.rb
semin-ulla-0.9.9 lib/ulla/environment.rb
ulla-0.9.9 lib/ulla/environment.rb
ulla-0.9.8 lib/ulla/environment.rb
ulla-0.9.7 lib/ulla/environment.rb