In RDKit, I would like to define a reaction pattern in SMARTS and generate a product from the reactant based on that pattern.
Please refer to the references.
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.
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()
Four products were obtained. One was an error due to the charge when sanitizing. Let's check the result with an image.
--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.
-Chemical reaction with RDKit: How to handle reaction formulas in chemoinformatics -Story of playing with SMARTS notation and RDKit chemical reaction
Recommended Posts