I'm trying to set the configuration of a molecule with a double bond, but
it doesn't seem to be working. Here's my code:

===============
from rdkit.Chem import AllChem
from rdkit import Chem
from rdkit.Chem.rdchem import BondStereo

# Make a molecule with a double bond, no stereo specified (cis or trans)
smi = "NC(O)=C(C)S"
mol = Chem.MolFromSmiles(smi)

# Get that double bond
double_bonds = [b.GetIdx() for b in mol.GetBonds() if
b.GetBondTypeAsDouble() == 2 and b.GetStereo() is BondStereo.STEREONONE]
double_bond_index = double_bonds[0]
double_bond = mol.GetBondWithIdx(double_bond_index)

# It's stereo is STEREONONE at this point
print double_bond.GetStereo()

# Get the bonds connected to the first and second atoms
first_atom = double_bond.GetBeginAtom()
bonds_connected_to_first_atom = first_atom.GetBonds()

second_atom = double_bond.GetEndAtom()
bonds_connected_to_second_atom = second_atom.GetBonds()

# Get the indecies of those bonds, removing the central double bond.
bonds_connected_to_first_atom_indecies = [b.GetIdx() for b in
first_atom.GetBonds()]
bonds_connected_to_first_atom_indecies.remove(double_bond_index)

bonds_connected_to_second_atom_indecies = [b.GetIdx() for b in
second_atom.GetBonds()]
bonds_connected_to_second_atom_indecies.remove(double_bond_index)

# Set the directions of the for bonds connected to this double bond.
mol.GetBondWithIdx(bonds_connected_to_first_atom_indecies[0]).SetBondDir(Chem.BondDir.ENDUPRIGHT)
mol.GetBondWithIdx(bonds_connected_to_first_atom_indecies[1]).SetBondDir(Chem.BondDir.ENDDOWNRIGHT)

mol.GetBondWithIdx(bonds_connected_to_second_atom_indecies[0]).SetBondDir(Chem.BondDir.ENDUPRIGHT)
mol.GetBondWithIdx(bonds_connected_to_second_atom_indecies[1]).SetBondDir(Chem.BondDir.ENDDOWNRIGHT)

# I assume this should set the stereochemistry. But it doesn't appear to.
# It's stereo is STEREONONE at this point
print double_bond.GetStereo()
Chem.AssignStereochemistry(mol)
# Still STEREONONE
print double_bond.GetStereo()

# And when I print out the smiles, no stereochemistry is given.
print Chem.MolToSmiles(mol, isomericSmiles=True, canonical=True)
# CC(S)=C(N)O
===============

Any suggestions? Thanks!

~Jacob
-- 

Sent from my mobile.
------------------------------------------------------------------------------
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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to