Spaces:
Build error
Build error
simonduerr
commited on
Commit
·
e8e9336
1
Parent(s):
5c34e1f
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
def update(smiles):
|
6 |
+
x = (
|
7 |
+
"""<!DOCTYPE html>
|
8 |
+
<html>
|
9 |
+
<head>
|
10 |
+
<meta charset="utf-8">
|
11 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
12 |
+
</head>
|
13 |
+
|
14 |
+
<body>
|
15 |
+
<img data-smiles="OC(C(=O)O[C@H]1C[N+]2(CCCOC3=CC=CC=C3)CCC1CC2)(C1=CC=CS1)C1=CC=CS1"
|
16 |
+
data-smiles-options="{ 'width': 800, 'height': 800 }" />
|
17 |
+
|
18 |
+
|
19 |
+
<script type="text/javascript" src="https://unpkg.com/smiles-drawer@2.0.1/dist/smiles-drawer.min.js"></script>
|
20 |
+
<script>
|
21 |
+
SmiDrawer.apply();
|
22 |
+
</script>
|
23 |
+
</body>
|
24 |
+
</html>
|
25 |
+
"""
|
26 |
+
)
|
27 |
+
|
28 |
+
return f"""<iframe style="width: 800px; height: 800px" name="result" allow="midi; geolocation; microphone; camera;
|
29 |
+
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
|
30 |
+
allow-scripts allow-same-origin allow-popups
|
31 |
+
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
32 |
+
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
33 |
+
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
gr.Markdown("Smiles viewer")
|
36 |
+
with gr.Row():
|
37 |
+
inp = gr.Textbox(label="SMILES string", placeholder="CCCC")
|
38 |
+
out = gr.HTML()
|
39 |
+
btn = gr.Button("Run")
|
40 |
+
btn.click(fn=update, inputs=inp, outputs=out)
|
41 |
+
|
42 |
+
demo.launch()
|