Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mspire-mass

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mspire-mass

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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']         # => 12.0
Mspire::Mass::AA::MONO_STRING['C']              # => 103.0091844778 (residue)
Mspire::Mass::Subatomic::MONO_STRING['NEUTRON'] # => 1.0086649156
Mspire::Mass::Common::MONO_STRING['H2O']        # => 18.0105646837

# similar for average masses
Mspire::Mass::Element::AVG_STRING['C']          # => 12.0107

# note that elements are accessed in mixed case by default
Mspire::Mass::Element::MONO_STRING['Se']        # => 79.9165213

A hash where everything but the amino acids is downcased can also be accessed

require 'mspire/mass/merged'  # <- must be required explicitly
Mspire::Mass::Merged::MONO_STRING['C']   # (cysteine) => 103.0091844778
Mspire::Mass::Merged::MONO_STRING['c']   # (carbon)   => 12.0
Mspire::Mass::Merged::MONO_STRING['h2o'] # (water)    => 18.0105646837
Mspire::Mass::Merged::MONO_STRING['e']   # (or 'electron') => 0.0005486 
# Mspire::Mass::Merged::AVG_STRING also available

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
# which defaults to this
el_masses = Mspire::Mass::Element.masses(type: :mono, by: :symbol, case: :up)
el_masses[:C]  # (carbon) => 12.0

aas = Mspire::Mass::AA.masses(type: :avg, by: :string)
aas['C'] # (cysteine) => 103.1429

subatomic = Mspire::Mass::Subatomic.masses
subatomic[:PROTON]   # (same as subatomic[:'H+'] or subatomic[:H_PLUS]) # => 1.00727643207

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] # (cysteine) => 103.0091844778
merged[:c] # (carbon)   => 12.0

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 #=> 0.0005486
Mspire::Mass::PROTON   #=> 1.00727643207
Mspire::Mass::NEUTRON  #=> 1.0086649156

FAQs

Package last updated on 01 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc