Learn R Programming

enviPat (version 2.2)

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,get_list=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?
get_list
Return list with vectors of elements atom counts contained in each chemical formula?

Value

Dataframe with 3 columns for get_list=FALSE: :Or list containing vector of elements for get_list=TRUE.

Details

Default checks if (1) a chemical formula contains only letters, numbers and square or round brackets, (2) elements can be found in isotopes and (3) letters and round brackets are all followed by a number of counts. Where (3) are missing, they are 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. Any other symbols which may be part of a chemical formula (e.g., charges (+), dashes, asterisks, ...) are 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