Hi Eddie and Greg, Thanks for your quick responses and solutions, they are really helpful.
Thanks, Sarah On 29 Sep 2011, at 03:51, Greg Landrum wrote: > Sarah, > > On Wed, Sep 28, 2011 at 7:53 PM, Eddie Cao <cao.yi...@gmail.com> > wrote: >> I suggest the following alternative: >> 1. first make a copy so you don't change the original molecule >>>>> from copy import deepcopy >>>>> mol2 = deepcopy(mol) >> Now set the atoms you'd like to remove to dummy atoms with atomic >> number 0 >>>>> mol2.GetAtomWithIdx(2).SetAtomicNum(0) >>>>> mol2.GetAtomWithIdx(3).SetAtomicNum(0) >> Now remove dummy atoms using a query >>>>> mol3 = Chem.DeleteSubstructs(mol2, Chem.MolFromSmarts('[#0]')) >> You get what you are looking for >>>>> Chem.MolToSmiles(mol3) >> 'CN' > > Eddie's solution is a nice one that should work pretty well. > > Another possible approach is to go ahead and use an EditableMol as you > originally started, but to make sure that you remove the atoms > starting with the highest numbers first: > >>>> m = Chem.MolFromSmiles('FCCCl') >>>> em1 = Chem.EditableMol(m) >>>> atomsToRemove=[0,3] >>>> atomsToRemove.sort(reverse=True) >>>> for atom in atomsToRemove: > .. em1.RemoveAtom(atom) > .. >>>> m2 = em1.GetMol() >>>> Chem.SanitizeMol(m2) >>>> Chem.MolToSmiles(m2) > 'CC' > > This should avoid the problem you were encountering. > > -greg The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer and network. ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss