forked from giovanni-bolcato/deepFMPOv3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeepFMPO.py
65 lines (36 loc) · 1.42 KB
/
deepFMPO.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
import sys
sys.path.insert(0, './Modules/')
from argsPassing import read_args
from Show_Epoch_new import write_results
def main(fragment_file, lead_file, args):
import numpy as np
from file_reader import read_file
from mol_utils import get_fragments
from build_encoding import get_encodings, encode_molecule, decode_molecule, encode_list, save_decodings
from models import build_models
from training import train
from rewards import clean_good
from rdkit import rdBase
rdBase.DisableLog('rdApp.error')
print ("Reading files")
fragment_mols = read_file(fragment_file)
lead_mols = read_file(lead_file)
fragment_mols += lead_mols
print ("Fragmenting molecules")
fragments, used_mols = get_fragments(fragment_mols)
print ("Encoding molecules")
encodings, decodings = get_encodings(fragments)
save_decodings(decodings)
lead_mols = np.asarray(fragment_mols[-len(lead_mols):])[used_mols[-len(lead_mols):]]
X = encode_list(lead_mols, encodings)
print ("Building models and training")
actor, critic = build_models(X.shape[1:])
X = clean_good(X, decodings)
history = train(X, actor, critic, decodings)
np.save("History/history.npy", history)
if __name__ == "__main__":
args = read_args()
fragment_file = args.fragment_file
lead_file = args.lead_file
main(fragment_file, lead_file, args)
write_results(args.out_file)