.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OECXSMILESToMol

.. oe:function:: OECXSMILESToMol

   .. oe:language:: c++ java csharp

      .. oe:api::

         bool OECXSMILESToMol(OEMolBase& mol, const std::string& str)

   .. oe:language:: python

      .. oe:api:: python

         OECXSMILESToMol(mol: Union[OEGraphMol,OEMol,OEQMol], str: str) -> bool

   Converts a :term:`CXSMILES` string into a molecule.
   After constructing the molecule the following properties are perceived:

   * Rings are perceived by calling the
     :oe:func:`OEChem::OEFindRingAtomsAndBonds` function.

   * The aromaticity is assigned by calling the
     :oe:func:`OEChem::OEAssignAromaticFlags` function using the
     :oe:const:`OEChem::OEAroModel::OpenEye` aromaticity model.

   * The chirality is perceived by calling the
     :oe:func:`OEChem::OEPerceiveChiral` function.

   Note that since :term:`CXSMILES` is a superset of the :term:`SMILES` syntax,
   it is safe to use this function for either format. Using :term:`SMILES` readers
   for known :term:`CXSMILES` is discouraged since any appendix information will become
   a static addition to the molecule title and cannot be recovered.

   The molecule object is cleared before parsing so the resulting molecule
   object only contains atoms and bonds from the :term:`CXSMILES`.  If one
   wishes to *add* atoms and bonds to an existing molecule, one can use
   the lower-level :oe:func:`OEChem::OEParseSmiles` function (with an option argument
   that enables :term:`CXSMILES` parsing), which preserves
   any existing atoms and bonds in the molecule.

   .. seealso::

      * :oe:func:`OEChem::OEMolToCXSMILES` function
      * :oe:func:`OEChem::OEMolToSmiles` function
      * :ref:`section_molctordtor_smilesfrommol` section
