File size: 1,572 Bytes
e8e9336
 
 
 
 
3c6b27e
ee33c53
e8e9336
 
 
 
3ef21a4
 
 
 
e8e9336
 
 
daccaa2
624e14a
 
 
 
e8e9336
 
 
 
3ef21a4
e8e9336
 
 
 
 
 
8ec6bbe
94216aa
0d7cf39
e8e9336
 
 
8ec6bbe
8492c94
e8e9336
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
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">
            <link
      href="https://fonts.googleapis.com/css?family=Droid+Sans:400,700"
      rel="stylesheet"
    />
        </head>
        
        <body>
            <svg style="height:380px;width:100%" 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%; height: 400px;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("# Smilesviewer")
    gr.Markdown("Using for academic work? Please cite: 10.1021/acs.jcim.7b00425")
    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)
    
    btn.click(fn=update, inputs=inp, outputs=out)

demo.launch()