.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEAssignFormalCharges

..  _OEChem_OEAssignFormalCharges:

.. oe:function:: OEAssignFormalCharges

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

      .. oe:api::

         void OEAssignFormalCharges(OEAtomBase* atm)

   .. oe:language:: python

      .. oe:api:: python

         OEAssignFormalCharges(atm: OEAtomBase) -> None

   Sets the formal charge property of an atom, based upon a **OpenEye
   valence model**.  This function assumes that the bond orders and
   implicit hydrogen counts have been set on a molecule.  For example,
   this function will place a single positive charge on a neutral
   four-valent nitrogen.  Note that this function only modifies neutral
   atoms, with zero formal charge.  This preserves any formal charges
   previously assigned, but requires the charge to be reset to zero in
   order to force a reassignment.

   The assigned formal charge can be accessed by the
   :oe:meth:`OEChem::OEAtomBase::GetFormalCharge` method

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

      .. oe:api::

         void OEAssignFormalCharges(OEMolBase& mol)

   .. oe:language:: python

      .. oe:api:: python

         OEAssignFormalCharges(mol: Union[OEGraphMol,OEMol,OEQMol]) -> None

   Sets the formal charge property of each atom in the molecule by
   by calling :oe:func:`OEAssignFormalCharges(OEAtomBase *)<OEChem::OEAssignFormalCharges>`
   function.

   The assigned formal charge can be accessed by the
   :oe:meth:`OEChem::OEAtomBase::GetFormalCharge` method.

   .. seealso::

      * :ref:`section_valence_openeye` section
      * :oe:func:`OEChem::OEAssignImplicitHydrogens` function
