.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEDetermineRingSystems

.. oe:function:: OEDetermineRingSystems

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

      .. oe:api::

         unsigned int OEDetermineRingSystems(const OEMolBase& mol,
                                             unsigned int* rings)

   .. oe:language:: python

      .. oe:api:: python

         OEDetermineRingSystems(mol: Union[OEGraphMol,OEMol,OEQMol]) -> Tuple[int, List[int]]

   .. oe:language:: python

      .. oe:api::

         OEDetermineRingSystems(const OEMolBase mol) -> number_of_rings, ring_idx_per_atom

   Determines the ring systems of a molecule.  The return
   value is the number of ring systems found in the molecule.  If
   the molecule is acyclic, the return value is zero.  The 'rings' array
   must contain at least :oe:meth:`OEChem::OEMolBase::GetMaxAtomIdx`
   elements, and upon return it contains a mapping indexed by
   :oe:meth:`OEChem::OEAtomBase::GetIdx` of which ring system each atom is
   in.  The ring systems are numbered from one, up to an including the
   return value of the function.  Atoms that aren't contained in a ring,
   *i.e.* for which :oe:meth:`OEChem::OEAtomBase::IsInRing` returns
   ``false``, are mapped to the value zero.

   .. oe:language:: python

      In Python, OEDetermineRingSystems returns a two item tuple. The
      first item in the tuple is the number of independent ring
      systems found. The second item in the tuple is a list of the
      atom ring membership as described as the 'rings' parameter
      above.


   .. warning::

      It is necessary to perform ring perception by calling
      :oe:func:`OEChem::OEFindRingAtomsAndBonds` function prior to calling
      :oe:func:`OEChem::OEDetermineRingSystems` function.

   .. seealso::

      * :ref:`section_ring_system_identification` section

