Class: Mascot::DAT::Masses
- Inherits:
-
Object
- Object
- Mascot::DAT::Masses
- Defined in:
- lib/mascot/dat/masses.rb
Overview
A Hash of the mass table section. See the masstable instance method for details.
Instance Attribute Summary collapse
-
#deltas ⇒ Object
(also: #mods, #d)
readonly
A subset of the mass table defining the variable modications.
-
#fixed_modifications ⇒ Object
(also: #fixed_mods, #f)
readonly
A subset of the mass table defining the fixed modifications.
-
#masstable ⇒ Object
(also: #m)
readonly
The main table of masses.
Instance Method Summary collapse
-
#initialize(masses_section) ⇒ Masses
constructor
A new instance of Masses.
Constructor Details
#initialize(masses_section) ⇒ Masses
Returns a new instance of Masses.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/mascot/dat/masses.rb', line 54 def initialize masses_section @masstable = {} @deltas = [] @fixed_modifications = [] masses_section.split("\n").each do |l| k,v = l.split("=") next unless k && v case k when /delta(\d+)/ idx = $1.to_i - 1 @deltas[idx] = v.split(",") @deltas[idx][0] = @deltas[idx][0].to_f @masstable[k.to_sym] = @deltas[idx][0] when /FixedMod(.*)(\d+)/ idx = $2.to_i - 1 if $1.empty? # new fixed mod record @fixed_modifications[idx] = v.split(",") @fixed_modifications[idx][0] = @fixed_modifications[idx][0].to_f @masstable[k.to_sym] = @fixed_modifications[idx][0] else # append the modified residue to the array @fixed_modifications[idx] << v end else @masstable[k.to_sym] = v.to_f end @masstable.keys.each do |m| self.class.send(:define_method,m, lambda { @masstable[m] }) end end end |
Instance Attribute Details
#deltas ⇒ Object (readonly) Also known as: mods, d
A subset of the mass table defining the variable modications. For example, given the following delta in a DAT file:
delta1=15.994915,Oxidation (M)
Then the following gets defined:
@deltas = [[15.994915,"Oxidation (M)"], ... ]
36 37 38 |
# File 'lib/mascot/dat/masses.rb', line 36 def deltas @deltas end |
#fixed_modifications ⇒ Object (readonly) Also known as: fixed_mods, f
A subset of the mass table defining the fixed modifications. For example:
FixedMod1=57.021464,Carbamidomethyl (C)
FixedModResidues1=C
Then the following gets defined:
@fixed_modifications = [[57.021464, "Carbamidomethyl (C)", "C"], ...]
50 51 52 |
# File 'lib/mascot/dat/masses.rb', line 50 def fixed_modifications @fixed_modifications end |
#masstable ⇒ Object (readonly) Also known as: m
The main table of masses. Given the following examples from a DAT file:
W=186.079313
X=111.000000
Y=163.063329
Z=128.550590
Hydrogen=1.007825
Carbon=12.000000
You can access the value for Hydrogen as:
mydat.masses.masstable[:Hydorgen] # => 1.007825
or
mydat.masses.m[:Hydrogen] # => 1.007825
or
mydat.masses.hydorgen # => 1.007825
21 22 23 |
# File 'lib/mascot/dat/masses.rb', line 21 def masstable @masstable end |