Learn R Programming

metamorphr (version 0.3.0)

formula_to_mass: Calculate the monoisotopic mass from a given formula

Description

Calculates the monoisotopic mass from a given formula. If only the element symbols are provided, the calculated mass corresponds to that of a molecule made up from the most abundant isotopes. Other isotopes can also be provided (e.g., 13C, instead of the naturally most abundant 12C). See the samples for details.

Usage

formula_to_mass(formula)

Value

The monoisotopic mass of the formula.

Arguments

formula

A formula as a string.

Examples

Run this code
# The monoisotopic mass is calculated with the most abundant isotopes
# if only the element symbols are provided:
formula_to_mass("CH4")
formula_to_mass("NH3")
formula_to_mass("C10H17N3O6S")

# Other isotopes can be provided as follows:
formula_to_mass("[13C]H4")
formula_to_mass("[15N]H3")

# Every isotope, including the most abundant ones, can be named explicitly.
# Compare:
formula_to_mass("[14N][1H]3")
formula_to_mass("NH3")

# The function also supports brackets and nested brackets:
formula_to_mass("(CH3)2")
formula_to_mass("(((CH3)2N)3C)2")
formula_to_mass("((([13C]H3)2N)3C)2")

Run the code above in your browser using DataLab