Spaces:
Build error
Build error
simonduerr
commited on
Commit
•
818f706
1
Parent(s):
ead96cc
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
|
|
|
3 |
def get_pdb(pdb_code="", filepath=""):
|
4 |
if pdb_code is None or pdb_code == "":
|
5 |
try:
|
@@ -10,6 +11,7 @@ def get_pdb(pdb_code="", filepath=""):
|
|
10 |
os.system(f"wget -qnc https://files.rcsb.org/view/{pdb_code}.pdb")
|
11 |
return f"{pdb_code}.pdb"
|
12 |
|
|
|
13 |
def read_mol(molpath):
|
14 |
with open(molpath, "r") as fp:
|
15 |
lines = fp.readlines()
|
@@ -17,7 +19,7 @@ def read_mol(molpath):
|
|
17 |
for l in lines:
|
18 |
mol += l
|
19 |
return mol
|
20 |
-
|
21 |
|
22 |
def molecule(input_pdb):
|
23 |
|
@@ -71,19 +73,22 @@ def molecule(input_pdb):
|
|
71 |
allow-scripts allow-same-origin allow-popups
|
72 |
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
73 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
74 |
-
|
75 |
-
|
|
|
76 |
pdb_path = get_pdb(inp, file)
|
77 |
return molecule(pdb_path)
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
82 |
gr.Markdown("#PDB viewer using 3Dmol.js")
|
83 |
-
inp = gr.Textbox(
|
|
|
|
|
84 |
file = gr.File(file_count="single")
|
85 |
btn = gr.Button("View structure")
|
86 |
mol = gr.HTML()
|
87 |
-
btn.click(fn=update,inputs=[inp, file],outputs=mol
|
88 |
-
|
89 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
|
4 |
def get_pdb(pdb_code="", filepath=""):
|
5 |
if pdb_code is None or pdb_code == "":
|
6 |
try:
|
|
|
11 |
os.system(f"wget -qnc https://files.rcsb.org/view/{pdb_code}.pdb")
|
12 |
return f"{pdb_code}.pdb"
|
13 |
|
14 |
+
|
15 |
def read_mol(molpath):
|
16 |
with open(molpath, "r") as fp:
|
17 |
lines = fp.readlines()
|
|
|
19 |
for l in lines:
|
20 |
mol += l
|
21 |
return mol
|
22 |
+
|
23 |
|
24 |
def molecule(input_pdb):
|
25 |
|
|
|
73 |
allow-scripts allow-same-origin allow-popups
|
74 |
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
75 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
76 |
+
|
77 |
+
|
78 |
+
def update(inp, file):
|
79 |
pdb_path = get_pdb(inp, file)
|
80 |
return molecule(pdb_path)
|
81 |
+
|
82 |
+
|
83 |
+
demo = gr.Blocks()
|
84 |
+
|
85 |
+
with demo:
|
86 |
gr.Markdown("#PDB viewer using 3Dmol.js")
|
87 |
+
inp = gr.Textbox(
|
88 |
+
placeholder="PDB Code or upload file below", label="Input structure"
|
89 |
+
)
|
90 |
file = gr.File(file_count="single")
|
91 |
btn = gr.Button("View structure")
|
92 |
mol = gr.HTML()
|
93 |
+
btn.click(fn=update, inputs=[inp, file], outputs=mol)
|
94 |
+
demo.launch()
|
|