.. oe:namespace:: OEGraphSim

.. meta::
   :keywords: OEFPDatabase, FPDatabase


.. _OEGraphSim_OEFPDatabase:

.. oe:class:: OEFPDatabase

   .. oe:api::

      class OEFPDatabase

   The :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` class is designed to perform
   rapid in-memory fingerprint searches.
   Each :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object is associated with a
   fingerprint type (:ref:`OEFPTypeBase <OEGraphSim_OEFPTypeBase>`) that is
   specified when the database is constructed.
   An :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object can only store
   fingerprints (:ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`) with this
   specified type.

   .. seealso::

      * :ref:`OEFastFPDatabase <OEGraphSim_OEFastFPDatabase>` class

   .. oe:method:: Constructors

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

         .. oe:api::

            OEFPDatabase(unsigned int fptype)

      .. oe:language:: python

         .. oe:api:: python

            OEFPDatabase(fptype: int) -> OEFPDatabase

      Creates an :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object that can
      store :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` objects with a given type.

      **fptype**
        The type of the :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` object stored in the
        :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>`.
        This value has to be from the :oe:constns:`OEGraphSim::OEFPType`
        namespace.

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

         .. oe:api::

            OEFPDatabase(const OEGraphSim::OEFPTypeBase *)

      .. oe:language:: python

         .. oe:api:: python

            OEFPDatabase(arg2: OEFPTypeBase) -> OEFPDatabase

      Creates an :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object that can
      store :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` objects with
      :ref:`OEFPTypeBase <OEGraphSim_OEFPTypeBase>` type.

      .. note::

         By default, an :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object is constructed with:

         * no cutoff value
         * :oe:const:`Tanimoto<OEGraphSim::OESimMeasure::Tanimoto>` similarity measure
         * descending order to return scores when calling the
           :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` method

         These default values can be altered by the following methods:

         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc`


   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEFPDatabase & operator=(const OEFPDatabase & rhs)

      Assignment operator.



   .. oe:method:: AddFP

      .. oe:api::

         unsigned int AddFP(const OEChem::OEMolBase &mol)

      Generates an :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` object from the
      :ref:`OEMolBase <OEChem_OEMolBase>` molecule with the fingerprint type of
      the :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>`.
      The generated :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` object is then
      inserted into the database returning its index.
      This method will return ``-1``, if the fingerprint generation
      was unsuccessful.

      .. oe:api::

         unsigned int AddFP(const OEGraphSim::OEFingerPrint &fp)

      Creates a copy of the :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` object,
      inserts it into the database, and then returns its index.
      If the type of the passed fingerprint was different from the
      type of the database, than the insertion is unsuccessful and
      this method will return ``-1``.

      .. note::

         The index returned by the
         :oe:meth:`OEGraphSim::OEFPDatabase::AddFP` method is a unique
         number starting from zero.
         This index can be used as a reference number to associate
         the fingerprint with the molecule from which is it generated.


   .. oe:method:: ClearCutoff

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

         .. oe:api::

            void ClearCutoff()

      .. oe:language:: python

         .. oe:api:: python

            ClearCutoff() -> None

      Removes the cutoff value previously set by the
      :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff` method.
      After clearing the cutoff value
      :oe:meth:`OEGraphSim::OEFPDatabase::HasCutoff` method
      will return ``false``.

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::GetCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::HasCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`


   .. oe:method:: GetCutoff

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

         .. oe:api::

            float GetCutoff() const

      .. oe:language:: python

         .. oe:api:: python

            GetCutoff() -> float

      Returns the cutoff value previously set by the
      :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff` method.

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::ClearCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::HasCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`

   .. oe:method:: GetDescendingOrder

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

         .. oe:api::

            bool GetDescendingOrder() const

      .. oe:language:: python

         .. oe:api:: python

            GetDescendingOrder() -> bool

      Returns the order in which the calculated scores are returned by
      the :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores`
      method.

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::SetDescendingOrder`


   .. oe:method:: GetFPTypeBase

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

         .. oe:api::

            const OEGraphSim::OEFPTypeBase* GetFPTypeBase() const

      .. oe:language:: python

         .. oe:api:: python

            GetFPTypeBase() -> OEFPTypeBase

      Returns the fingerprint type of the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.


   .. oe:method:: GetFingerPrints

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

         .. oe:api::

            OESystem::OEIterBase<const OEGraphSim::OEFingerPrint>* GetFingerPrints() const

      .. oe:language:: python

         .. oe:api:: python

            GetFingerPrints() -> Iterable[OEFingerPrint]

      Returns an iterator pointer over fingerprints
      (:ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`) stored in the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.
      The returned :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` objects can only
      be accessed by `const` methods or functions, *i.e.*, they can
      not be modified.


   .. oe:method:: GetScores

   .. list-table:: **The overloaded versions of the GetScores method**
      :widths: 100 200
      :header-rows: 1

      * - Link
        - Description

      * - :ref:`GetScores(mol, bgn, end)<api_OEFPDatabase_GetScores>`
        - returns similarities for a molecule

      * - :ref:`GetScores(fp, bgn, end)<api_OEFPDatabase_GetScores>`
        - returns similarities for a fingerprint

      * - :ref:`GetScores(mol, opts)<api_OEFPDatabase_GetScores_OEFPDatabaseOptions>`
        - returns similarities for a molecule with the given options

      * - :ref:`GetScores(fp, opts)<api_OEFPDatabase_GetScores_OEFPDatabaseOptions>`
        - returns similarities for a fingerprint with the given options

   **Similarity calculation:**

   .. _api_OEFPDatabase_GetScores:

      .. oe:api::

         OESystem::OEIterBase<OEGraphSim::OESimScore> * GetScores(const OEChem::OEMolBase &mol,
                                                                  unsigned int bgn = 0,
                                                                  unsigned int end = 0) const

      .. oe:api::

         OESystem::OEIterBase<OEGraphSim::OESimScore> * GetScores(const OEGraphSim::OEFingerPrint &fp,
                                                                  unsigned int bgn = 0,
                                                                  unsigned int end = 0) const


      Performs similarity calculation between a given molecule or a
      fingerprint and the fingerprints stored in the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.
      It returns an iterator over the calculated similarity scores
      (:ref:`OESimScore <OEGraphSim_OESimScore>`).
      Each :ref:`OESimScore <OEGraphSim_OESimScore>` holds a similarity score
      and index of the corresponding fingerprint of the database.

      **mol**
         If the method is called with an :ref:`OEMolBase <OEChem_OEMolBase>`
         object, then a fingerprint is generated from this molecule
         before looping over the fingerprints of the database and
         calculating similarities.

      **fp**
         If the method is called with an :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`
         object, then its type has to  match with the type of the
         :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>`.

      **bgn**, **end**
         The ``bgn`` and ``end`` arguments define the segment of the
         database on which the similarity calculation will take place.
         If both of these parameters are omitted (or set to zero), then
         the similarity calculation is performed on the entire
         fingerprint database.

      .. note::

         * By default, the :oe:meth:`OEGraphSim::OEFPDatabase::GetScores`
           methods calculates :oe:const:`Tanimoto<OEGraphSim::OESimMeasure::Tanimoto>`
           similarity scores and will always return these scores in the
           order in which the corresponding :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`
           objects are added to the database.

         * By using the :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc`
           method, similarity measures other than the default can be
           performed.

         * The behavior of :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` is
           also influenced by the cutoff value
           (:oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`) of the database
           and the order of the scores specified by the
           :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc` method.
           If a cutoff value was set, then the
           :oe:meth:`OEGraphSim::OEFPDatabase::GetScores` method:

           * return scores that are equal to or larger than the specified
             cutoff value if the order is descending
           * return scores that are equal to or smaller than the
             specified cutoff value if the order is ascending

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc` method
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff` method

      **Examples:**

      * Calculates the :oe:const:`Tanimoto<OEGraphSim::OESimMeasure::Tanimoto>`
        similarity on the first 100 entries of the database and returns
        scores that are equal to or larger than ``0.1``.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SCORES-1

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SCORES-1

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`

        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SCORES-1

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SCORES-1

      * Calculates the :oe:cls:`Tversky<OEGraphSim::OETverskySim>`
        similarity (with :math:`\alpha=0.9` and :math:`\beta=0.1`)
        on the entire database and returns all scores.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SCORES-2

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SCORES-2

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`

        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SCORES-2

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SCORES-2

      * Calculates the :oe:const:`Dice<OEGraphSim::OESimMeasure::Dice>`
        similarity beginning at the 100th entry of the database and
        returns scores that are equal to or smaller than  ``0.5``.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SCORES-3

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SCORES-3

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`

        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SCORES-3

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SCORES-3


   .. _api_OEFPDatabase_GetScores_OEFPDatabaseOptions:

   **Similarity calculation with an option class:**

      Performs similarity calculation between a given molecule or a
      fingerprint and the fingerprints stored in the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.
      It returns an iterator over the calculated similarity scores
      (:ref:`OESimScore <OEGraphSim_OESimScore>`).
      Each :ref:`OESimScore <OEGraphSim_OESimScore>` holds a similarity score
      and index of the corresponding fingerprint of the database.


      **mol**
         If the method is called with an :ref:`OEMolBase <OEChem_OEMolBase>`
         object, then a fingerprint is generated from this molecule
         before looping over the fingerprints of the database and
         calculating similarities.

      **fp**
         If the method is called with an :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`
         object, then its type has to  match with the type of the
         :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>`.


      **opts**
         The :ref:`OEFPDatabaseOptions <OEGraphSim_OEFPDatabaseOptions>` object controls
         all the parameters that determine the sorted search.
         For example, similarity measure, score cutoff, descending or ascending order
         etc.

      .. seealso::

         * :ref:`OEFPDatabaseOptions <OEGraphSim_OEFPDatabaseOptions>` class


      **Example:**

      * Calculates the :oe:const:`Cosine<OEGraphSim::OESimMeasure::Cosine>`
        similarity on the entire database and returns scores
        that are equal to or larger than `0.3`.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SCORES-OPTIONS

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SCORES-OPTIONS

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`


        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SCORES-OPTIONS

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SCORES-OPTIONS


   .. oe:method:: GetSortedScores

   .. list-table:: **The overloaded versions of the GetSortedScores method**
      :widths: 100 200
      :header-rows: 1

      * - Link
        - Description

      * - :ref:`GetSortedScores(mol, limit, bgn, end)<api_OEFPDatabase_GetSortedScores>`
        - returns sorted similarities for a molecule

      * - :ref:`GetSortedScores(fp, limit, bgn, end)<api_OEFPDatabase_GetSortedScores>`
        - returns sorted similarities for a fingerprint

      * - :ref:`GetSortedScores(mol, opts)<api_OEFPDatabase_GetSortedScores_OEFPDatabaseOptions>`
        - returns sorted similarities for a molecule with the given options

      * - :ref:`GetSortedScores(fp, opts)<api_OEFPDatabase_GetSortedScores_OEFPDatabaseOptions>`
        - returns similarities for a fingerprint with the given options

   **Similarity calculation:**

   .. _api_OEFPDatabase_GetSortedScores:

      .. oe:api::

         OESystem::OEIterBase<OEGraphSim::OESimScore> * GetSortedScores(const OEChem::OEMolBase &mol,
                                                                        unsigned int limit = 0,
                                                                        unsigned int bgn = 0,
                                                                        unsigned int end = 0) const

      .. oe:api::

         OESystem::OEIterBase<OEGraphSim::OESimScore> * GetSortedScores(const OEGraphSim::OEFingerPrint &fp,
                                                                        unsigned int limit = 0,
                                                                        unsigned int bgn = 0,
                                                                        unsigned int end = 0) const

      Performs similarity calculations between a molecule or a
      fingerprint and the fingerprints stored in the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.
      It returns an iterator over the calculated similarity
      scores (:ref:`OESimScore <OEGraphSim_OESimScore>`) in sorted order.
      Each :ref:`OESimScore <OEGraphSim_OESimScore>` holds a similarity score
      and index of the corresponding fingerprint of the database.

      **mol**
         If the method is called with an :ref:`OEMolBase <OEChem_OEMolBase>`
         object, then a fingerprint is generated from this molecule
         before looping over the fingerprints of the database and
         calculating similarities.

      **fp**
         If the method is called with an :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`
         object, then its type has to  match with the type of the
         :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>`.

      **bgn**, **end**
         The ``bgn`` and ``end`` arguments define the segment of the
         database on which the similarity calculation will take place.
         If both of these parameters are omitted (or set to zero), then
         the similarity calculation is performed on the entire
         fingerprint  database.

      **limit**
         The value that defines the number of similarity scores
         returned by the
         :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` method.
         If it is omitted (or set to zero) then all of the similarity
         scores are returned.

      .. note::

         * By default, the :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores`
           method calculates :oe:const:`Tanimoto<OEGraphSim::OESimMeasure::Tanimoto>`
           similarity scores and returns them in descending order.

         * By using the :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc`
           method, similarity measures other than the default can be
           performed.

         * The behavior of :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` is
           also influenced by the cutoff value
           (:oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`) of the database
           and the order of the scores specified by the
           :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc` method.
           If a cutoff value was set, then the
           :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` method:

           * return scores that are equal to or larger than the specified
             cutoff  value if the order is descending
           * return scores that are equal to or smaller than the
             specified cutoff value if the order is ascending

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::SetSimFunc` method
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff` method


      **Examples:**

      * Calculates the :oe:const:`Tanimoto<OEGraphSim::OESimMeasure::Tanimoto>`
        similarity on the entire database and returns the 10 best
        scores in descending order.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-1

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-1

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`


        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-1

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-1

      * Calculates the :oe:const:`Dice<OEGraphSim::OESimMeasure::Dice>`
        similarity on the first 100 entries of the database and
        returns scores that are equal to or larger than ``0.5`` in
        descending order.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-2

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-2

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`


        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-2

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-2

      * Calculates :oe:const:`Manhattan<OEGraphSim::OESimMeasure::Manhattan>`
        similarity beginning at the 100th entry of the database and
        returns the "worst" 5 scores that are equal to or smaller
        than ``0.3`` in ascending order.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-3

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-3

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`


        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-3

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-3

   **Sorted similarity calculation with an option class:**

   .. _api_OEFPDatabase_GetSortedScores_OEFPDatabaseOptions:

      .. oe:api::

         OESystem::OEIterBase<OESimScore>* GetSortedScores(const OEChem::OEMolBase& mol,
                                                           const OEFPDatabaseOptions& opts) const GetSortedScores(const OEChem::OEMolBase &mol, const OEFPDatabaseOption &opts) const

      .. oe:api::

         OESystem::OEIterBase<OESimScore>* GetSortedScores(const OEFingerPrint& fp,
                                                           const OEFPDatabaseOptions& opts) const GetSortedScores(const OEGraphSim::OEFingerPrint &fp, const OEFPDatabaseOption &opts) const

      Performs similarity calculations between a molecule or a
      fingerprint and the fingerprints stored in the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.
      It returns an iterator over the calculated similarity
      scores (:ref:`OESimScore <OEGraphSim_OESimScore>`) in sorted order.
      Each :ref:`OESimScore <OEGraphSim_OESimScore>` holds a similarity score
      and index of the corresponding fingerprint of the database.

      **mol**
         If the method is called with an :ref:`OEMolBase <OEChem_OEMolBase>`
         object, then a fingerprint is generated from this molecule
         before looping over the fingerprints of the database and
         calculating similarities.

      **fp**
         If the method is called with an :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`
         object, then its type has to  match with the type of the
         :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>`.

      **opts**
         The :ref:`OEFPDatabaseOptions <OEGraphSim_OEFPDatabaseOptions>` object controls
         all the parameters that determine the sorted search.
         For example, similarity measure, score cutoff, descending or ascending order
         etc.

      .. seealso::

         * :ref:`OEFPDatabaseOptions <OEGraphSim_OEFPDatabaseOptions>` class


      **Example:**

      * Calculates :oe:const:`Tversky<OEGraphSim::OESimMeasure::Tversky>`
        similarity on the entire database and
        returns the best ``10`` scores that are equal to or larger than ``0.3`` in
        descending order.

        .. oe:source:: GetScores.cpp
           :language: c++
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-OPTIONS

        .. oe:source:: GetScores.py
           :language: python
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-OPTIONS

        ..  oe:language:: python

            :ref:`Full listing. <listing-GetScores.py>`


        .. oe:source:: GetScores.java
           :language: java
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-OPTIONS

        .. oe:source:: GetScores.cs
           :language: csharp
           :noindent:
           :frag:     SNIPPET-GET-SORTED-SCORES-OPTIONS


   .. oe:method:: HasCutoff

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

         .. oe:api::

            bool HasCutoff() const

      .. oe:language:: python

         .. oe:api:: python

            HasCutoff() -> bool

      Returns whether the cutoff value of the
      :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object has been set by the
      :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff` method.

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::ClearCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::GetCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`


   .. oe:method:: NumFingerPrints

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

         .. oe:api::

            unsigned int NumFingerPrints() const

      .. oe:language:: python

         .. oe:api:: python

            NumFingerPrints() -> int

      Returns the number of :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` objects
      stored in the database.


   .. oe:method:: SetCutoff

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

         .. oe:api::

            void SetCutoff(float)

      .. oe:language:: python

         .. oe:api:: python

            SetCutoff(arg2: float) -> None

      Sets the cutoff value of the :ref:`OEFPDatabase <OEGraphSim_OEFPDatabase>` object.
      The cutoff value influences the behavior of both the
      :oe:meth:`OEGraphSim::OEFPDatabase::GetScores` and the
      :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` methods.

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::ClearCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::HasCutoff`
         * :oe:meth:`OEGraphSim::OEFPDatabase::SetCutoff`

   .. oe:method:: SetDescendingOrder

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

         .. oe:api::

            void SetDescendingOrder(bool descending)

      .. oe:language:: python

         .. oe:api:: python

            SetDescendingOrder(arg2: bool) -> None

      Sets the order in which the calculated scores are returned by
      the :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores`
      method.

      .. seealso::

         * :oe:meth:`OEGraphSim::OEFPDatabase::GetDescendingOrder`


   .. oe:method:: SetSimFunc


      Sets the method used to evaluate fingerprint similarity
      when calling either the :oe:meth:`OEGraphSim::OEFPDatabase::GetScores`
      or the :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` methods.

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

         .. oe:api::

            void SetSimFunc(unsigned int simtype, bool descending = true)

      .. oe:language:: python

         .. oe:api:: python

            SetSimFunc(simtype: int, descending: bool = True) -> None

      Sets the similarity calculation by specifying a similarity method
      with a constant from the :oe:constns:`OEGraphSim::OESimMeasure`
      namespace.
      The second argument defines the order in which the calculated
      scores are returned by the
      :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` method.

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

         .. oe:api::

            void SetSimFunc(const OEGraphSim::OESimFuncBase &,
                            bool descending = true)

      .. oe:language:: python

         .. oe:api:: python

            SetSimFunc(arg2: OESimFuncBase, descending: bool = True) -> None

      Creates a copy of the :ref:`OESimFuncBase <OEGraphSim_OESimFuncBase>` object
      and uses its :oe:meth:`OEGraphSim::OESimFuncBase::operator()`
      method to evaluate similarity between two :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>`
      objects.
      The second argument defines the order in which the calculated
      scores are returned by the
      :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores` method.

      .. note::

         By default, both the :oe:meth:`OEGraphSim::OEFPDatabase::GetScores`
         and the :oe:meth:`OEGraphSim::OEFPDatabase::GetSortedScores`
         methods calculate :oe:const:`Tanimoto<OEGraphSim::OESimMeasure::Tanimoto>`
         similarity scores.
         While the :oe:meth:`OEGraphSim::OEFPDatabase::GetScores`
         always returns these scores in the order in which the corresponding
         :ref:`OEFingerPrint <OEGraphSim_OEFingerPrint>` objects are added to the
         database, the latter method returns them in descending order,
         by default.

      .. seealso::

        * :ref:`section_database_simfunc` section
        * :ref:`section_measure_user_defined` section
        * :oe:constns:`OEGraphSim::OESimMeasure` namespace
        * :ref:`OETanimotoSim <OEGraphSim_OETanimotoSim>` class
        * :ref:`OETverskySim <OEGraphSim_OETverskySim>` class

