cobra.core.formula

Provide a class representing a chemical formula.

Module Contents

Classes

Formula

Describe a chemical formula.

Attributes

element_re

elements_and_molecular_weights

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.

property weight: float[source]

Calculate the mol mass of the compound.

Returns

the mol mass

Return type

float

__add__(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() None[source]

Break the chemical formula down by element.

cobra.core.formula.elements_and_molecular_weights[source]