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)