.. include:: ../substitutions

.. oe:namespace:: OEChem

.. meta::
   :keywords: OEMDLGetValence

.. oe:function:: OEMDLGetValence

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

      .. oe:api::

         unsigned int OEMDLGetValence(unsigned int atomicnum, int charge,
                                      unsigned int minvalence)

   .. oe:language:: python

      .. oe:api:: python

         OEMDLGetValence(elemno: int, charge: int, minval: int) -> int

   Returns the **MDL valence** for the given parameters.

   **elemno**
      The atomic number returned by the :oe:meth:`OEChem::OEAtomBase::GetAtomicNum` method.

   **charge**
      The formal charge returned by the :oe:meth:`OEChem::OEAtomBase::GetFormalCharge` method.

   **minvalence**
     The minimum valence.

   For example, :oe:func:`OEChem::OEMDLGetValence` will return ``4``
   in the case of the following input parameters:

   * atomic number: :oe:const:`OEChem::OEElemNo::N`
   * formal charge: "+1"
   * minimum valence: three single bonds to heavy atoms (value returned by the
     :oe:meth:`OEChem::OEAtomBase::GetExplicitDegree` method)

   This means that the atom has correct valence only if it has either one implicit
   or one explicit hydrogen.

   .. seealso::

      * :ref:`section_valence_mdl` section
      * :oe:func:`OEChem::OEDefaultMDLHCount` function
      * :oe:func:`OEChem::OEAssignMDLHydrogens` function
      * :oe:cls:`OEChem::OEIsValidMDLAtomValence` predicate 

