smilesdrawer / app.py
simonduerr's picture
Update app.py
3a5c939
raw
history blame
1.63 kB
import gradio as gr
def update(smiles):
x = (
f"""<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<svg data-smiles="{smiles}" />
<script type="text/javascript" src="https://unpkg.com/smiles-drawer@2.0.1/dist/smiles-drawer.min.js"></script>
<script>
SmiDrawer.apply();
</script>
</body>
</html>
"""
)
return f"""<iframe style="width: 100%; min-height: 600px;margin:0 auto" name="result" allow="midi; geolocation; microphone; camera;
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
allow-scripts allow-same-origin allow-popups
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
with gr.Blocks() as demo:
gr.Markdown("# GeoMol: Torsional Geometric Generation of Molecular 3D Conformer Ensembles")
gr.Markdown(">Octavian-Eugen Ganea, Lagnajit Pattanaik, Connor W. Coley, Regina Barzilay, Klavs Jensen, William Green, Tommi S. Jaakkola 21 May 2021 (modified: 13 Jan 2022) NeurIPS 2021 Spotlight")
with gr.Column():
inp = gr.Textbox(label="SMILES string", placeholder="CCCC")
out = gr.HTML()
btn = gr.Button("Run")
gr.Examples(["CCCCC", "OC(C(=O)O[C@H]1C[N+]2(CCCOC3=CC=CC=C3)CCC1CC2)(C1=CC=CS1)C1=CC=CS1"], inp, out, update, cache_examples=True)
btn.click(fn=update, inputs=inp, outputs=out)
demo.launch()