On Dec 9, 2016, at 9:50 PM, Brian Kelley wrote:
> >>> from rdkit import Chem
> >>> m = Chem.MolFromSmiles("F/C=C/F")
> >>> for bond in m.GetBonds():
> ...    print bond.GetStereo()
> ... 
> STEREONONE
> STEREOE
> STEREONONE
> 
> However, setting bond stereo doesn't appear to be exposed.

I thought I knew a way to change it, via GetBondDir()/SetBondDir() on the 
directional bonds. It doesn't seem to work.

First, get the existing bond directions:

>>> from rdkit import Chem
>>> mol = Chem.MolFromSmiles("F/C=C/F")
>>> for bond in mol.GetBonds():
...   print(bond.GetBondDir())
... 
ENDUPRIGHT
NONE
ENDUPRIGHT


I'll change the first "/" to a "\" (That's "\\" when escaped for a normal 
Python string.)

>>> mol.GetBondWithIdx(0)
<rdkit.Chem.rdchem.Bond object at 0x10fe26600>
>>> mol.GetBondWithIdx(0).GetBondDir()
rdkit.Chem.rdchem.BondDir.ENDUPRIGHT
>>> mol.GetBondWithIdx(0).SetBondDir(Chem.BondDir.ENDDOWNRIGHT)

If I generate the SMILES I see the old "F/C=C/F" instead of the new direction. 
I need to clear internal computed properties when I make structure edits:

>>> Chem.MolToSmiles(mol, isomericSmiles=True)
'F/C=C/F'
>>> mol.ClearComputedProps()
>>> Chem.MolToSmiles(mol, isomericSmiles=True)
'F/C=C\\F'

I'll set the directions to "NONE" and clear computed properties. The SMILES is 
correct:

>>> mol.GetBondWithIdx(0).SetBondDir(Chem.BondDir.NONE)
>>> mol.GetBondWithIdx(2).SetBondDir(Chem.BondDir.NONE)
>>> mol.ClearComputedProps()
>>> Chem.MolToSmiles(mol, isomericSmiles=True)
'FC=CF'

although the stereo setting is unchanged:

>>> for bond in mol.GetBonds():
...   print(bond.GetStereo())
... 
STEREONONE
STEREOE
STEREONONE

I expected it to give me all STEREONONEs, as if it were the same as the 
following:

>>> mol2 = Chem.MolFromSmiles("FC=CF")
>>> for bond in mol2.GetBonds():
...   print(bond.GetStereo())
... 
STEREONONE
STEREONONE
STEREONONE




                                Andrew
                                da...@dalkescientific.com



------------------------------------------------------------------------------
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