Mspire::Mass
mspire library holding constants for mass lookup. Uses NIST masses (where applicable). See mspire-isotope for complete isotope information (including masses). See mspire-molecular_formula for mass or m/z methods for larger molecular formulas.
Installation
gem install mspire-mass
Examples
MONO_STRING and AVG_STRING
A simple hash may be accessed directly from the various modules:
require 'mspire/mass'
Mspire::Mass::Element::MONO_STRING['C']
Mspire::Mass::AA::MONO_STRING['C']
Mspire::Mass::Subatomic::MONO_STRING['NEUTRON']
Mspire::Mass::Common::MONO_STRING['H2O']
Mspire::Mass::Element::AVG_STRING['C']
Mspire::Mass::Element::MONO_STRING['Se']
A hash where everything but the amino acids is downcased can also be accessed
require 'mspire/mass/merged'
Mspire::Mass::Merged::MONO_STRING['C']
Mspire::Mass::Merged::MONO_STRING['c']
Mspire::Mass::Merged::MONO_STRING['h2o']
Mspire::Mass::Merged::MONO_STRING['e']
MONO_STRING and AVG_STRING are only for quick, low-level access. They are
purposefully ugly to encourage you to use the beautiful interface shown
directly below!
.masses
A mass hash can be created in a variety of forms depending on your
needs/preferences.
---------------------------------
<default>
---------------------------------
type = :mono | :avg
by = :symbol | :string | :both
case = :up | :down | :both
NOTE: it defaults to symbols, not strings.
el_masses = Mspire::Mass::Element.masses
el_masses = Mspire::Mass::Element.masses(type: :mono, by: :symbol, case: :up)
el_masses[:C]
aas = Mspire::Mass::AA.masses(type: :avg, by: :string)
aas['C']
subatomic = Mspire::Mass::Subatomic.masses
subatomic[:PROTON]
A merged hash can be created in a similar way, but :up and :down aren't
respected since it merges by upcasing amino acids and downcasing all else.
merged = Mspire::Mass::Merged.masses(type: :mono)
merged[:C]
merged[:c]
Subatomic constants on Mspire::Mass
The strings that play nice are defined as constants on Mspire::Mass so you can
do this:
Mspire::Mass::ELECTRON
Mspire::Mass::PROTON
Mspire::Mass::NEUTRON