.. include:: ../substitutions

.. oe:namespace:: OEMolProp

.. meta::
   :keywords: OEGetRotatableBondCount

..  _OEMolProp_OEGetRotatableBondCount:

.. _OEMolProp_OEGetRotatableBondCount:

.. oe:function:: OEGetRotatableBondCount

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

      .. oe:api::

         unsigned int OEGetRotatableBondCount(const OEChem::OEMolBase& mol,
                                              bool adjust = false)

   .. oe:language:: python

      .. oe:api:: python

         OEGetRotatableBondCount(mol: Union[OEGraphMol,OEMol,OEQMol],
                                 adjust: bool = False) -> int

   Returns the number of rotatable bond counts in a molecule. :term:`Rotatable<rotatable bond>`
   bond is defined as any single non-ring bond, bounded to nonterminal heavy (i.e., non-hydrogen) atom.
   In addition, It considers the carbon-carbon triple bond in acetylene rotatable. The function
   excludes single bonds observed in a certain groups, such as sulfonamides, esters, and amidine.

   **adjust**
      This parameter allows optional adjustment for aliphatic rings following the method of
      [Oprea-2000]_. In this case, it also estimates the number of
      flexible bonds in aliphatics rings.


   .. note::

      The Oprea's method is individual ring based. Since *Smallest set of smallest rings*
      perception is not available in **OEChem TK**
      (see section :ref:`section_sssr` for more details), we modified
      Oprea's method to be ring system based
      (:ref:`section_ring_system_identification`), and implemented the
      function relatively closed to Oprea's definition. The function
      works for various complex fused ring-systems and simple bridge
      ring-systems.

   **Examples**

   The number of rotatable bonds calculated for the molecule below is ``0``.
   When considering the flexibility of the aliphatic ring
   (setting the **adjust** parameter to ``true``), the
   :oe:func:`OEMolProp::OEGetRotatableBondCount` function returns `3`,
   based on Oprea's method that considers the amide bonds as non-rotatable.

   .. figure:: ../../../common/images/molprop/rtb-001.*
      :align:  center

      **Example of aliphatic ring**

   The number of rotatable bonds calculated for the molecule below is ``7``.
   When considering the flexibility of the aliphatic ring
   (setting the **adjust** parameter to ``true``), the
   :oe:func:`OEMolProp::OEGetRotatableBondCount` function returns ``11``,
   adjusting the rotatable bond count by ``2`` from each of the two aliphatic
   rings.

   .. figure:: ../../../common/images/molprop/rtb-002.*
      :align:  center

      **Example of rotatable bond count adjustment for aliphatic rings**

   .. seealso::

      * :ref:`filter_files_rotor_count` subsection describing filter files
      * :term:`rotatable bond` definition in **OEChem TK**
      * :ref:`OEIsRotor <OEChem_OEIsRotor>` functor in **OEChem TK**
      * :ref:`section_sssr` and :ref:`section_ring_system_identification` sections in  **OEChem TK**
