The ChemMW package of ChemW parses a chemical formula string – which can consist of any combination of elements and decimal stoichiometry – and precisely calculates the MW of the chemical formula. The significant digits of the reported MW matches the lowest significant digits from the set of elements that constitute the chemical formula, where the elemental masses are the most precise contemporary measurements of pure elements, per the chemicals module. This approach offers 1-2 more significant digits than PubChemPy).
ChemMW¶
This class determines the MW of a formula or common-name chemical, after the initial parameters are specified:
import chemw
chem_mw = chemw.ChemMW(verbose = False, printing = True)
verbose & printing
bool: specifies whether troubleshooting information or MW results will be printed, respectively.
mass()¶
The parameterized data is fitted to the Hill equation, with the following arguments and their default values:
mw = chem_mw.mass(formula = None, common_name = None)
formula
str: parameterizes the chemical formula for which the MW is desired. The acceptable formats for the formula are quite broad, which are exemplified in the following table:
Example chemical |
Format option |
|---|---|
|
Any organic compounds can be easily processed. |
|
Underscores can arbitrarily separate content, since these are ignored by |
|
|
|
Chemical groups can be nested, with differing stoichiometric values. |
|
|
|
|
|
Non-water entities can be complexed. |
|
Multiple complexations can be applied with repeated |
|
The complexity, while remaining within the aforementioned format, is arbitrary. |
common_name
str: parameterizes the common name of the chemical for which the MW is desired, as it is recognized by Pubchem: e.g.'water','acetone','toluene','glucose','aspirin','hydrochloric acid',"alanine","glutamine","phenylalanine","tryptophan", et cetera.
Note
Common names that begin with a lower-case letter can also be parameterized as the formula, which efficiently enables the positional parameterization of common names.
Returns mw float: The mass of the parameterized chemical to the appropriate significant digitsthat are alloted by those of the elemental masses.
Accessible content¶
The ChemMW object retains numerous components that are accessible to the user:
mw
str: The MW of the parameterized chemical formula with the proper significant digits, which should be used for printing and storing a calculated mass.raw_mw
float: The MW of the parameterized chemical formula without consideration of the significant digits, which should be used for calculations.proportions
dict: The ratio of elements in the chemical formula. This loses accuracy with the grouped elements, and is being improved.formula
str: The original chemical formula as a string.atoms
int: The qantity of atoms that are defined in the chemical formula.groups
int: A numerical counter for the quantity of chemical groups that aregroup_masses
dict: A dictionary for the masses of each nesting level in a molecule.