Class: Mspire::Lipid::Ion
- Inherits:
-
Object
- Object
- Mspire::Lipid::Ion
- Includes:
- Fragment
- Defined in:
- lib/mspire/lipid/ion.rb,
lib/mspire/lipid/ion/fragment.rb
Overview
a lipid with modifications (typically the mods give it a charge so that it can be seen in the mass spec)
Defined Under Namespace
Modules: Fragment
Instance Attribute Summary collapse
-
#lipid ⇒ Object
an Mspire::Lipid object.
-
#modifications ⇒ Object
an Mspire::Lipid::Modifications object.
Instance Method Summary collapse
- #charge ⇒ Object
-
#formula ⇒ Object
a MolecularFormula object.
-
#initialize(lipid, mods = []) ⇒ Ion
constructor
the key attribute of a query.
- #inspect ⇒ Object
-
#mz ⇒ Object
the unsigned m/z value.
-
#mz_signed ⇒ Object
value is cached.
Methods included from Fragment
Constructor Details
#initialize(lipid, mods = []) ⇒ Ion
the key attribute of a query
15 16 17 18 19 |
# File 'lib/mspire/lipid/ion.rb', line 15 def initialize(lipid, mods=[]) @lipid = lipid @modifications = mods @mz = nil end |
Instance Attribute Details
#lipid ⇒ Object
an Mspire::Lipid object
10 11 12 |
# File 'lib/mspire/lipid/ion.rb', line 10 def lipid @lipid end |
#modifications ⇒ Object
an Mspire::Lipid::Modifications object
12 13 14 |
# File 'lib/mspire/lipid/ion.rb', line 12 def modifications @modifications end |
Instance Method Details
#charge ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/mspire/lipid/ion.rb', line 21 def charge z = 0 @modifications.each do |mod| z += mod.charge end z end |
#formula ⇒ Object
a MolecularFormula object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mspire/lipid/ion.rb', line 30 def formula _formula = @lipid.formula _formula = Mspire::MolecularFormula.from_any(_formula) unless _formula.is_a?(Mspire::MolecularFormula) modifications.each do |mod| if mod.gain? _formula += mod.formula else _formula -= mod.formula end end _formula end |
#inspect ⇒ Object
65 66 67 |
# File 'lib/mspire/lipid/ion.rb', line 65 def inspect "<|| Ion mz=#{mz} #{lipid.inspect} + #{modifications.map(&:inspect).join(', ')} ||>" end |
#mz ⇒ Object
the unsigned m/z value
60 61 62 63 |
# File 'lib/mspire/lipid/ion.rb', line 60 def mz _mz_signed = mz_signed _mz_signed >= 0 ? _mz_signed : -_mz_signed end |
#mz_signed ⇒ Object
value is cached
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mspire/lipid/ion.rb', line 44 def mz_signed 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 |