Class: Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, label, amino_acids = "ACDEFGHIKLMNPQRSTVWYJ".split('')) ⇒ Environment

Returns a new instance of Environment.



16
17
18
19
20
21
22
23
24
# File 'lib/environment.rb', line 16

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)
  @logodd_array       = NArray.float(@amino_acids.size)
  @smooth_prob_array  = NArray.float(@amino_acids.size)
end

Instance Attribute Details

#amino_acidsObject

Returns the value of attribute amino_acids.



8
9
10
# File 'lib/environment.rb', line 8

def amino_acids
  @amino_acids
end

#freq_arrayObject

Returns the value of attribute freq_array.



8
9
10
# File 'lib/environment.rb', line 8

def freq_array
  @freq_array
end

#labelObject

Returns the value of attribute label.



8
9
10
# File 'lib/environment.rb', line 8

def label
  @label
end

#logodd_arrayObject

Returns the value of attribute logodd_array.



8
9
10
# File 'lib/environment.rb', line 8

def logodd_array
  @logodd_array
end

#numberObject

Returns the value of attribute number.



8
9
10
# File 'lib/environment.rb', line 8

def number
  @number
end

#prob_arrayObject

Returns the value of attribute prob_array.



8
9
10
# File 'lib/environment.rb', line 8

def prob_array
  @prob_array
end

#smooth_prob_arrayObject

Returns the value of attribute smooth_prob_array.



8
9
10
# File 'lib/environment.rb', line 8

def smooth_prob_array
  @smooth_prob_array
end

Instance Method Details

#increase_residue_count(a, inc = 1.0) ⇒ Object



26
27
28
# File 'lib/environment.rb', line 26

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

#label_setObject



30
31
32
# File 'lib/environment.rb', line 30

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

#to_sObject



34
35
36
# File 'lib/environment.rb', line 34

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