.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OERandomizeTorsions

.. oe:function:: OERandomizeTorsions

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

      .. oe:api::

         bool OERandomizeTorsions(OEMolBase& mol, double maxRadians)
         bool OERandomizeTorsions(OEMolBase& mol, double maxRadians,
                                  const OESystem::OEUnaryPredicate<OEBondBase>& isRotor)

   .. oe:language:: python

      .. oe:api:: python

         OERandomizeTorsions(arg1: Union[OEGraphMol,OEMol,OEQMol],
                             maxRadians: float) -> bool
         OERandomizeTorsions(arg1: Union[OEGraphMol,OEMol,OEQMol],
                             maxRadians: float, isRotor: OEUnaryBondPred) -> bool


   Modifies each of the torsions in a molecule by a random value between
   ``+maxRadians`` and ``-maxRadians``.  While most people think about
   this sort of function in degrees, all angles in **OEChem TK** are measures
   in radians.  The following simple constants may be used
   :oe:const:`OEMath::OEMath::Pi`, :oe:const:`OEMath::OEMath::Rad2Deg` and
   :oe:const:`OEMath::OEMath::Deg2Rad` to generate the appropriate value.

   There are two API points, the one with two arguments applies the
   random torsion adjustment to every bond for which the **OEChem TK** bond
   predicate 'IsRotor` returns ``true``.  The second API point has an
   additional argument in which the user can specify a functor which
   defines which bonds are rotatable.  If the user's functor causes the
   function to attempt to apply a random rotation on a ring bond, no
   change in the internal coordinates will occur, however, the frame of
   reference of the molecule may change.

   The functions return ``true`` if completes successfully.  The functions 
   return ``false`` if there are no torsions to randomize.


   *mol*
      The molecule to randomize torsions of.

   *maxRadians*
      Maximum value of torsions angle to be modified, in radians. 

   *isRotor*
      Predicate to define which torsions should be randomized.

