Re: [Rdkit-discuss] A couple of questions regarding ReactionFromSmarts
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Greg L. <gre...@gm...> - 2010-06-18 05:08:14
|
Dear all, A followup/update on a request from a couple weeks ago: On Fri, Jun 4, 2010 at 6:13 AM, Greg Landrum <gre...@gm...> wrote: > On Thu, Jun 3, 2010 at 7:51 PM, James Davidson <J.D...@ve...> wrote: >> >> (1) I see that the reaction objects can be created from MDL Reaction >> Files/Blocks - is there a way to do the reverse, and save a reaction object >> in MDL .rxn format? I tried using investigating the rxn.ToBinary() >> attribute, but didn't get very far... The reason I wanted to do this, is >> that I was trying to figure-out how to generate a form of the reaction >> object (generated from reaction SMARTS) that was suitable for converting >> into a 2D depiction of the transformation. > > At the moment the reactions are essentially input-only. There's really > no way to get them out in any format that could be used elsewhere. > This is a sadly missing feature: it would be really nice to be able to > generate either .rxn files (or at least reaction smarts) from > reactions. I will add a feature request for this, but it may take a > while to happen.[1] I've added a partial solution to this that at least provides some help with visualizing reactions. Here's my reaction: [12]>>> rxn = AllChem.ReactionFromSmarts('[C:1](=[O:2])-[O;-,H].[N;!$(N-C=[O,N,S]);!$(N=*):3]>>[C:1](=[O:2])-[N:3]') You can now output reaction smarts: [13]>>> AllChem.ReactionToSmarts(rxn) Out[13] '[C:1](=[O:2])-[O;-,H1].[N;!$(N-C=[O,N,S]);!$(N=*):3]>>[C:1](=[O:2])-[N:3]' You can also generate coordinates for a reaction and the create an rxn file: [14]>>> AllChem.Compute2DCoordsForReaction(rxn) [15]>>> print AllChem.ReactionToRxnBlock(rxn) ------> print(AllChem.ReactionToRxnBlock(rxn)) $RXN RDKit 2 1 $MOL RDKit 2D 3 2 0 0 0 0 0 0 0 0999 V2000 -0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 1 0 0 -0.0000 -1.5000 0.0000 O 0 0 0 0 0 0 0 0 0 2 0 0 -0.0000 1.5000 0.0000 * 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 0 1 3 1 0 V 3 [O;-,H1] M END $MOL RDKit 2D 1 0 0 0 0 0 0 0 0 0999 V2000 0.5000 0.0000 0.0000 * 0 0 0 0 0 0 0 0 0 3 0 0 V 1 [N;!$(N-C=[O,N,S]);!$(N=*):3] M END $MOL RDKit 2D 3 2 0 0 0 0 0 0 0 0999 V2000 1.5000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 1 0 0 1.5000 -1.5000 0.0000 O 0 0 0 0 0 0 0 0 0 2 0 0 1.5000 1.5000 0.0000 N 0 0 0 0 0 0 0 0 0 3 0 0 1 2 2 0 1 3 1 0 M END #---------------------------------------- Notice that query features on atoms in the rxn blocks are not output as property ctab query features. Instead I use the atom-value feature of ctabs and output the SMARTS query for the atoms. This has the marked disadvantage that it won't actually generate reactions that do sensible things in other tools, but at least you can do some debugging of reactions. At some point in the future it would be nice to have ctab queries handled correctly, but this is at least something. These changes are checked into subversion and will be in the next release. Best Regards, -greg |