In Python, I'd like to iterate through all the atoms in a molecule,
including hydrogens, so I can assign an isotope to each atom. I haven't
been able to include hydrogens in the iterable of atoms:

from rdkit import Chem

mol = Chem.MolFromSmiles("CCO") # Example molecule: Ethanol (C2H5OH)

# Add explicit hydrogens
Chem.AddHs(mol)

for atom in mol.GetAtoms():
print(f"Atom Symbol: {atom.GetSymbol()}")
Output:
Atom Symbol: C
Atom Symbol: C
Atom Symbol: O

Similarly, mol.GetAtomWithIdx() works up to an index of only 3, giving C,
C, and O atoms but no hydrogens.

Thanks,
Jeremy
 -- ~ -- ~ --
Jeremy Monat, PhD
LinkedIn: http://www.linkedin.com/in/jemonat
Portfolio: https://bertiewooster.github.io
GitHub: https://github.com/bertiewooster
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to