Re: [Rdkit-discuss] ReplaceSubstructs Output
Hi Greg, Thanks or the answer, There is a small example that replaces terminal hydrogens with methyl groups. --- def mutatemol(mol, outputsdf): outf=open(outputsdf, 'w+') writer = Chem.SDWriter(outf) patterns = ('[C,c;!H0]','[N;!H0]') replacements = ('[#6](C)','[N](C)') if (mol.HasProp('_Name')): mName = mol.GetProp('_Name') else: mName = 'StructX' for i in range(0, len(patterns)): pat = Chem.MolFromSmarts(patterns[i]) repl = Chem.MolFromSmarts(replacements[i]) mutmol = AllChem.ReplaceSubstructs(mol,pat,repl) for j in range(0, len(mutmol)): mname ='%s_%d_%d'%(mName,i,j) mutmol[j].SetProp('_Name', mname) AllChem.SanitizeMol(mutmol[j]) AllChem.Compute2DCoords(mutmol[j]) writer.write(mutmol[j]) writer.flush() outf.close() --- I would like to replace the second for loop with a function that puts structures from mutmol in a temporary container of sorts. Is this possible? Its not critical but it I think it would give me more flexibility in how to manipulate the output. Regards Basil From: Greg Landrum [mailto:greg.land...@gmail.com] Sent: 07 November 2013 02:57 To: ba...@drugdesigner.net Cc: RDKit Discuss Subject: Re: [Rdkit-discuss] ReplaceSubstructs Output Hi Basil On Tue, Nov 5, 2013 at 1:31 PM, Basil Hartzoulakis ba...@drugdesigner.net wrote: Hello, I am building a tool with multiple calls of the ReplaceSustructs on the same structure. Is there any easy way to place the output of each call in a pickle or some temporary holder? At the moment I have to iterate through each output and the code looks a bit awkward. I'm not quite sure what you mean. Can you provide a short code snippet that shows the repeated calls? -greg -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
[Rdkit-discuss] AllChem.ReplaceSubstructs
Hello, I have a question about AllChem.ReplaceSubstructs(mol, query,replacement). As I understand, it replaces 'query' pattern in 'mol' by 'replacement' fragment. It is clear which atom from 'mol' is the joining atom, but which is the joining atom in 'replacement'? The atom with index=0? Is it possible to specify which atom in the 'replacement' should be bonded to 'mol'? It would be lovely to be able to do so, because the only alternative (using reaction SMARTS) is much, much slower. If not, is it possible to generate (from a given Mol object) a SMILES string starting from the specified atom index? Thanks, Michal -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] AllChem.ReplaceSubstructs
Hello again, I browsed through the sources and I found the answer to my question: the atom at index 0 from the replacement is used for the new bond. It would be nice to be able to specify the index of this bonding atom as a parameter in AllChem.ReplaceSubstructs. Is it possible to reorder atoms in a molecule (i.e. to have a chosen atom at index 0)? Best wishes, Michal On 7 November 2013 11:38, Michal Krompiec michal.kromp...@gmail.com wrote: Hello, I have a question about AllChem.ReplaceSubstructs(mol, query,replacement). As I understand, it replaces 'query' pattern in 'mol' by 'replacement' fragment. It is clear which atom from 'mol' is the joining atom, but which is the joining atom in 'replacement'? The atom with index=0? Is it possible to specify which atom in the 'replacement' should be bonded to 'mol'? It would be lovely to be able to do so, because the only alternative (using reaction SMARTS) is much, much slower. If not, is it possible to generate (from a given Mol object) a SMILES string starting from the specified atom index? Thanks, Michal -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] AllChem.ReplaceSubstructs
Dear Michal, On Thu, Nov 7, 2013 at 12:46 PM, Michal Krompiec michal.kromp...@gmail.comwrote: Hello again, I browsed through the sources and I found the answer to my question: the atom at index 0 from the replacement is used for the new bond. It would be nice to be able to specify the index of this bonding atom as a parameter in AllChem.ReplaceSubstructs. Is it possible to reorder atoms in a molecule (i.e. to have a chosen atom at index 0)? Indeed there is, the functionality was added at the last minute to the 2013.09 release. Here's how you use it: In [2]: m = Chem.MolFromSmiles('NCO') In [3]: print Chem.MolToMolBlock(m) RDKit 3 2 0 0 0 0 0 0 0 0999 V2000 0.0.0. N 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. O 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 2 3 1 0 M END In [4]: m2 = Chem.RenumberAtoms(m,(1,2,0)) In [5]: print Chem.MolToMolBlock(m2) RDKit 3 2 0 0 0 0 0 0 0 0999 V2000 0.0.0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. O 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. N 0 0 0 0 0 0 0 0 0 0 0 0 3 1 1 0 1 2 1 0 M END -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] AllChem.ReplaceSubstructs
Greg, Is it available in c++? Also, just to make sure - the argument is a list of old positions for each new position? Thanks, Igor On Thu, Nov 7, 2013 at 8:41 AM, Greg Landrum greg.land...@gmail.com wrote: Dear Michal, On Thu, Nov 7, 2013 at 12:46 PM, Michal Krompiec michal.kromp...@gmail.com wrote: Hello again, I browsed through the sources and I found the answer to my question: the atom at index 0 from the replacement is used for the new bond. It would be nice to be able to specify the index of this bonding atom as a parameter in AllChem.ReplaceSubstructs. Is it possible to reorder atoms in a molecule (i.e. to have a chosen atom at index 0)? Indeed there is, the functionality was added at the last minute to the 2013.09 release. Here's how you use it: In [2]: m = Chem.MolFromSmiles('NCO') In [3]: print Chem.MolToMolBlock(m) RDKit 3 2 0 0 0 0 0 0 0 0999 V2000 0.0.0. N 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. O 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 2 3 1 0 M END In [4]: m2 = Chem.RenumberAtoms(m,(1,2,0)) In [5]: print Chem.MolToMolBlock(m2) RDKit 3 2 0 0 0 0 0 0 0 0999 V2000 0.0.0. C 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. O 0 0 0 0 0 0 0 0 0 0 0 0 0.0.0. N 0 0 0 0 0 0 0 0 0 0 0 0 3 1 1 0 1 2 1 0 M END -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] AllChem.ReplaceSubstructs
On Thu, Nov 7, 2013 at 4:06 PM, Igor Filippov igor.v.filip...@gmail.comwrote: Greg, Is it available in c++? Also, just to make sure - the argument is a list of old positions for each new position? Yes, and yes. It's MolOps::renumberAtoms(): http://rdkit.org/docs/cppapi/namespaceRDKit_1_1MolOps.html#a96649cb8953d6b3ab6dfd43f639cafd1 -greg -- November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231iu=/4140/ostg.clktrk___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss