[Rdkit-discuss] fast hydrogen count in molecule
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Rafal R. <rmr...@gm...> - 2019-03-13 10:16:33
|
Hello group, Is there any fast way to count all hydrogen atoms in molecule? The only idea which I have is: sum([atom.GetTotalNumHs() for atom in mol.GetAtoms() ]) which probably is not the most optimal because it require iteration over atom at python end. For all other atoms I found such solution: from rdkit.Chem import rdqueries q = rdqueries.AtomNumEqualsQueryAtom(6) len(mol.GetAtomsMatchingQuery(q)) (in mailing-list archive: https://sourceforge.net/p/rdkit/mailman/message/34524687/) but this is valid only for atoms present in molecular graph, so is there any smart solution for H? Regards, Rafal |