cobra.core.formula
==================

.. py:module:: cobra.core.formula

.. autoapi-nested-parse::

   Provide a class representing a chemical formula.



Attributes
----------

.. autoapisummary::

   cobra.core.formula.element_re
   cobra.core.formula.elements_and_molecular_weights


Classes
-------

.. autoapisummary::

   cobra.core.formula.Formula


Module Contents
---------------

.. 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:attribute:: formula
      :value: None



   .. py:attribute:: elements


   .. 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:property:: weight
      :type: float


      Calculate the mol mass of the compound.

      :returns: the mol mass
      :rtype: float


.. py:data:: elements_and_molecular_weights

