Oof, thanks for the pointer MIchal.  I'm sorry I didn't read the docs
carefully enough! ~CF

On Thu, Jan 12, 2017 at 9:32 AM, Michal Krompiec <michal.kromp...@gmail.com>
wrote:

> You need to sanitize the products, just run Chem.SanitizeMol on each
> molecule. See http://www.rdkit.org/docs/GettingStartedInPython.html#
> chemical-reactions : "the molecules that are produced by the chemical
> reaction processing code are not sanitized".
>
> Best,
> Michal
>
> On 12 January 2017 at 17:22, Curt Fischer <curt.r.fisc...@gmail.com>
> wrote:
>
>> What makes you think the molecules are nonsensical?  They look OK to me.
>> Converting to SMILES before doing any UpdatePropertyCache() stuff....
>>
>>
>>
>> *products_tuples = copper_click.RunReactants((diyne, azide))products =
>> list(chain(*products_tuples))print [Chem.MolToSmiles(prod) for prod in
>> products]*
>>
>> gives....
>>
>>
>>> *['C#CC(O)Cc1cnnn1CCC', 'C#CC(O)Cc1cn(CCC)nn1', 'C#CCC(O)c1cn(CCC)nn1',
>>> 'C#CCC(O)c1cnnn1CCC']*
>>
>>
>> ...and those all look like valid SMILES strings to me.
>>
>> I'm not sure exactly how to turn off all sanitization, but I did
>>
>> *Draw.MolsToGridImage(products, kekulize = False)*
>>
>> and as long that is invoked before UpdatePropertyCache, there is a
>> *different* error than the one I reported last time.
>>
>> ---------------------------------------------------------------------------RuntimeError
>>                               Traceback (most recent call 
>> last)<ipython-input-22-0305dfc54e69> in <module>()      7 print 
>> [Chem.MolToSmiles(prod) for prod in products]      8 ----> 9 
>> Draw.MolsToGridImage(products, kekulize = False)
>> /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)    400   if useSVG:    401     return 
>> _MolsToGridSVG(mols, molsPerRow=molsPerRow, subImgSize=subImgSize, 
>> legends=legends,--> 402                           
>> highlightAtomLists=highlightAtomLists, **kwargs)    403   else:    404     
>> return _MolsToGridImage(mols, molsPerRow=molsPerRow, subImgSize=subImgSize, 
>> legends=legends,
>> /Users/curt/anaconda2/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.pyc
>>  in _MolsToGridSVG(mols, molsPerRow, subImgSize, legends, 
>> highlightAtomLists, stripSVGNamespace, **kwargs)    374       nmol = 
>> rdMolDraw2D.PrepareMolForDrawing(mol, kekulize=kwargs.get('kekulize', True)) 
>>    375       d2d = rdMolDraw2D.MolDraw2DSVG(subImgSize[0], subImgSize[1])--> 
>> 376       d2d.DrawMolecule(nmol, legend=legends[i], 
>> highlightAtoms=highlights)    377       d2d.FinishDrawing()    378       txt 
>> = d2d.GetDrawingText()
>> RuntimeError: Pre-condition Violation
>>      getNumImplicitHs() called without preceding call to 
>> calcImplicitValence()
>>      Violation occurred on line 153 in file Code/GraphMol/Atom.cpp
>>      Failed Expression: d_implicitValence > -1
>>      RDKIT: 2016.09.2
>>      BOOST: 1_56
>>
>>
>>
>> On Thu, Jan 12, 2017 at 4:41 AM, Brian Kelley <fustiga...@gmail.com>
>> wrote:
>>
>>> The outputs of reaction are a bit confusing.
>>>
>>> Reactions can have multiple product templates so the output of
>>> RunReactants is a list of list of molecules.
>>>
>>> For products in result:
>>>   For molecule in products:
>>>      Molecule.UpdatePropertyCache()
>>>
>>> However, it looks like your reaction is generating non sensical
>>> molecules so you may want to draw with sanitizaton turned off so you can
>>> see the reaction output.
>>>
>>> ----
>>> Brian Kelley
>>>
>>> On Jan 11, 2017, at 9:11 PM, Curt Fischer <curt.r.fisc...@gmail.com>
>>> wrote:
>>>
>>> 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/tentrill
>>> ion/ipython_notebooks/blob/master/rdkit_smarts_reactions_nee
>>> ds_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
>>>
>>>
>>
>> ------------------------------------------------------------
>> ------------------
>> 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
>>
>>
>
------------------------------------------------------------------------------
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