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
https://github.com/tentrillion/ipython_notebooks/blob/master/rdkit_smarts_reactions_needs_updating.ipynb

# -------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 =
'[C:1]#[C:2].[N:3]=[N+:4]=[N-:5]>>[c:1]1[c:2][n-0:3][n-0:4][n-0:5]1'
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
try:
    Draw.MolsToGridImage(products)
except (RuntimeError, ValueError) as e:
    print 'FAILED!'
    my_error = e

# this works: force updating
for product in products:
    product.UpdatePropertyCache()

Draw.MolsToGridImage(products)

my_error

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

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

The stacktrace is:

---------------------------------------------------------------------------ValueError
                               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)
/Users/curt/anaconda2/lib/python2.7/site-packages/rdkit/Chem/Draw/IPythonConsole.pyc
in ShowMols(mols, **kwargs)    198   else:    199     fn =
Draw.MolsToGridImage--> 200   res = fn(mols, **kwargs)    201   if
kwargs['useSVG']:    202     return SVG(res)
/Users/curt/anaconda2/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.pyc
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
/Users/curt/anaconda2/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.pyc
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
/Users/curt/anaconda2/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.pyc
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',
True))
/Users/curt/anaconda2/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.pyc
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to