-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrmsd_benchmark.py
131 lines (93 loc) · 3.26 KB
/
rmsd_benchmark.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import numpy as np
import subprocess as sp
from pdb2sql.StructureSimilarity import StructureSimilarity
import matplotlib.pyplot as plt
import time
import os
'''
WHERE TO FIND HADDOCK DATA
L-RMSD
ON ALCAZAR
/home/benchmark/docking-benchmark4/runs-cmrestraints/<MOL NAME>/run1/structures/it1/water/l-RMSD.dat
FNAT
LOCAL
~/Documents/projects/deeprank/data/HADDOCK/BM4_dimers/model_qualities/Fnat/water/<MOL>.Fnat
IRMSD
LOCAL
Documents/projects/deeprank/data/HADDOCK/BM4_dimers/model_qualities/i-rmsd/water/<MOL>.irmsd
'''
data = os.path.join('data','1AK4')
decoys = os.path.join(data, 'decoys')
ref = os.path.join(os.path.join(data, 'ref'), '1AK4.pdb')
print(data)
# decoy_list = sp.check_output('dir %s/*.pdb' %decoys,shell=True).decode('utf-8').split()
decoy_list = [ os.path.join(decoys,d) for d in os.listdir(decoys) if d.endswith('.pdb')]
haddock_data = {}
haddock_files = [ os.path.join(os.path.join(data,'haddock'),f) for f in ['1AK4.Fnat','1AK4.lrmsd','1AK4.irmsd'] ]
for i,fname in enumerate(haddock_files):
f = open(fname,'r')
data = f.readlines()
f.close()
for line in data:
if line[0] == '#':
continue
line = line.split()
mol_name = line[0].split('.')[0]
if i == 0:
haddock_data[mol_name] = np.zeros(3)
haddock_data[mol_name][i] = float(line[1])
print(haddock_data)
nconf = len(haddock_data)
deep = np.zeros((nconf,3))
hdk = np.zeros((nconf,3))
deep_data = {}
t0 = time.time()
for i,decoy in enumerate(decoy_list):
print('\n-->' + decoy)
sim = StructureSimilarity(decoy,ref, enforce_residue_matching=False)
lrmsd = sim.compute_lrmsd_fast(method='svd',lzone='1AK4.lzone')
irmsd = sim.compute_irmsd_fast(method='svd',izone='1AK4.izone')
fnat = sim.compute_fnat_fast()#ref_pairs='1AK4.refpairs')
#fnat = sim.compute_Fnat_pdb2sql()
dockQ = sim.compute_DockQScore(fnat,lrmsd,irmsd)
# mol_name = decoy.split('/')[-1].split('.')[0]
mol_name = os.path.basename(decoy).split('.')[0]
deep_data[mol_name] = [fnat,lrmsd,irmsd]
np.savetxt(mol_name+'.LRMSD',[lrmsd])
np.savetxt(mol_name+'.IRMSD',[irmsd])
np.savetxt(mol_name+'.FNAT',[fnat])
np.savetxt(mol_name+'.DOCKQ',[dockQ])
deep[i,:] = deep_data[mol_name]
hdk[i,:] = haddock_data[mol_name]
print("HADDOCK : fnat = %1.6f\tlrmsd = %2.7f\tirmsd = %2.7f" %(haddock_data[mol_name][0],haddock_data[mol_name][1],haddock_data[mol_name][2]))
print("DEEP : fnat = %1.6f\tlrmsd = %2.7f\tirmsd = %2.7f" %(deep_data[mol_name][0],deep_data[mol_name][1],deep_data[mol_name][2]))
print("DOCKQ : %f" %dockQ)
t1=time.time()-t0
print('total time %f' %t1 )
np.savetxt('deep.dat',deep)
np.savetxt('hdk.dat',hdk)
plt.subplot(3,1,1)
plt.scatter(hdk[:,0],deep[:,0],label='Fnat')
mini = np.min(deep[:,0])
maxi = np.max(deep[:,0])
plt.plot( [mini,maxi],[mini,maxi],'--',color='black' )
plt.legend(loc=4)
plt.xlabel('PROFIT')
plt.ylabel('DEEP')
plt.subplot(3,1,2)
plt.scatter(hdk[:,1],deep[:,1],label='l-rmsd')
mini = np.min(deep[:,1])
maxi = np.max(deep[:,1])
plt.plot( [mini,maxi],[mini,maxi],'--',color='black' )
plt.legend(loc=4)
plt.xlabel('PROFIT')
plt.ylabel('DEEP')
plt.subplot(3,1,3)
plt.scatter(hdk[:,2],deep[:,2],label='i-rmsd')
mini = np.min(deep[:,2])
maxi = np.max(deep[:,2])
plt.plot( [mini,maxi],[mini,maxi],'--',color='black' )
plt.legend(loc=4)
plt.xlabel('PROFIT')
plt.ylabel('DEEP')
plt.show()