Dear Pablo,
You might do something along these lines:
from rdkit import Chem
smi = "[H]C([H])O"
params = Chem.SmilesParserParams()
params.sanitize = True
params.removeHs = False
mol = Chem.MolFromSmiles(smi, params)
for a in mol.GetAtoms():
if a.GetNumImplicitHs():
Hi Pablo,
SMILES by definition has implicit hydrogens (enough to satisfy the typicial
valence) for atoms that are not within brackets.
It doesn't matter if you write C, C[H], [H]C[H], or [H]C([H])([H])[H]; they
are all methane. The number of hydrogens that are returned by
GetNumImplicitHs() and
Dear all,
I am trying to catch an error every time that a smiles associated to a mol
object does not exist. To do this, I want to use sanitize function: if the
smiles is incorrect I will get my error.
My smiles with explicit hydrogens is the next one: [H]C([H])O
I want it to provide an error
3 matches
Mail list logo