Try to react only the carbon at the end of the chain with SMARTS

Introduction

In Define the reaction pattern with SMARTS and generate a reactant with RDKit, the reaction with SMARTS is performed with RDKit using the hydroxylation reaction of carbon atoms as an example. saw. However, it is not realistic to want to hydroxylate all carbon atoms. So, this time, I tried to specify more detailed conditions with SAMRTS. Specifically, I specified the methyl group at the end of the chain and tried to hydroxylate only that group.

Method

Last time, I wrote the following SMARTS.

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

However, this will react with any carbon atom. This time, I want to oxidize only the methyl group at the end of the chain. Since the terminal methyl group should have three hydrogen atoms, try changing the rules as follows.

'[CH3:1]>>[CH2:1]-[OH]'

let's try it. This time we will test the same compound as last time. Last time, four reactants were produced, but this time, only two terminal methyl groups should be produced.

reactant.png

When I tried it, two reactants were produced. let's see.

The first one. The terminal methyl group is reacting. metablite_0.png

The second. The other terminal methyl group is reacting. As expected.

metablite_1.png

By the way, SMARTS that reacts only two carbon atoms in which two hydrogen atoms in the middle of the chain are bonded is as follows.

'[CH2:1]>>[CH1:1]-[OH]'

Source

Finally, I will post the entire source including image generation.

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

#reference(rdkit-smarts)https://magattaca.hatenablog.com/entry/2019/02/10/194853
#reference(smarts) https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5515729/table/Tab1/?report=objectonly
# https://sourceforge.net/p/rdkit/mailman/message/36294482/

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:
        print("errro")
        pass


def main():
    reactant_1 = Chem.MolFromSmiles('COc2ccc1cccc(CCNC(C)=O)c1c2')
    generate_image(reactant_1, (300, 300), "./tmp", "reactant")

    #reaction_pattern = '[CH3:1]>>[CH2:1]-[OH]'
    reaction_pattern = '[CH3:1]>>[CH2: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()

in conclusion

――Strictly speaking, you may have to consider the electric charge. I'm not sure because it's chemically a shiroto. ――As a future task, when the reaction site is known, I would like to react only that site. Also, although it may not be related to SMARTS, I would like to evaluate the susceptibility to reaction. --As an application, define a reaction template group in SMARTS and use the reaction product generated from it, https://www.frontiersin.org/articles/10.3389/fphar.2019.01586/full It seems interesting to predict the reaction by Deep Learning like this.

Recommended Posts

Try to react only the carbon at the end of the chain with SMARTS
python> print> Redirected only at the end of processing?> Run with -u
Try to get the contents of Word with Golang
Try to automate the operation of network devices with Python
Try to extract the features of the sensor data with CNN
How to insert a specific process at the start and end of spider with scrapy
Try to solve the N Queens problem with SA of PyQUBO
Python Basic Course (at the end of 15)
Try to image the elevation data of the Geographical Survey Institute with Python
Try to separate the background and moving object of the video with OpenCV
Automation of creation of working hours table created at the end of the month with Selenium
Try to solve the fizzbuzz problem with Keras
Try installing only the core part of Ubuntu
I made you to express the end of the IP address with L Chika
Try to solve the man-machine chart with Python
How to try the friends-of-friends algorithm with pyfof
Specify the start and end positions of files to be included with qiitap
Send Gmail at the end of the process [Python]
[Verification] Try to align the point cloud with the optimization function of pytorch Part 1
Remove specific strings at the end of python
Try to simulate the movement of the solar system
How to get started with Visual Studio Online ~ The end of the environment construction era ~
It's Christmas, so I'll try to draw the genealogy of Jesus Christ with Cabocha
Coordinates of the right end of Label made with tkinter
Add information to the bottom of the figure with Matplotlib
Try to solve the problems / problems of "Matrix Programmer" (Chapter 1)
Try to visualize the room with Raspberry Pi, part 1
Try to solve the internship assignment problem with Python
Try to estimate the number of likes on Twitter
[Neo4J] ④ Try to handle the graph structure with Cypher
Try to specify the axis with PyTorch's Softmax function
I tried to automatically post to ChatWork at the time of deployment with fabric and ChatWork Api
[Introduction to SIR model] Predict the end time of each country with COVID-19 data fitting ♬
Create a 2D array by adding a row to the end of an empty array with numpy
Try to import to the database by manipulating ShapeFile of national land numerical information with Python
Try to visualize the nutrients of corn flakes that M-1 champion Milkboy said with Python
I tried to find the entropy of the image with python
Try scraping the data of COVID-19 in Tokyo with Python
Try to get the function list of Python> os package
Try to evaluate the performance of machine learning / regression model
Try to play with the uprobe that supports Systemtap directly
[Selenium/Python] Try to display the court case pdf at once
Get UNIXTIME at the beginning of today with a command
I want to improve efficiency with Python even in the experimental system (5) I want to send a notification at the end of the experiment with the slack API
Try to evaluate the performance of machine learning / classification model
I want to use only the normalization process of SudachiPy
Decorator that displays "FIN method name" at the end of the method
Try to improve the accuracy of Twitter like number estimation
Try to solve the problems / problems of "Matrix Programmer" (Chapter 0 Functions)
The story of displaying images with OpenCV or PIL (only)
Try to decipher the garbled attachment file name with Python
Get the source of the page to load infinitely with python.
Try to calculate the position of the transmitter from the radio wave propagation model with python [Wi-Fi, Beacon]
Try to factorial with recursion
The story of not being able to run pygame with pycharm
Save the results of crawling with Scrapy to the Google Data Store
[Note] Let's try to predict the amount of electricity used! (Part 1)
Become familiar with (want to be) around the pipeline of spaCy
I tried to automate the watering of the planter with Raspberry Pi
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)