Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
Latest commit
41 lines (30 loc) · 1.19 KB
/
Copy pathexample.py
File metadata and controls
41 lines (30 loc) · 1.19 KB
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
"""Generate the first molecule in data/val.pt from its K=25 representation.
Run: python example.py
"""
importtorch
fromsampleimportload_decoder, generate_for_entry
CKPT="checkpoints/latest.pt"
VAL_FILE="data/val.pt"
OUT_DIR="outputs/example"
K_TARGET=25
defmain():
device="cuda"iftorch.cuda.is_available() else"cpu"
val_raw=torch.load(VAL_FILE, map_location="cpu")
entry=val_raw[0]
M=int(entry["M"])
available_ks=sorted(int(k[1:]) forkinentry["K_all"])
k_value=max([kforkinavailable_ksifk<=K_TARGET], default=available_ks[0])
print(f"Molecule 0: M={M} atoms, {len(available_ks)} K options available; using K={k_value}")
decoder=load_decoder(CKPT, device)
print(f"Loaded decoder: {CKPT}")
generate_for_entry(
decoder, entry["K_all"], M, device,
out_root=OUT_DIR, tag="example_mol0",
k_min=k_value, k_max=k_value, n_try=1, n_step=300,
target_aa=entry["AA"],
)
print(f"Done. See {OUT_DIR}/example_mol0_K{k_value}_try1_result.mol2 "
f"(plus _sites.mol2, _init.mol2, _result_attr.csv, and _target.mol2 "
f"for the ground truth).")
if__name__=="__main__":
main()