Re: [Rdkit-discuss] Sanitize molecule with explicit Hydrogens to catch an error

2020-05-11 Thread Paolo Tosco
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():

Re: [Rdkit-discuss] Sanitize molecule with explicit Hydrogens to catch an error

2020-05-11 Thread Ivan Tubert-Brohman
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

[Rdkit-discuss] Sanitize molecule with explicit Hydrogens to catch an error

2020-05-11 Thread Pablo Ramos
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