-
Notifications
You must be signed in to change notification settings - Fork 14
/
fine-tune.py
41 lines (37 loc) · 1.37 KB
/
fine-tune.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
from utils import *
from models import *
import matplotlib.pyplot as plt
import torch
import numpy as np
from rdkit.Chem import MolFromSmiles
import argparse
import time
replacements = ('N', 'O', 'Cl', 'F')
parser = argparse.ArgumentParser()
parser.add_argument('smiles', type=str)
parser.add_argument('--autodock_executable', type=str, default='AutoDock-GPU/bin/autodock_gpu_128wi')
parser.add_argument('--protein_file', type=str, default='1err/1err.maps.fld')
args = parser.parse_args()
base = args.smiles
while True:
tests = [base]
for i in range(len(base)):
if base[i] == 'C':
for replace in replacements:
test = list(base)
test[i] = replace
test = ''.join(test)
m = MolFromSmiles(test)
if m:
for other in replacements:
if m.HasSubstructMatch(MolFromSmiles(f'{replace}{other}')):
break
if MolFromSmiles(f'{replace}={other}') and m.HasSubstructMatch(MolFromSmiles(f'{replace}={other}')):
break
else:
tests.append(test)
tests *= 10
affins = smiles_to_affinity(tests, args.autodock_executable, args.protein_file)
base = tests[np.argmin(affins)]
print(delta_g_to_kd(min(affins)), base)
time.sleep(2)