Module: Mspire::Mass

Defined in:
lib/mspire/mass.rb,
lib/mspire/mass.rb,
lib/mspire/mass/aa.rb,
lib/mspire/mass/all.rb,
lib/mspire/mass/util.rb,
lib/mspire/mass/common.rb,
lib/mspire/mass/element.rb,
lib/mspire/mass/subatomic.rb

Defined Under Namespace

Modules: AA, All, Common, Element, Subatomic, Util

Constant Summary

ELECTRON =
Subatomic::MONO[:e]
NEUTRON =
Subatomic::MONO[:neutron]
PROTON =
Subatomic::MONO[:proton]
H_PLUS =
PROTON

Class Method Summary (collapse)

Class Method Details

+ (Object) aa_to_exact_mass(aa_seq) Also known as: aa



29
30
31
32
33
34
# File 'lib/mspire/mass.rb', line 29

def aa_to_exact_mass(aa_seq)
  chain_mass = aa_seq.each_char.inject(0.0) do |sum, aa_char|
    sum + AA[aa_char]
  end
  chain_mass + formula_to_exact_mass('H2O')
end

+ (Object) formula_to_exact_mass(formula) Also known as: formula

takes a molecular formula as a string, hash or MolecularFormula object and returns the exact mass.



24
25
26
# File 'lib/mspire/mass.rb', line 24

def formula_to_exact_mass(formula)
  Mspire::MolecularFormula.from_any(formula).mass
end