.. include:: ../substitutions

.. oe:namespace:: OEDepict

.. meta::
   :keywords: OEAnnotateValenceProblems

.. _OEDepict_OEAnnotateValenceProblems:


.. oe:function:: OEAnnotateValenceProblems


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

      .. oe:api::

         bool OEAnnotateValenceProblems(OE2DMolDisplay& disp)

   .. oe:language:: python

      .. oe:api:: python

         OEAnnotateValenceProblems(disp: OE2DMolDisplay) -> bool

   Annotates potential valence problems on the molecule.
   An atom is considered to have a valence problem when its bond count exceeds
   the maximum valence defined by the MDL valence model for its atomic number
   and formal charge.

   .. note::

      Aromaticity must be perceived (e.g.\ via :oe:func:`OEChem::OEAssignAromaticFlags`)
      before calling this function. Without aromaticity perception, aromatic
      ring atoms may be incorrectly flagged as having valence problems because
      their bonds are treated as alternating single/double bonds.

   *disp*
      The :ref:`OE2DMolDisplay <OEDepict_OE2DMolDisplay>` object being
      annotated.

   The following code snippet show how to use the
   :oe:func:`OEDepict::OEAnnotateValenceProblems` function.
   See the generated image in :ref:`Figure: Example of molecule with incorrect
   valences <figure_OEAnnotateValenceProblems>`.

   .. oe:source:: OEAnnotateValenceProblems.py
      :language: python
      :noindent:
      :frag:     SNIPPET-ANNOTATE-VALENCE-PROBLEMS

   .. oe:source:: OEAnnotateValenceProblems.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-ANNOTATE-VALENCE-PROBLEMS

   .. oe:source:: OEAnnotateValenceProblems.java
      :language: java
      :noindent:
      :frag:     SNIPPET-ANNOTATE-VALENCE-PROBLEMS

   .. oe:source:: OEAnnotateValenceProblems.cs
      :language: csharp
      :noindent:
      :frag:     SNIPPET-ANNOTATE-VALENCE-PROBLEMS

   .. _figure_OEAnnotateValenceProblems:

   .. figure:: ../images/OEAnnotateValenceProblems.*
      :align:  center

      **Example of molecule with incorrect valences**

   .. note::

      The :oe:func:`OEDepict::OEAnnotateValenceProblems` function uses
      the :ref:`section_valence_mdl`.
