[PYTHON] Define the reaction pattern with SMARTS with RDKit and generate a reactant

Introduction

In RDKit, I would like to define a reaction pattern in SMARTS and generate a product from the reactant based on that pattern.

environment

Method

Please refer to the references.

Reaction I tried this time

This time I would like to try the hydroxylation reaction of carbon atoms. The SMARTS pattern is as follows.

[C:1]>>[C:1][OH]

For the reaction product, the following compounds were tried.

query.png

Source

The source is as follows. I tried to output all the products produced by the reaction to an image.

from rdkit.Chem import AllChem
from rdkit.Chem.Draw import rdMolDraw2D
from io import BytesIO
from cairosvg import svg2png
from IPython.display import SVG
from rdkit import Chem

#Image output
def generate_image(mol, size, path, name):

    image_data = BytesIO()
    view = rdMolDraw2D.MolDraw2DSVG(size[0], size[1])
    tm = rdMolDraw2D.PrepareMolForDrawing(mol)

    view.DrawMolecule(tm)
    view.FinishDrawing()
    svg = view.GetDrawingText()
    SVG(svg.replace('svg:', ''))
    print(path + "/" + name)
    try:
        svg2png(bytestring=svg, write_to=path + "/" + name + ".png ")
    except:
        pass


def main():
    reactant_1 = Chem.MolFromSmiles('COc2ccc1cccc(CCNC(C)=O)c1c2')
    reaction_pattern = '[C:1]>>[C:1][OH]'
    rxn = AllChem.ReactionFromSmarts(reaction_pattern)
    x = rxn.RunReactants([reactant_1])
    for i, mol in enumerate(x):
        print(mol[0])
        try:
            Chem.SanitizeMol(mol[0])
            generate_image(mol[0], (300, 300), "tmp", "metablite_{0}".format(i))
        except:
            print("Error")
            print(Chem.MolToMolBlock(mol[0]))


if __name__ == "__main__":
    main()

Verification

Four products were obtained. One was an error due to the charge when sanitizing. Let's check the result with an image.

Product 1

metablite_0.png

Product 2

metablite_1.png

Product 3

metablite_2.png

Product 4

metablite_4.png

Product 5 (charge error due to sanitizing process)

error_metabolite.png

Consideration

--The result is as expected. --There was no reaction of the aromatic ring to the C atom, but the reason is not clear. It is necessary to confirm the specifications (future issues) —— In any case, it will be necessary to determine whether the produced reactant is a valid compound.

References

-Chemical reaction with RDKit: How to handle reaction formulas in chemoinformatics -Story of playing with SMARTS notation and RDKit chemical reaction

Recommended Posts

Define the reaction pattern with SMARTS with RDKit and generate a reactant
Try to generate a cyclic peptide from an amino acid sequence with Python and RDKit
Make a BLE thermometer and get the temperature with Pythonista3
Generate physically sturdy shapes with GAN and print with a 3D printer
Solve the Python knapsack problem with a branch and bound method
Generate a normal distribution with SciPy
Generate a Pre-Signed URL with golang
[Python] Generate a password with Slackbot
Replace the directory name and the file name in the directory together with a Linux command.
Calculate the shortest route of a graph with Dijkstra's algorithm and Python
Generate a list packed with the number of days in the current month.
C> link> Define a string and access the index> * dstPtr ++ = "0123456789ABCDEF" [nibble];
The story of making a sound camera with Touch Designer and ReSpeaker
Make a DNN-CRF with Chainer and recognize the chord progression of music
Create a command to search for similar compounds from the target database with RDKit and check the processing time