Spaces:
Running
Running
Generate PDB files
Browse files
app.py
CHANGED
@@ -1,13 +1,22 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import torch
|
4 |
from foldingdiff import sampling
|
|
|
5 |
|
6 |
def sample_at_length(l:int, seed:int):
|
|
|
|
|
|
|
7 |
torch.manual_seed(seed)
|
8 |
l = int(l)
|
9 |
-
s = sampling.sample_simple("wukevin/foldingdiff_cath", n=1, sweep_lengths=(l, l+1))
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
12 |
interface = gr.Interface(
|
13 |
fn=sample_at_length,
|
@@ -15,6 +24,9 @@ interface = gr.Interface(
|
|
15 |
gr.Number(value=55, label="Protein backbone length to generate", show_label=True, precision=0),
|
16 |
gr.Number(value=8964, label="Random seed", show_label=True, precision=0),
|
17 |
],
|
18 |
-
outputs=
|
|
|
|
|
|
|
19 |
)
|
20 |
interface.launch()
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
|
4 |
import torch
|
5 |
from foldingdiff import sampling
|
6 |
+
from foldingdiff import angles_and_coords as ac
|
7 |
|
8 |
def sample_at_length(l:int, seed:int):
|
9 |
+
"""
|
10 |
+
Sample a single structure at the given length
|
11 |
+
"""
|
12 |
torch.manual_seed(seed)
|
13 |
l = int(l)
|
14 |
+
s = sampling.sample_simple("wukevin/foldingdiff_cath", n=1, sweep_lengths=(l, l+1))[0]
|
15 |
+
# Create a PDB file
|
16 |
+
outdir = os.path.join(os.getcwd(), "output")
|
17 |
+
os.makedirs(outdir, exist_ok=True)
|
18 |
+
pdb_file = ac.create_new_chain_nerf(os.path.join(outdir, "generated.pdb"), s)
|
19 |
+
return s, pdb_file
|
20 |
|
21 |
interface = gr.Interface(
|
22 |
fn=sample_at_length,
|
|
|
24 |
gr.Number(value=55, label="Protein backbone length to generate", show_label=True, precision=0),
|
25 |
gr.Number(value=8964, label="Random seed", show_label=True, precision=0),
|
26 |
],
|
27 |
+
outputs=[
|
28 |
+
gr.Dataframe(label="Generated angles defining structure"),
|
29 |
+
gr.File(label="Generated structure in PDB format (cartesian coordinates)"),
|
30 |
+
],
|
31 |
)
|
32 |
interface.launch()
|