:py:mod:`cobra.core.formula` ============================ .. py:module:: cobra.core.formula .. autoapi-nested-parse:: Provide a class representing a chemical formula. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: cobra.core.formula.Formula Attributes ~~~~~~~~~~ .. autoapisummary:: cobra.core.formula.element_re cobra.core.formula.elements_and_molecular_weights .. py:data:: element_re .. py:class:: Formula(formula: Optional[str] = None, **kwargs) Bases: :py:obj:`cobra.core.object.Object` Describe a chemical formula. :param formula: A legal formula string contains only letters and numbers. :type formula: string .. py:property:: weight :type: float Calculate the mol mass of the compound. :returns: the mol mass :rtype: float .. py:method:: __add__(other_formula: Union[Formula, str]) -> Formula Combine two molecular formulas. :param other_formula: string for a chemical formula :type other_formula: Formula, str :returns: **Formula** -- The combined formula :rtype: Formula .. py:method:: parse_composition() -> None Break the chemical formula down by element. .. py:data:: elements_and_molecular_weights