Spaces:
Sleeping
Sleeping
File size: 771 Bytes
535ef26 7ced3ac 535ef26 4513aee 535ef26 d1c7538 535ef26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import gradio as gr
from rdkit import Chem
from rdkit.Chem import AllChem, Draw
def get_sdf(smile: str):
"""
Convert a SMILES string to an SDF string
Args:
smile: The SMILES string of the molecule
Returns:
The SDF string of the molecule
"""
mol = Chem.MolFromSmiles(smile)
molH = Chem.AddHs(mol)
AllChem.EmbedMolecule(molH)
AllChem.MMFFOptimizeMolecule(molH)
img = Chem.Draw.MolToImage(molH)
sdf = Chem.MolToMolBlock(molH)
return sdf, img
gradio_app = gr.Interface(
get_sdf,
inputs=[gr.Textbox(label="SMILES to convert to SDF")],
outputs=[gr.Textbox(label="SDF: ", lines=20), gr.Image(label="Image: ")],
title="Convert SMILES to SDF",
)
if __name__ == "__main__":
gradio_app.launch(mcp_server=True) |