Hi Nitzan,

On Wed, Dec 6, 2017 at 5:12 PM, Nitzan Tzanani <in.tzan...@gmail.com> wrote:

> I am trying to write a RDkit reaction, using Recursive SMARTS to better
> define the atoms participating in the reaction.
> For example, in this fragmentation reaction:
> rxn = AllChem.ReactionFromSmarts('[C:1][O:2][C:3]>>[C:1].[O:2]=[C:3]')
I would like for [C:1] to define the carbon as  [$(C1=CC=CC=C1),$(C1=CNC=C1
> )]

You can add recursive SMARTS directly to your reaction input. Here's a
silly example:

In [*16*]: rxn = AllChem.ReactionFromSmarts(

In [*17*]: ps = rxn.RunReactants((Chem.MolFromSmiles('CC(=O)O'

In [*18*]: ps

Out[*18*]: ((<rdkit.Chem.rdchem.Mol at 0x1049f0768>,),)

In [*19*]: Chem.MolToSmiles(ps[0][0])

Out[*19*]: 'CCNC(C)=O'

In [*20*]: ps = rxn.RunReactants((Chem.MolFromSmiles('CC(=O)O'

In [*21*]: ps

Out[*21*]: ()

(I prefer to kekulize the molecules).

Under most circumstances I would really suggest that you not do this. Using
the kekulized forms of the molecules in your reaction queries makes it
considerably more difficult to construct correct reactions. For example,
suppose you want to break a phenyl ring between two substituted carbons. If
you define this as SMARTS the reaction is relatively simple:

In [*37*]: rxn = AllChem.ReactionFromSmarts(

In [*42*]: ps = rxn.RunReactants((Chem.MolFromSmiles('c1cccc(O)c1N'),))

In [*43*]: Chem.SanitizeMol(ps[0][0])

Out[*43*]: rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE

In [*44*]: Chem.MolToSmiles(ps[0][0])

Out[*44*]: 'NC=CC=CC=CO'

If you wanted to do the same thing in the kekule form, you would have to
have two separate reactions: one that matches 'C1=CC=CC(*)=C1*' and one
that matches 'C=1CC=CC=C(*)C1*' (since either is a valid kekule form for
what you're trying to split).

As you can see, it's always possible to get the output in a kekulized form.

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

Reply via email to