element_atom_count#

skfp.descriptors.element_atom_count(mol: Mol, atom_id: int | str) int#

Element atom count.

Calculates the count of atoms of a specific type. In case of hydrogens, the total number is returned, counting both explicit and implicit ones.

Parameters:
  • mol (RDKit Mol object) – The molecule for which the atom count is to be calculated.

  • atom_id (int or str) – The atomic number of the atom type, e.g. 6 for carbon, 1 for hydrogen or symbol of the atom type, e.g. “C” for carbon, “H” for hydrogen.

Examples

>>> from rdkit.Chem import MolFromSmiles
>>> from skfp.descriptors import element_atom_count
>>> mol = MolFromSmiles("C1=CC=CC=C1")  # Benzene
>>> element_atom_count(mol, "C")
6
>>> element_atom_count(mol, 6)
6
>>> mol = MolFromSmiles("CCO")  # Ethanol
>>> element_atom_count(mol, "H")
6
>>> element_atom_count(mol, 1)
6