.. oe:namespace:: OEProton

.. meta::
   :keywords: OEChargeEngineBase, ChargeEngineBase, ChargeEngine


.. _OEProton_OEChargeEngineBase:

.. oe:class:: OEChargeEngineBase

   .. oe:api::

      class OEChargeEngineBase

   This is the abstract base class for all charge engines, containing methods
   used by the function :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>`.

   The following charge engine classes derive from this base class:

    * :ref:`OEAM1BCCCharges <OEProton_OEAM1BCCCharges>`
    * :ref:`OEAM1BCCELF10Charges <OEProton_OEAM1BCCELF10Charges>`
    * :ref:`OEAM1Charges <OEProton_OEAM1Charges>`
    * :ref:`OEAmberFF94Charges <OEProton_OEAmberFF94Charges>`
    * :ref:`OEChargeEngineNoOp <OEProton_OEChargeEngineNoOp>`
    * :ref:`OEClearCharges <OEProton_OEClearCharges>`
    * :ref:`OECombineChargeEngines <OEProton_OECombineChargeEngines>`
    * :ref:`OEDesignUnitCharges <OEProton_OEDesignUnitCharges>`
    * :ref:`OEELFCharges <OEProton_OEELFCharges>`
    * :ref:`OEFormalToPartialCharges <OEProton_OEFormalToPartialCharges>`
    * :ref:`OEGasteigerCharges <OEProton_OEGasteigerCharges>`
    * :ref:`OEInitialCharges <OEProton_OEInitialCharges>`
    * :ref:`OEMMFF94Charges <OEProton_OEMMFF94Charges>`

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

      .. oe:api::

         OEChargeEngineBase & operator=(const OEChargeEngineBase & rhs)

      Assignment operator.


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

      .. oe:api::

         bool operator!=(const OEChargeEngineBase& rhs) const

      Returns ``true`` if the charge engines are `not` equivalent.

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

      .. oe:api::

         bool operator==(const OEChargeEngineBase& rhs) const

      Returns ``true`` if the charge engines are equivalent (the same
      class with the same parameters).

   .. oe:method:: ApplyCharges

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

         .. oe:api::

            bool ApplyCharges(OEChem::OEMolBase& mol) const
            bool ApplyCharges(OEChem::OEMCMolBase& mcMol) const
            bool ApplyCharges(OEBio::OEDesignUnit& du) const

      .. oe:language:: python

         .. oe:api:: python

            ApplyCharges(du: OEDesignUnit) -> bool

      Assigns partial charges to the atoms of the molecule. The ``OEMCMolBase``
      overload assigns charges using all conformers where applicable. The
      ``OEDesignUnit`` overload charges the small-molecule component of the
      design unit.

   .. oe:method:: CheckCharges

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

         .. oe:api::

            bool CheckCharges(const OEChem::OEMolBase& mol) const
            bool CheckCharges(const OEChem::OEMCMolBase& mcMol) const
            bool CheckCharges(const OEBio::OEDesignUnit& du) const

      .. oe:language:: python

         .. oe:api:: python

            CheckCharges(mol: Union[OEGraphMol,OEQMol]) -> bool
            CheckCharges(mcMol: OEMol) -> bool
            CheckCharges(du: OEDesignUnit) -> bool

      Used by :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>` to
      determine if the charges on the molecule are as expected.

   .. oe:method:: CreateCopy

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

         .. oe:api::

            OEChargeEngineBase* CreateCopy() const = 0

      .. oe:language:: python

         .. oe:api:: python

            CreateCopy() -> OEChargeEngineBase

      Deep copy of the charge engine.

   .. oe:method:: GetExpectValidMol

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

         .. oe:api::

            bool GetExpectValidMol() const

      .. oe:language:: python

         .. oe:api:: python

            GetExpectValidMol() -> bool

      Returns ``true`` if an input molecule must be valid before
      :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>` attempts to
      assign charges.

      .. seealso:
         :oe:meth:`SetExpectValidMol<OEProton::OEChargeEngineBase::SetExpectValidMol>`

   .. oe:method:: GetName

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

         .. oe:api::

            std::string GetName() const

      .. oe:language:: python

         .. oe:api:: python

            GetName() -> str

      Returns the name of the charge engine.

   .. oe:method:: GetRepairRequestedHint

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

         .. oe:api::

            bool GetRepairRequestedHint() const

      .. oe:language:: python

         .. oe:api:: python

            GetRepairRequestedHint() -> bool

      Returns ``true`` if :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>`
      is requested to repair the input molecule before assigning charges.
      Examples of repairing a molecule include adding explicit hydrogens and
      perceiving residues.

      .. seealso:
         :oe:meth:`SetRepairRequestedHint<OEProton::OEChargeEngineBase::SetRepairRequestedHint>`

   .. oe:method:: GetRequirements

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

         .. oe:api::

            unsigned GetRequirements() const

      .. oe:language:: python

         .. oe:api:: python

            GetRequirements() -> int

      Returns a bit mask used by :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>`
      describing aspects of the input molecule required for this charging method.
      Examples include 3D coordinates, explicit hydrogens, and PDB order.

   .. oe:method:: IsValid

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

         .. oe:api::

            bool IsValid(OEChem::OEMolBase& mol) const
            bool IsValid(OEChem::OEMCMolBase& mcMol) const
            bool IsValid(OEBio::OEDesignUnit& du) const
            bool IsValid(const OEChem::OEMolBase& mol) const = 0
            bool IsValid(const OEChem::OEMCMolBase& mcMol) const
            bool IsValid(const OEBio::OEDesignUnit& du) const

      .. oe:language:: python

         .. oe:api:: python

            IsValid(mol: Union[OEGraphMol,OEQMol]) -> bool
            IsValid(mcMol: OEMol) -> bool
            IsValid(du: OEDesignUnit) -> bool

      Returns ``true`` if the input molecule appears to be valid for use with
      this method.

   .. oe:method:: SetExpectValidMol

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

         .. oe:api::

            void SetExpectValidMol(bool expect = true)

      .. oe:language:: python

         .. oe:api:: python

            SetExpectValidMol(expect: bool = True) -> None

      Defines whether an input molecule must be valid before
      :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>` attempts to
      assign charges. If set to ``false`` and the molecule is not valid,
      then :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>`
      attempt to charge the molecule anyway.

      .. seealso:
         :oe:meth:`IsValid<OEProton::OEChargeEngineBase::IsValid>`

   .. oe:method:: SetRepairRequestedHint

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

         .. oe:api::

            void SetRepairRequestedHint(bool repair = true)

      .. oe:language:: python

         .. oe:api:: python

            SetRepairRequestedHint(repair: bool = True) -> None

      Define whether :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>`
      is requested to repair the input molecule before assigning charges.
      Examples of repairing a molecule include adding explicit hydrogens and
      perceiving residues. If set to ``false`` and the molecule requires
      repairs, then :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>`
      will fail and return ``false``.

   .. oe:method:: TransferCharge

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

         .. oe:api::

            bool TransferCharge(OEChem::OEAtomBase* dstAtom,
                                const OEChem::OEAtomBase* srcAtom) const

      .. oe:language:: python

         .. oe:api:: python

            TransferCharge(dstAtom: OEAtomBase, srcAtom: OEAtomBase) -> bool

      If :oe:func:`OEAssignCharges<OEProton::OEAssignCharges>` must make
      a copy of the input molecule before charges can be applied, this
      method is used to transfer charges back to the input molecule.
