Dear list, I have been trying to replace this SMARTS pattern in a ring:
'c(=O)[nH]' By this SMILES fragment: 'c(O)n' My trials using a single SMARTS pattern search then replace break open the ring, which is not what I want. My not working trial code: --- mol = Chem.MolFromSmiles('O=c1[nH]cccc1') pat = Chem.MolFromSmarts('c(=O)[nH]') rep = Chem.MolFromSmarts('c(O)n') res = AllChem.ReplaceSubstructs(mol,pat,rep) Chem.MolToSmiles(res[0]) 'ccccc(n)O' --- The example molecule is just an example; the ring might be smaller and/or have more heteroatoms. Should I use a chemical reaction for this? Am I forced to describe full rings in both SMARTS patterns?! I don't want to have to enumerate all the possibilities... I can make it ~work~ using two replacements: first 'c(=O)' to 'c(O)' then '[nH]' to 'n' But this is less precise than what I really want and I believe it will change molecules or places I don't want to change. Thanks a lot and happy new year! F. _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss