Re: [Rdkit-discuss] DeleteSubstructs vs ReplaceSubstructs
Thank you, Pavel. Indeed, in this case the substructure is deleted properly and substitution gives only variant - clearly, the query knows that the side-atom is not aromatic and doesn't match it with the ring atom. I wonder why that doesn't happen when I create molecule from smiles or use other notation for smarts (C-C1:C:C:C:C:C:1). Actually, in my case the substructure is created automatically with FindMCS method, with smarts like this: [#6]-[#6]1:[#6]:[#6]:[#6]:[#6]:[#6]:1 and reading to use as substructure still produces two options for substitution and wrong result (chipping away part of the ring) for deletion. Maxim From: Pavel Polishchuk [mailto:pavel_polishc...@ukr.net] Sent: Freitag, 31. März 2017 08:18 To: rdkit-discuss@lists.sourceforge.net Subject: Re: [Rdkit-discuss] DeleteSubstructs vs ReplaceSubstructs Hi Maxim, if you change your query to SMARTS it would be possible to delete what you want m=Chem.MolFromSmiles('C1(C2=NC=CC=C2)=CC=CC(C)=C1') ss = Chem.MolFromSmarts('c1c1C') frag = AllChem.DeleteSubstructs(m, ss) print(Chem.MolToSmiles(frag)) Pavel. On 03/31/2017 07:41 AM, Popov, Maxim (Ext) wrote: Dear RDKit users, I am trying to remove a common substructure from a number of molecules (with AllChem.DeleteSubstructs). My problem is best illustrated by this short code: from rdkit import Chem from rdkit.Chem import AllChem m=Chem.MolFromSmiles('C1(C2=NC=CC=C2)=CC=CC(C)=C1') ss = Chem.MolFromSmiles('C1=CC=CC(C)=C1') hyd=Chem.MolFromSmiles('[H]') print("Substituting substructure with hydrogen") frags = AllChem.ReplaceSubstructs(m, ss,hyd) for frag in frags: print(Chem.MolToSmiles(frag)) print("\nDeleting substructure") frag = AllChem.DeleteSubstructs(m, ss) print(Chem.MolToSmiles(frag)) I create a toluene connected to pyridine and try to remove toluene. When replacing toluene substructure with hydrogen (AllChem.ReplaceSubstructs), I receive two sets of results: pyridine (with explicit hydrogen) and single carbon plus single hydrogen plus aromatic open chain (what is left from pyridine after removing one ring atom). When deleting the toluene substructure (AllChem.DeleteSubstructs), I receive just the open chain of ex-pyridine (corresponding to second set of the ReplaceSubstructs results). Is there a way of directing DeleteSubstructs method to a specific variant (in this case, leaving pyridine as a ring seems to be logical). Best regards, Maxim -- 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<mailto:Rdkit-discuss@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss -- 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
Re: [Rdkit-discuss] DeleteSubstructs vs ReplaceSubstructs
Hi Maxim, if you change your query to SMARTS it would be possible to delete what you want m=Chem.MolFromSmiles('C1(C2=NC=CC=C2)=CC=CC(C)=C1') ss = Chem.MolFromSmarts('c1c1C') frag = AllChem.DeleteSubstructs(m, ss) print(Chem.MolToSmiles(frag)) Pavel. On 03/31/2017 07:41 AM, Popov, Maxim (Ext) wrote: Dear RDKit users, I am trying to remove a common substructure from a number of molecules (with AllChem.DeleteSubstructs). My problem is best illustrated by this short code: fromrdkit importChem fromrdkit.Chem importAllChem m=Chem.MolFromSmiles(/'C1(C2=NC=CC=C2)=CC=CC(C)=C1'/) ss = Chem.MolFromSmiles(/'C1=CC=CC(C)=C1'/) hyd=Chem.MolFromSmiles(/'[H]'/) print(/"Substituting substructure with hydrogen"/) frags = AllChem.ReplaceSubstructs(m, ss,hyd) forfrag infrags: print(Chem.MolToSmiles(frag)) print(/"\nDeleting substructure"/) frag = AllChem.DeleteSubstructs(m, ss) print(Chem.MolToSmiles(frag)) I create a toluene connected to pyridine and try to remove toluene. When replacing toluene substructure with hydrogen (AllChem.ReplaceSubstructs), I receive two sets of results: pyridine (with explicit hydrogen) and single carbon plus single hydrogen plus aromatic open chain (what is left from pyridine after removing one ring atom). When deleting the toluene substructure (AllChem.DeleteSubstructs), I receive just the open chain of ex-pyridine (corresponding to second set of the ReplaceSubstructs results). Is there a way of directing DeleteSubstructs method to a specific variant (in this case, leaving pyridine as a ring seems to be logical). Best regards, Maxim -- 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 -- 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
[Rdkit-discuss] DeleteSubstructs vs ReplaceSubstructs
Dear RDKit users, I am trying to remove a common substructure from a number of molecules (with AllChem.DeleteSubstructs). My problem is best illustrated by this short code: from rdkit import Chem from rdkit.Chem import AllChem m=Chem.MolFromSmiles('C1(C2=NC=CC=C2)=CC=CC(C)=C1') ss = Chem.MolFromSmiles('C1=CC=CC(C)=C1') hyd=Chem.MolFromSmiles('[H]') print("Substituting substructure with hydrogen") frags = AllChem.ReplaceSubstructs(m, ss,hyd) for frag in frags: print(Chem.MolToSmiles(frag)) print("\nDeleting substructure") frag = AllChem.DeleteSubstructs(m, ss) print(Chem.MolToSmiles(frag)) I create a toluene connected to pyridine and try to remove toluene. When replacing toluene substructure with hydrogen (AllChem.ReplaceSubstructs), I receive two sets of results: pyridine (with explicit hydrogen) and single carbon plus single hydrogen plus aromatic open chain (what is left from pyridine after removing one ring atom). When deleting the toluene substructure (AllChem.DeleteSubstructs), I receive just the open chain of ex-pyridine (corresponding to second set of the ReplaceSubstructs results). Is there a way of directing DeleteSubstructs method to a specific variant (in this case, leaving pyridine as a ring seems to be logical). Best regards, Maxim -- 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