i_vorobyev
commited on
Commit
·
9f2073b
1
Parent(s):
fde5663
add 2dmoljs
Browse files
app.py
CHANGED
@@ -1,26 +1,99 @@
|
|
1 |
import gradio as gr
|
2 |
from igfold import IgFoldRunner
|
|
|
3 |
|
4 |
-
def pred_seq(seq):
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
}
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
)
|
18 |
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
-
def greet(name):
|
23 |
-
return "Hello " + name + "!!"
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from igfold import IgFoldRunner
|
3 |
+
import os
|
4 |
|
|
|
5 |
|
6 |
+
def read_mol(molpath):
|
7 |
+
with open(molpath, "r") as fp:
|
8 |
+
lines = fp.readlines()
|
9 |
+
mol = ""
|
10 |
+
for l in lines:
|
11 |
+
mol += l
|
12 |
+
return mol
|
13 |
+
|
14 |
+
|
15 |
+
def molecule(input_pdb):
|
16 |
+
|
17 |
+
mol = read_mol(input_pdb)
|
18 |
+
|
19 |
+
x = (
|
20 |
+
"""<!DOCTYPE html>
|
21 |
+
<html>
|
22 |
+
<head>
|
23 |
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
24 |
+
<style>
|
25 |
+
body{
|
26 |
+
font-family:sans-serif
|
27 |
+
}
|
28 |
+
.mol-container {
|
29 |
+
width: 100%;
|
30 |
+
height: 600px;
|
31 |
+
position: relative;
|
32 |
}
|
33 |
+
.mol-container select{
|
34 |
+
background-image:None;
|
35 |
+
}
|
36 |
+
</style>
|
37 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js" integrity="sha512-STof4xm1wgkfm7heWqFJVn58Hm3EtS31XFaagaa8VMReCXAkQnJZ+jEy8PCC/iT18dFy95WcExNHFTqLyp72eQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
38 |
+
<script src="https://3Dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
|
39 |
+
</head>
|
40 |
+
<body>
|
41 |
+
<div id="container" class="mol-container"></div>
|
42 |
+
|
43 |
+
<script>
|
44 |
+
let pdb = `"""
|
45 |
+
+ mol
|
46 |
+
+ """`
|
47 |
+
|
48 |
+
$(document).ready(function () {
|
49 |
+
let element = $("#container");
|
50 |
+
let config = { backgroundColor: "white" };
|
51 |
+
let viewer = $3Dmol.createViewer(element, config);
|
52 |
+
viewer.addModel(pdb, "pdb");
|
53 |
+
viewer.getModel(0).setStyle({}, { cartoon: { colorscheme:"whiteCarbon" } });
|
54 |
+
viewer.zoomTo();
|
55 |
+
viewer.render();
|
56 |
+
viewer.zoom(0.8, 2000);
|
57 |
+
})
|
58 |
+
</script>
|
59 |
+
</body></html>"""
|
60 |
)
|
61 |
|
62 |
+
return f"""<iframe style="width: 100%; height: 600px" name="result" allow="midi; geolocation; microphone; camera;
|
63 |
+
display-capture; encrypted-media;" sandbox="allow-modals allow-forms
|
64 |
+
allow-scripts allow-same-origin allow-popups
|
65 |
+
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
66 |
+
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
67 |
|
|
|
|
|
68 |
|
69 |
+
def validate(seq):
|
70 |
+
alphabet = set('ACDEFGHIKLMNPQRSTVWY')
|
71 |
+
leftover = set(seq.upper()) - alphabet
|
72 |
+
return not leftover
|
73 |
+
|
74 |
+
def pred_seq(seq):
|
75 |
+
|
76 |
+
is_valid = validate(seq)
|
77 |
+
if is_valid:
|
78 |
+
sequences = {
|
79 |
+
"H": "QVQLQESGGGLVQAGGSLTLSCAVSGLTFSNYAMGWFRQAPGKEREFVAAITWDGGNTYYTDSVKGRFTISRDNAKNTVFLQMNSLKPEDTAVYYCAAKLLGSSRYELALAGYDYWGQGTQVTVS"
|
80 |
+
}
|
81 |
+
pred_pdb = "my_nanobody1.pdb"
|
82 |
+
|
83 |
+
igfold = IgFoldRunner()
|
84 |
+
igfold.fold(
|
85 |
+
pred_pdb,
|
86 |
+
sequences=sequences,
|
87 |
+
do_refine=False,
|
88 |
+
do_renum=False,
|
89 |
+
)
|
90 |
+
|
91 |
+
molecule(pred_pdb)
|
92 |
+
|
93 |
+
else:
|
94 |
+
html = "<p color = 'red'>ERROR! Not valid sequence</p>"
|
95 |
+
return (html)
|
96 |
+
|
97 |
+
iface = gr.Interface(fn=pred_seq,
|
98 |
+
inputs="text", outputs=gr.HTML())
|
99 |
iface.launch()
|