-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprepare_pdb_feature_rev_frwd_ca.py
More file actions
58 lines (46 loc) · 2.01 KB
/
prepare_pdb_feature_rev_frwd_ca.py
File metadata and controls
58 lines (46 loc) · 2.01 KB
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
#####################################################################################################################
# Date created : 10/21/2022
# Date modified: 10/21/2022
# Purpose : This program is to crate features for forward and reverse direction to next and previous Ca-Ca total 6
#####################################################################################################################
import os,sys
import optparse
import numpy as np
import math
from atomic_feature import get_residue_area_volume
import math
parser=optparse.OptionParser()
parser.add_option('--dssp_feat', dest='dssp_feat',
default= '', #default empty!
help= 'name of dssp feature file')
parser.add_option('--o', dest='o',
default= '', #default empth
help= 'name of output feature file npz format')
(options,args) = parser.parse_args()
dssp_feat = options.dssp_feat
o = options.o
fd = open(dssp_feat, 'r')
fdlines = fd.readlines()
length = int(fdlines[-1].split()[0])
feature_list = [[0 for _ in range(6)] for _ in range(length)] # 1D feature dimension is set 6, may change
for linei in range(2, len(fdlines)-1):
line = fdlines[linei].split()
line_prev = fdlines[linei-1].split()
line_post = fdlines[linei+1].split()
res = int(line[0]) - 1
cai = [float(line[9]), float(line[10]), float(line[11])]
cai_prev = [float(line_prev[9]), float(line_prev[10]), float(line_prev[11])]
cai_post = [float(line_post[9]), float(line_post[10]), float(line_post[11])]
forw = np.subtract(cai_post, cai)
revw = np.subtract(cai_prev, cai)
forwn = math.sqrt(forw[0] ** 2 + forw[1] ** 2 + forw[2] ** 2)
revwn = math.sqrt(revw[0] ** 2 + revw[1] ** 2 + revw[2] ** 2)
u_forw = forw/forwn
u_revw = revw/revwn
#print(u_forw, u_revw)
feature_list[res][:3] = u_forw
feature_list[res][3:] = u_revw
#print(feature_list[res])
np.save(o, feature_list)
fd.close()
#fm.close()