17.1.1.1.1.3. cobra.core.formula

Provide a class representing a chemical formula.

17.1.1.1.1.3.1. Module Contents

17.1.1.1.1.3.1.1. Classes

Formula

Describe a chemical formula.

cobra.core.formula.element_re[source]
class cobra.core.formula.Formula(formula: Optional[str] = None, **kwargs)[source]

Bases: cobra.core.object.Object

Describe a chemical formula.

Parameters

formula (string) – A legal formula string contains only letters and numbers.

__add__(self, other_formula: Union['Formula', str]) → 'Formula'[source]

Combine two molecular formulas.

Parameters

other_formula (Formula, str) – string for a chemical formula

Returns

Formula – The combined formula

Return type

Formula

parse_composition(self) → None[source]

Break the chemical formula down by element.

property weight(self) → float[source]

Calculate the mol mass of the compound.

Returns

the mol mass

Return type

float

cobra.core.formula.elements_and_molecular_weights[source]