Hi all,

I recently wanted to use RDKit to model the famous copper-catalyzed
cycloaddition of alkynes and azides.

I eventually got things working, kind of, but had two questions.  First, I
was surprised to find that the products of RunReactants don't have update
property caches.  Is this something I should have expected, or is it a
bug?  If the latter, is it any easy-to-fix bug or a hard-to-fix one?

Second, how can I modify my SMARTS reaction query to avoid duplication of
each product?

Here's some example code, also available at

# -------BEGIN CODE------ #
# import rdkit components
from rdkit import rdBase
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import Draw

# use IPythonConsole for pretty drawings
from rdkit.Chem.Draw import IPythonConsole
# IPythonConsole.ipython_useSVG=True  # leave out for github

# for flattening
from itertools import chain

# define reactants
diyne_smiles = 'C#CCC(O)C#C'
azide_smiles = 'CCCN=[N+]=[N-]'

diyne = Chem.MolFromSmiles(diyne_smiles)
azide = Chem.MolFromSmiles(azide_smiles)

# define reaction
copper_click_smarts =
copper_click = AllChem.ReactionFromSmarts(copper_click_smarts)

# run reaction
products_tuples = copper_click.RunReactants((diyne, azide))

# flatten product tuple of tuples into list
products = list(chain(*products_tuples))

# FAILS: mol property caches are not updated
except (RuntimeError, ValueError) as e:
    print 'FAILED!'
    my_error = e

# this works: force updating
for product in products:



products_tuples = copper_click.RunReactants((diyne, azide))
products = list(chain(*products_tuples))
# FAILS: mol property caches are not updated

# -------END CODE------ #

The stacktrace is:

                               Traceback (most recent call
last)<ipython-input-4-7962390107ec> in <module>()      2 products =
list(chain(*products_tuples))      3 # FAILS: mol property caches are
not updated----> 4 Draw.MolsToGridImage(products)
in ShowMols(mols, **kwargs)    198   else:    199     fn =
Draw.MolsToGridImage--> 200   res = fn(mols, **kwargs)    201   if
kwargs['useSVG']:    202     return SVG(res)
in MolsToGridImage(mols, molsPerRow, subImgSize, legends,
highlightAtomLists, useSVG, **kwargs)    403   else:    404     return
_MolsToGridImage(mols, molsPerRow=molsPerRow, subImgSize=subImgSize,
legends=legends,--> 405
highlightAtomLists=highlightAtomLists, **kwargs)    406     407
in _MolsToGridImage(mols, molsPerRow, subImgSize, legends,
highlightAtomLists, **kwargs)    344       highlights =
highlightAtomLists[i]    345     if mol is not None:--> 346       img
= _moltoimg(mol, subImgSize, highlights, legends[i], **kwargs)    347
     res.paste(img, (col * subImgSize[0], row * subImgSize[1]))    348
  return res
in _moltoimg(mol, sz, highlights, legend, **kwargs)    309   from
rdkit.Chem.Draw import rdMolDraw2D    310   if not
hasattr(rdMolDraw2D, 'MolDraw2DCairo'):--> 311     img =
MolToImage(mol, sz, legend=legend, highlightAtoms=highlights,
**kwargs)    312   else:    313     nmol =
rdMolDraw2D.PrepareMolForDrawing(mol, kekulize=kwargs.get('kekulize',
in MolToImage(mol, size, kekulize, wedgeBonds, fitImage, options,
canvas, **kwargs)    112     from rdkit import Chem    113     mol =
Chem.Mol(mol.ToBinary())--> 114     Chem.Kekulize(mol)    115     116
 if not mol.GetNumConformers():
ValueError: Sanitization error: Can't kekulize mol.  Unkekulized atoms: 3
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
Rdkit-discuss mailing list

Reply via email to