get_atom_charge#

get_atom_charge(atom, ignore_multiple_charges=True, use_formal_charge=False)[source]#

Get the effective charge of an atom based on its default valence and total bond orders.

Parameters:
  • atom (rdkit.Chem.rdchem.Atom) – RDKit atom to assess.

  • ignore_multiple_charges (bool, optional, default=True) – If False, raises an error when multiple possible charges are encountered; otherwise, selects the lowest charge. This is relevant for atoms like sulfur that can have multiple charge states.

  • use_formal_charge (bool, optional, default=False) – Whether to use the atomic formal charge. If True, the output is the number of hanging bonds (negative for hanging, positive for excess). Either may indicate that the formal charge of the atom should be updated.

Returns:

The formal charge of the atom. May be fractional if aromatics are involved. If use_formal_charge is True, returns the number of excess bonds.

Return type:

float

Raises:

ValueError – If the atom could have multiple charge states given the bonding orders and ignore_multiple_charges is False.

Notes

If multiple possible charges are found and ignore_multiple_charges is True, the lowest charge is selected.