.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEBioisostere

.. meta::
   :keywords: OECPDDatabase, CPDDatabase


.. _OEBioisostere_OECPDDatabase:

.. oe:class:: OECPDDatabase

   .. attention::

      |PRELIMINARY-API|

   .. oe:api::

      class OECPDDatabase

   This class provides an interface to use an external compound database
   to identify similar compounds to a **Brood**-generated hitlist, as described in 
   :ref:`brood_compound_similarity`.

   The :ref:`OECPDDatabase <OEBioisostere_OECPDDatabase>` class defines the following public methods:
    * :oe:meth:`GetNumMolecules<OEBioisostere::OECPDDatabase::GetNumMolecules>`
    * :oe:meth:`GetSimilarMolecules<OEBioisostere::OECPDDatabase::GetSimilarMolecules>`  
    * :oe:meth:`HasNewFingerPrints<OEBioisostere::OECPDDatabase::HasNewFingerPrints>`
    * :oe:meth:`IsPrepared<OEBioisostere::OECPDDatabase::IsPrepared>`
    * :oe:meth:`Prep<OEBioisostere::OECPDDatabase::Prep>`
    * :oe:meth:`Write<OEBioisostere::OECPDDatabase::Write>` 

   

   .. _OEBioisostere_OECPDDatabase_Constructor:
   .. oe:method:: Constructor

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

         .. oe:api::

            OECPDDatabase()

      .. oe:language:: python

         .. oe:api:: python

            OECPDDatabase() -> OECPDDatabase

      Default constructor.

   .. _OEBioisostere_OECPDDatabase_GetNumMolecules:

   .. oe:method:: GetNumMolecules

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

         .. oe:api::

            unsigned GetNumMolecules()

      .. oe:language:: python

         .. oe:api:: python

            GetNumMolecules() -> int

      Returns the number of molecules in the prepared external compound
      database that are ready for hitlist comparison.

      See also :oe:meth:`IsPrepared<OEBioisostere::OECPDDatabase::IsPrepared>` method.

   .. _OEBioisostere_OECPDDatabase_GetSimilarMolecules:

   .. oe:method:: GetSimilarMolecules

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

         .. oe:api::

            bool GetSimilarMolecules(const OEChem::OEMolBase& hitMol,
                                     std::vector<std::string>& vecCpddbInfo)
            std::vector<std::string> GetSimilarMolecules(const OEChem::OEMolBase& hitMol)

      .. oe:language:: python

         .. oe:api:: python

            GetSimilarMolecules(hitMol: Union[OEGraphMol,OEMol,OEQMol]) -> OEStringVector


      Retrieves information (SMILES and labels) for molecules similar to the
      provided hit molecule from the external compound database. The ``bool``
      overload returns ``true`` when similar molecules are found.
      This method should be used after the compound database has been prepared
      using the :oe:meth:`Prep<OEBioisostere::OECPDDatabase::Prep>` method.

   .. _OEBioisostere_OECPDDatabase_HasNewFingerPrints:

   .. oe:method:: HasNewFingerPrints

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

         .. oe:api::

            bool HasNewFingerPrints()

      .. oe:language:: python

         .. oe:api:: python

            HasNewFingerPrints() -> bool

      Returns ``true`` if new fingerprints were generated during preparation.

      See also :oe:meth:`Prep<OEBioisostere::OECPDDatabase::Prep>` method.

   .. _OEBioisostere_OECPDDatabase_IsPrepared:

   .. oe:method:: IsPrepared

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

         .. oe:api::

            bool IsPrepared()

      .. oe:language:: python

         .. oe:api:: python

            IsPrepared() -> bool

      Returns whether the external compound database has been prepared.


   .. _OEBioisostere_OECPDDatabase_Prep:

   .. oe:method:: Prep

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

         .. oe:api::

            unsigned Prep(OEChem::oemolistream& cpddbifs,
                          OESystem::OETracerBase& tracer = OESystem::OENoTracer)

      .. oe:language:: python

         .. oe:api:: python

            Prep(cpddbifs: oemolistream, tracer: OETracerBase = OENoTracer) -> int

      Prepares the input stream molecules by generating 2D fingerprints for each, if they do not already have one.
      The method returns an unsigned. The unsigned code number can be extracted using :oe:func:`OEBioisostere::OEGetBroodStatus`. 


   .. _OEBioisostere_OECPDDatabase_Write:

   .. oe:method:: Write

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

         .. oe:api::

            bool Write(OEChem::oemolistream& cpddbifs,
                       OEChem::oemolostream& cpddbofs)

      .. oe:language:: python

         .. oe:api:: python

            Write(cpddbifs: oemolistream, cpddbofs: oemolostream) -> bool

      Writes newly generated fingerprints from ``cpddbifs`` into ``cpddbofs``
      for more efficient reuse in future runs.

      See also :oe:meth:`HasNewFingerPrints<OEBioisostere::OECPDDatabase::HasNewFingerPrints>` method.


