File size: 1,559 Bytes
3c50437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cacd6c4
 
 
 
 
 
3c50437
 
 
947fcf9
 
 
 
cacd6c4
2aa230e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c50437
 
 
cacd6c4
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

import gradio as gr
from gradio_molecule3d import Molecule3D

import os

example = Molecule3D().example_inputs()


reps =    [
    {
      "model": 0,
      "chain": "",
      "resname": "",
      "style": "cartoon",
      "color": "whiteCarbon",
      "residue_range": "",
      "around": 0,
      "byres": False,
      "visible": False,
    },
  ]

def predict(x):
    print("predict function", x)
    return x

#doesn't work
#demo = gr.Interface(
#     predict,
#     Molecule3D(label="Molecule3D", reps=reps),  # interactive version of your component
#     Molecule3D(),  # static version of your component
#     examples=[[example]],  # uncomment this line to view the "example version" of your component
# )

#works
with gr.Blocks() as demo:
    #gr.Markdown("# 3dmol.js Molecule Viewer")
    #inp = Molecule3D(label="Molecule3D", reps=reps)
    #gr.Markdown("Viewer disabled")
    inp = Molecule3D(label="Molecule3D", reps=reps, showviewer=False)
    out = Molecule3D(label="Molecule3D", reps=reps)
    gr.Markdown(""" 
    You can configure the default rendering of the molecule by adding a list of representations
    <code>
        reps =    [
        {
          "model": 0,
          "chain": "",
          "resname": "",
          "style": "cartoon",
          "color": "whiteCarbon",
          "residue_range": "",
          "around": 0,
          "byres": False,
          "visible": False,
        },
      ]
    </code>
    """)
    btn = gr.Button("Predict")
    btn.click(predict, inputs=inp, outputs=out)

demo.launch()
# blocks.launch()