-
Notifications
You must be signed in to change notification settings - Fork 0
/
Centroid.py
28 lines (24 loc) · 886 Bytes
/
Centroid.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
import os
import numpy as np
import math
import sys
if len(sys.argv) == 2:
prot_name = sys.argv[1]
# Provide the protein binding residue file genrated from binding_pocket.py"
pro_file = os.path.join(prot_name)
x_co_list = []
y_co_list = []
z_co_list = []
with open('centroid.txt', 'w+') as pdbfile:
with open(pro_file) as f:
data = f.readlines()
for line in data:
x_co, y_co, z_co = float(line[31:38]), float(line[39:46]), float(line[47:54])
x_co_list.append(x_co)
y_co_list.append(y_co)
z_co_list.append(z_co)
xn, yn, zn = np.mean(x_co_list), np.mean(y_co_list), np.mean(z_co_list)
#pdbfile.write(xn, yn, zn)
print(F'{xn},{yn},{zn}')
else:
print("python3 Centroid.py" + " <Provide the protein binding residue file genrated from binding_pocket.py>")