Learn R Programming

enviPat (version 2.1)

check_chemform: Check chemical formulas

Description

Checks chemical formulas (=a vector of character strings) for consistency with usage in isopattern; calculation of the molecular mass.

Usage

check_chemform(isotopes,chemforms,get_sorted=FALSE)

Arguments

isotopes
chemforms
Vector of character strings with chemical formulas
get_sorted
Should elements in each formula be sorted according to their order in isotopes?

Value

Dataframe with 3 columns:
warning
Correct chemical formula, FALSE/TRUE?
new_formula
Chemical formula
monoisotopic_mass
Monoisotopic mass

Details

Checks if (1) a chemical formula contains only letters, numbers and square brackets, (2) elements can be found in isotopes and (3) letters are all followed by a number of atom counts. If (3) is missing, it is automatically set to 1.

(2) must consist of an upper case letter, possibly followed by lower case letters; to refer to individual isotopes (e.g., from isotope labelling of a molecule, e.g., N5 vs. [15]N2N3), square brackets may precede the capital letter. Anything else that may usually be part of a standard chemical formula (e.g., (+), (C4H3)2, dashes,...) is not permissible.

The molecular mass will be calculated from isotope masses and abundances listed in isotopes.

See Also

isopattern isotopes

Examples

Run this code

# Check package data set of chemical formulas #############
data(chemforms);
data(isotopes);
checked<-check_chemform(isotopes,chemforms);
checked;

# Check for some senseless molecular formulas #############
chemforms<-c("C900Cl4H49","O82394","C8G500Zn9","Br1","6DBr9889");
data(isotopes);
checked<-check_chemform(isotopes,chemforms);
checked;

# Molecular mass with and without isotope labelling #######
chemforms<-c("C10H5N4O5","[13]C2C8D2H3[15]N2N2[18]O2O3");
data(isotopes);
checked<-check_chemform(isotopes,chemforms);
checked;

Run the code above in your browser using DataLab