I replied to Andrew's very nice discussion of implicit hydrogens in SMILES
 but forgot to include the whole list.

Wow, thank you, that was very useful.  I didn't realize those nuances of
> On the rdkit "side", the distinction made in Smiles between implicit and
> explicit hydrogens seems to live in the atom properties ImplicitValence and
> NumImplicitHs.  rdkit, unlike SMILES apparently, does not require that
> isotopically labeled atoms have an implicit valence explicitly specified.
> # print out some key properties of all atoms in a molecule
> def print_atom_info(mol):
>     for atom in mol.GetAtoms():
>         print(atom.GetIdx(), atom.GetSymbol(),
>               atom.GetIsotope(), atom.GetImplicitValence(),
>               atom.GetNumImplicitHs())
>     print('\n')
>     return
> # make some ethanol
> ethanol_v1 = Chem.MolFromSmiles('CCO')
> # label carbon #1 with C13
> ethanol_v1.GetAtomWithIdx(1).SetIsotope(13)
> # make more ethanol, labeled as it's created
> ethanol_v2 = Chem.MolFromSmiles('C[13C]O')
> # implicit valence is different for the two molecules
> # so is implicit
> show_atom_info(ethanol_v1)
> show_atom_info(ethanol_v2)
> Draw.MolsToGridImage([ethanol_v1, ethanol_v2])

I also didn't finish my thought here.  My ultimate goal is an easy way to
create rdkit molecules that have isotopic substitutions but which are
otherwise exactly the same as non-substituted variants.  What's the best
approach?  Is it to directly call .SetIsotope() like I do above?  This
requires figuring out the rdkit atom index of my target atom, which is
doable but perhaps (?) overly complicated?   Converting to InChI and back
seems to avoid the problem, I guess because MolToInchi() has a removeHs
parameter that defaults to True.  That also seems a bit hack-ish but I'm
not sure what the best approach is.

Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Rdkit-discuss mailing list

Reply via email to