Going to reply in two parts, because the second question is easier to answer than the first.
On Thu, Feb 2, 2012 at 7:59 PM, JP <[email protected]> wrote: > > 2) This is more tricky, as it involves our friend deuterium. Why isn't the > whole mol replaced? Why is it not being matched? > >>>> b = Chem.MolFromSmiles('C(=O)O[2H]') >>>> rep = AllChem.ReplaceSubstructs(b, Chem.MolFromSmarts('C(=O)O[2H]'), >>>> Chem.MolFromSmiles('C(=O)[O-]', sanitize=False), replaceAll=True)[0] >>>> print Chem.MolToSmiles(rep, isomericSmiles=True) > > [2H]OC=O # expecting C(=O)[O-] > > Thanks for any help/insights you can provide... [2H] doesn't mean what you think it does when you do MolFromSmarts: In [19]: m = Chem.MolFromSmiles('C(=O)O[2H]') In [20]: m.HasSubstructMatch(Chem.MolFromSmiles('[2H]')) Out[20]: True So far so good... what about with SMARTS? In [21]: m.HasSubstructMatch(Chem.MolFromSmarts('[2H]')) Out[21]: False The following helps to understand what's going on here: In [22]: Chem.MolToSmarts(Chem.MolFromSmarts('[2H]')) Out[22]: '[2*&H1]' an "H" in a SMARTS doesn't mean an atom which is a hydrogen, it means an atom which is connected to a hydrogen. You can get the behavior you expect as follows: In [24]: rep = AllChem.ReplaceSubstructs(m, Chem.MolFromSmiles('C(=O)O[2H]'), Chem.MolFromSmiles('C(=O)[O-]'), replaceAll=True)[0] In [26]: Chem.MolToSmiles(rep) Out[26]: 'O=C[O-]' (Note, I also removed a "sanitize=False", but that doesn't affect this) -greg ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

