.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEParseSmiles

.. oe:function:: OEParseSmiles

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

      .. oe:api::

         bool OEParseSmiles(OEMolBase& mol, const char* str,
                            bool canon = false, bool strict = false)
         bool OEParseSmiles(OEMolBase& mol, const std::string& str,
                            bool canon = false, bool strict = false)
         bool OEParseSmiles(OEMolBase& mol, const char* str,
                            const OEParseSmilesOptions& options)
         bool OEParseSmiles(OEMolBase& mol, const std::string& str,
                            const OEParseSmilesOptions& options)

   .. oe:language:: python

      .. oe:api:: python

         OEParseSmiles(mol: Union[OEGraphMol,OEMol,OEQMol], str: str,
                       canon: bool = False, strict: bool = False) -> bool
         OEParseSmiles(mol: Union[OEGraphMol,OEMol,OEQMol], str: str,
                       options: OEParseSmilesOptions) -> bool

   Parses a :term:`SMILES` string into a molecule.
   The returned value indicates whether the given :term:`SMILES` string was parsed
   successfully.

   mol
    The constructed molecule.

   str
    The :term:`SMILES` string that is parsed into the molecule.

   canon
     Flag that determines whether the post-processing kekulization is performed.
     Passing a boolean ``true`` value to this argument indicates to the parser
     that the :term:`SMILES` string
     should be assumed to be well-formed and the usual kekulization (by
     calling :oe:func:`OEChem::OEKekulize`) step may be omitted.

     This can be used to speed-up parsing of a large database, but has the
     side-effect that bond orders are not correctly assigned for aromatic molecules.

   strict
     Flag that controls whether the parser should operate in strict mode.
     By default, the :term:`SMILES`
     parser attempts to process any reasonably formed :term:`SMILES`
     string.  If the 'strict' argument is ``true``, the parser applies more
     rigorous sanity checking.  For example, the :term:`SMILES` ``C==C`` is
     accepted by the default non-strict parser, but rejected by the strict
     parser.

   options
      The :ref:`OEParseSmilesOptions <OEChem_OEParseSmilesOptions>` object that stores
      properties that influence how a :term:`SMILES` string is parsed into a
      molecule.

   The input molecule instance is not cleared so these functions can be used
   to add components to an existing molecule.  If the :term:`SMILES` string
   represents a reaction, any previously-existing atoms and bonds not already
   in a reaction component become reactants in the resulting molecule object.

   .. hint::

      The use of the high-level :oe:func:`OEChem::OESmilesToMol` function is
      highly recommended over the low-level :oe:func:`OEChem::OEParseSmiles` function.
      The :oe:func:`OEChem::OESmilesToMol` function not only converts
      a :term:`SMILES` string into a molecule but also perceives basic molecular
      properties.

   .. seealso::

      * :oe:func:`OEChem::OESmilesToMol` function
      * :ref:`section_molctordtor_smilesfrommol` section
