Class: Modifications

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mods) ⇒ Modifications

Returns a new instance of Modifications.



5
6
7
8
9
10
11
12
13
14
# File 'lib/ms/sim_modifications.rb', line 5

def initialize(mods)
  @modifications = mods
  @modifications = @modifications.split(/_/)
  if @modifications[0] != "false"
    get_mods
  else
    @modifications = nil
  end
  return @modifications
end

Instance Attribute Details

#modificationsObject

Returns the value of attribute modifications.



40
41
42
# File 'lib/ms/sim_modifications.rb', line 40

def modifications
  @modifications
end

Instance Method Details

#get_modsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ms/sim_modifications.rb', line 16

def get_mods()
  mods = {}
  obo = Obo::Ontology.new(Obo::Ontology::DIR + '/mod.obo')
  @modifications.each do |mod|
    diff = nil
    residue = mod[9..mod.size-1]
    mod = (obo.id_to_element[mod[0..8]]).tagvalues
    xref = mod['xref']
    xref.each do |x|
      if x =~ /DiffFormula/
        diff = (x.split(/"/))[1]
      end
    end
    if mods[residue] == nil
      mods[residue] = [[mod['id'][0],diff]]
    else
      mds = mods[residue]
      mds<<[mod['id'][0],diff]
      mods[residue] = mds
    end
  end
  @modifications = mods
end