.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEGetNearestNbrs

.. oe:function:: OEGetNearestNbrs

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

      .. oe:api::

         OESystem::OEIterBase<OENbrs>* OEGetNearestNbrs(const OEMolBase& mol,
                                                        double maxdist,
                                                        unsigned int method = OENearestNbrsMethod::Default)

   .. oe:language:: python

      .. oe:api:: python

         OEGetNearestNbrs(mol: Union[OEGraphMol,OEMol,OEQMol], maxdist: float,
                          method: int) -> OENbrsIter

   Returns an iterator over all atom pairs of the given molecule that are closer
   to each other than the given limit.

   maxdist
     The maximum distance between two atoms.

   method
     Determines the algorithm that is used to find the nearest neighbors.
     This value has to be from the :oe:const:`OEChem::OENearestNbrsMethod` namespace.

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

      .. oe:api::

         OESystem::OEIterBase<OENbrs>* OEGetNearestNbrs(const OEMolBase& mol,
                                                        const OEAtomBase* atom,
                                                        double maxdist,
                                                        unsigned int method = OENearestNbrsMethod::Default)

   .. oe:language:: python

      .. oe:api:: python

         OEGetNearestNbrs(mol: Union[OEGraphMol,OEMol,OEQMol],
                          atom: OEAtomBase, maxdist: float, method: int) -> OENbrsIter

   Returns an iterator over all neighbors of the given atom that is closer than the
   given limit.

   atom
     This atom does not have to belong to the given molecule.

   maxdist
     The maximum distance between two atoms.

   method
     Determines the algorithm that is used to find the nearest neighbors.
     This value has to be from the :oe:const:`OEChem::OENearestNbrsMethod` namespace.

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

      .. oe:api::

         OESystem::OEIterBase<OENbrs>* OEGetNearestNbrs(const OEMolBase& mol,
                                                        const float* coords,
                                                        double maxdist,
                                                        unsigned int method = OENearestNbrsMethod::Default)
         OESystem::OEIterBase<OENbrs>* OEGetNearestNbrs(const OEMolBase& mol,
                                                        const double* coords,
                                                        double maxdist,
                                                        unsigned int method = OENearestNbrsMethod::Default)

   .. oe:language:: python

      .. oe:api:: python

         OEGetNearestNbrs(mol: Union[OEGraphMol,OEMol,OEQMol], coords: float,
                          maxdist: float, method: int) -> OENbrsIter

   Returns an iterator over all atom pairs of the given molecule that are closer
   to each other than the given limit. When calculating the distances the coordinates
   passed as a parameter are utilized rather then the coordinates stored in
   the molecule.

   maxdist
     The maximum distance between two atoms.

   method
     Determines the algorithm that is used to find the nearest neighbors.
     This value has to be from the :oe:const:`OEChem::OENearestNbrsMethod` namespace.

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

      .. oe:api::

         OESystem::OEIterBase<OENbrs>* OEGetNearestNbrs(const OEMolBase& mol1,
                                                        const OEMolBase& mol2,
                                                        double maxdist,
                                                        unsigned int method = OENearestNbrsMethod::Default,
                                                        const bool sorting = false)

   .. oe:language:: python

      .. oe:api:: python

         OEGetNearestNbrs(mol1: Union[OEGraphMol,OEMol,OEQMol],
                          mol2: Union[OEGraphMol,OEMol,OEQMol], maxdist: float,
                          method: int) -> OENbrsIter

   Returns an iterator over all atom pairs of the two molecules that are closer
   to each other than the given limit.
   This function calculates **intra-molecular** distances.

   maxdist
     The maximum distance between two atoms.

   method
     Determines the algorithm that is used to find the nearest neighbors.
     This value has to be from the :oe:const:`OEChem::OENearestNbrsMethod` namespace.

   sorting
     If the value is set to ``true``, the returned atom pairs are sorted based on
     the distance from the shortest to the longest. The default value is ``false``.

   .. seealso::

      * :oe:func:`OEChem::OENearestNbrs` function
      * :oe:func:`OEChem::OENbrs` class
