-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rfdiffusion_motif.py
98 lines (77 loc) · 2.99 KB
/
test_rfdiffusion_motif.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import os
import time
import logging
import prody
import numpy
import torch
from proteopt import rfdiffusion_motif
from proteopt.scaffold_problem import ScaffoldProblem
DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
from . import util
def test_basic(caplog):
caplog.set_level(logging.INFO)
handle = prody.parsePDB(os.path.join(DATA_DIR, "1MBN.pdb"), model=1)
print(len(handle))
structure_to_recapitulate = handle.select("chain A and resid 22 to 33")
print(len(structure_to_recapitulate.ca), structure_to_recapitulate.ca.getSequence())
problem = ScaffoldProblem(handle)
problem.add_segment(length=20)
problem.add_segment(
structure=structure_to_recapitulate,
sequence_from_structure=True
)
problem.add_segment(length=30)
start = time.time()
runner = rfdiffusion_motif.RFDiffusionMotif(
models_dir=util.RFDIFFUSION_WEIGHTS_DIR)
print(runner.conf)
print("*** Initialization time", time.time() - start)
start = time.time()
results, = list(runner.run_multiple([{"problem": problem, "num": 1}]))
print("*** Run time", (time.time() - start))
assert len(results) == 1
result = results.iloc[0]
construct = result.structure
seq = construct.ca.getSequence()
assert len(seq) == 62
assert seq[20:20 + 12] == handle.select(
"chain A and resid 22 to 33").ca.getSequence()
assert construct.select("constrained_by_sequence").ca.getSequence() == (
structure_to_recapitulate.ca.getSequence())
assert construct.select("constrained_by_structure").ca.getSequence() == (
structure_to_recapitulate.ca.getSequence())
assert len(construct.select("unconstrained").ca) == 50
def test_basic_with_nanobody(caplog):
caplog.set_level(logging.INFO)
handle = prody.parsePDB(os.path.join(DATA_DIR, "5m13.pdb"), model=1)
print(handle)
problem = ScaffoldProblem(handle)
problem.add_segment(length=20)
resid_ranges = [
(81, 101),
(126, 131),
(161, 190),
(246, 256),
(301, 328),
]
for pair in resid_ranges:
problem.add_segment(
structure=handle.select(f"chain A and resid {pair[0]} to {pair[1]}"))
problem.add_segment(length=10)
problem.add_segment(length=30)
problem.add_contig_chain_break()
problem.add_segment(
structure=handle.select("chain B")) # nanobody
start = time.time()
runner = rfdiffusion_motif.RFDiffusionMotif(
models_dir=util.RFDIFFUSION_WEIGHTS_DIR)
print(runner.conf)
print("*** Initialization time", time.time() - start)
start = time.time()
results, = list(runner.run_multiple([problem]))
print("*** Run time", (time.time() - start))
assert len(results) == 1
result = results.iloc[0]
assert result.structure.select("chain B").ca.getSequence() == handle.select("chain B").ca.getSequence()
designed_seq = result.structure.select("chain A").ca.getSequence()
print("Designed seq", designed_seq)