Discussion:
[Rdkit-discuss] ReplaceSubstructs changes chirality
Jan Halborg Jensen
2017-05-27 13:11:21 UTC
Permalink
The code below protonates select nitrogen atoms using ReplaceSubstructs but in some cases the chirality is changed, despite the fact that I used MolToSmiles(xx,isomericSmiles=True)

Any help appreciated



Output

C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F [NX2;H0] [NH+] C[C@@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)[NH+]=C(N)OCC1(F)F

C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F [nX2;H0] [NH+] C[C@]1(c2cc(NC(=O)c3ccc(C#N)c[nH+]3)ccc2F)N=C(N)OCC1(F)F


code:


from rdkit import Chem

from rdkit.Chem import AllChem


smartsref = ( ('[NX2;H1]','[NH2+]'),

('[NX2;H0]','[NH+]'),

('[nX2;H0]','[NH+]'))



smiles = "C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F"

m = Chem.MolFromSmiles(smiles)


for (smarts1, smiles2) in smartsref:

patt1 = Chem.MolFromSmarts(smarts1)

patt2 = Chem.MolFromSmiles(smiles2)

if(m.HasSubstructMatch(patt1)):

newmol = AllChem.ReplaceSubstructs(m, patt1, patt2)

for ion in newmol:

ion = Chem.MolToSmiles(ion,isomericSmiles=True)

print smiles,smarts1,smiles2,ion
Jan Halborg Jensen
2017-05-27 13:44:23 UTC
Permalink
Also

newmol = AllChem.ReplaceSubstructs(m, patt1, patt2, useChirality=True)

doesn't help
________________________________
From: Jan Halborg Jensen
Sent: Saturday, May 27, 2017 3:11 PM
To: rdkit-***@lists.sourceforge.net
Subject: ReplaceSubstructs changes chirality



The code below protonates select nitrogen atoms using ReplaceSubstructs but in some cases the chirality is changed, despite the fact that I used MolToSmiles(xx,isomericSmiles=True)

Any help appreciated



Output

C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F [NX2;H0] [NH+] C[C@@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)[NH+]=C(N)OCC1(F)F

C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F [nX2;H0] [NH+] C[C@]1(c2cc(NC(=O)c3ccc(C#N)c[nH+]3)ccc2F)N=C(N)OCC1(F)F


code:


from rdkit import Chem

from rdkit.Chem import AllChem


smartsref = ( ('[NX2;H1]','[NH2+]'),

('[NX2;H0]','[NH+]'),

('[nX2;H0]','[NH+]'))



smiles = "C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F"

m = Chem.MolFromSmiles(smiles)


for (smarts1, smiles2) in smartsref:

patt1 = Chem.MolFromSmarts(smarts1)

patt2 = Chem.MolFromSmiles(smiles2)

if(m.HasSubstructMatch(patt1)):

newmol = AllChem.ReplaceSubstructs(m, patt1, patt2)

for ion in newmol:

ion = Chem.MolToSmiles(ion,isomericSmiles=True)

print smiles,smarts1,smiles2,ion
Greg Landrum
2017-05-31 07:14:10 UTC
Permalink
HI Jan,

That is certainly a bug. It'd be good to report in github (or I can do if
if you don't have a github account).

This may not be trivial to fix but a workaround is to use the RDKit's
ChemicalReaction functionality (which tends to be more robust when it comes
to chirality):

In [31]: rxn = AllChem.ReactionFromSmarts('[NX2;H0:1]>>[*H+:1]')

In [32]: rxn
Out[32]: <rdkit.Chem.rdChemReactions.ChemicalReaction at 0x10bc6df80>

In [33]: ps = rxn.RunReactants((Chem.MolFromSmiles('C[C@
]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F'),))

In [34]: len(ps)
Out[34]: 1

In [35]: Chem.MolToSmiles(ps[0][0],isomericSmiles=True)
Out[35]: 'C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)[NH+]=C(N)OCC1(F)F'



You could even use this to simplify things a bit and combine two of your
protonation patterns into one:

In [36]: rxn = AllChem.ReactionFromSmarts('[#7X2;H0:1]>>[*H+:1]') # <-
matches aromatic and aliphatic N

In [37]: ps = rxn.RunReactants((Chem.MolFromSmiles('C[C@
]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)N=C(N)OCC1(F)F'),))

In [38]: len(ps)
Out[38]: 2

In [39]: [Chem.MolToSmiles(x[0],isomericSmiles=True) for x in ps]
Out[39]:
['C[C@]1(c2cc(NC(=O)c3ccc(C#N)c[nH+]3)ccc2F)N=C(N)OCC1(F)F',
'C[C@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)[NH+]=C(N)OCC1(F)F']



Best,
-greg
Post by Jan Halborg Jensen
The code below protonates select nitrogen atoms using ReplaceSubstructs
but in some cases the chirality is changed, despite the fact that I
used MolToSmiles(xx,isomericSmiles=True)
Any help appreciated
Output
@]1(c2cc(NC(=O)c3ccc(C#N)cn3)ccc2F)[NH+]=C(N)OCC1(F)F
]1(c2cc(NC(=O)c3ccc(C#N)c[nH+]3)ccc2F)N=C(N)OCC1(F)F
from rdkit import Chem
from rdkit.Chem import AllChem
smartsref = ( ('[NX2;H1]','[NH2+]'),
('[NX2;H0]','[NH+]'),
('[nX2;H0]','[NH+]'))
m = Chem.MolFromSmiles(smiles)
patt1 = Chem.MolFromSmarts(smarts1)
patt2 = Chem.MolFromSmiles(smiles2)
newmol = AllChem.ReplaceSubstructs(m, patt1, patt2)
ion = Chem.MolToSmiles(ion,isomericSmiles=True)
print smiles,smarts1,smiles2,ion
------------------------------------------------------------
------------------
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
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Loading...