-
Notifications
You must be signed in to change notification settings - Fork 0
/
dd_rank.py
53 lines (48 loc) · 1.96 KB
/
dd_rank.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
from openbabel import pybel
import math
import glob
import statistics
import numpy as np
print("Peptide,Average,Standard Deviation")
for file0 in glob.glob(f"/home/aiman/p53_docking/fin_results/*/"):
# if "ACE" not in file0[36:39]:
# continue
distance = []
avg_dist = 0
for file in (glob.glob(f"{file0}rank*_confidence*.sdf")):
with open(file, "r") as fhIn:
content = fhIn.read()
lines = content.split("\n")
analysis_line = lines[4].lstrip()
entries = analysis_line.split()
if len(entries) < 16:
continue
for mol in pybel.readfile('sdf', file):
add = 0
i = 0
process_file = True
for atom in mol:
coords = atom.coords
if np.isnan(coords[0]) or np.isnan(coords[1]) or np.isnan(coords[2]):
process_file = False
if not process_file:
break
for file1 in (glob.glob(f"{file0}rank1_confidence*.sdf")):
for mol2 in pybel.readfile('sdf', file1):
for idx, atom in enumerate(mol):
# print(file, file1)
atom2 = list(mol2)[idx]
coord1 = atom2.coords
if (atom2.idx == atom.idx):
coord2 = atom.coords
P = coord1
Q = coord2
moldistance = math.dist(P,Q)
# print(coord1, coord2, moldistance)
add += moldistance
i += 1
avg = add/i
distance.append(avg)
avg_dist = statistics.mean(distance)
stdev = statistics.stdev(distance)
print (f"{file0[36:39]},{str(avg_dist)},{str(stdev)}")