Class: MS::Lipid::Ion

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

Overview

a lipid with modifications (typically the mods give it a charge so that it can be seen in the mass spec)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lipid, mods = []) ⇒ Ion

the key attribute of a query



13
14
15
16
17
# File 'lib/ms/lipid/ion.rb', line 13

def initialize(lipid, mods=[])
  @lipid = lipid
  @modifications = mods
  @mz = nil
end

Instance Attribute Details

#lipidObject

an MS::Lipid object



8
9
10
# File 'lib/ms/lipid/ion.rb', line 8

def lipid
  @lipid
end

#modificationsObject

an MS::Lipid::Modifications object



10
11
12
# File 'lib/ms/lipid/ion.rb', line 10

def modifications
  @modifications
end

Instance Method Details

#inspectObject



34
35
36
# File 'lib/ms/lipid/ion.rb', line 34

def inspect
  "<|| Ion mz=#{mz} #{lipid.inspect} + #{modifications.map(&:inspect).join(', ')} ||>"
end

#mzObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ms/lipid/ion.rb', line 19

def mz
  return @mz if @mz
  mass = @lipid.mass
  charge = 0
  @modifications.each do |mod|
    mass += mod.massdiff 
    charge += mod.charge
  end
  if charge == 0
    @mz = nil
  else
    @mz = mass / charge
  end
end