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.
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.
When I tried it, two reactants were produced. let's see.
The first one. The terminal methyl group is reacting.
The second. The other terminal methyl group is reacting. As expected.
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]'
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()
――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