-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeature.py
193 lines (154 loc) · 5.52 KB
/
feature.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
"""
This feature assigns a tag to the initial identity of an a.a.
e.g. A-->X would return the value 0, based on the properties table below
THe new data is assigned to a new dataframe tag (INITAA)
"""
def CalcInitialAA(df,newTag="INITAA"):
properties={
'a': 0, 'c': 1, 'd': 2, 'e': 3, 'f': 4,
'g': 5, 'h': 6, 'i': 7, 'k': 8, 'l': 9,
'm':10, 'n':11, 'p':12, 'q':13, 'r':14,
's':15, 't':16, 'v':17, 'w':18, 'y':19,
}
def calc_prop(variantName):
#print(variantName)
if variantName == 'wt':
return 20
daID = properties[variantName[0]]
return daID
df[newTag] = df.apply( lambda row:
calc_prop(row['VARIANT'].lower()),
axis=1)
##### FOR KAL TO IMPLEMENT ###############
import pandas as pd
"""
Brief Documentation of feature
"""
def CalcRMSFLoc(df,rmsfFileName,newTag="RMSF" ):#, aaRange=[]):
# convert into dictionary for easy lookup
#print( df.loc[df['VARIANT'] == 'a57p'] )
df.loc[:,newTag] = 0
with open(rmsfFileName) as f:
for line in f:
# his format has a header with a single entry
vals = line.split()
if len(vals)<2:
continue
mut,val = vals
idx = df.index
cond = df['VARIANT']==mut #vals[0] )
varIdx = idx[cond].tolist()
if len(varIdx)<1:
print(mut, " not found in input list")
continue
df.loc[varIdx,newTag] = float( val )
"""
Brief Documentation of feature
"""
def CalcNativeScore(nativeFileName, variantName):
return 1/0
"""
Brief Documentation of feature.
data is in file 'feature_sets/sasa-wt-aa.txt'
"""
def CalcSASASingleScore(nativeFileName, variantName):
return 1/0
####### change im aa sidechain volume is estimated.
####### volume in solution is being used for this calculation
####### volumes are missig for his, arg, cys
####### ref: "Volumes of Individual Amino Acid Residues in Gas-Phase Peptide Ions"
def Calcsvolume(df,newTag="SVOLUME"):
properties={
'a': 100.3, 'c':100, 'd': 113.1, 'e': 140.2,
'f': 202.3, 'g': 71.7, 'h':202, 'i': 175.4,
'k': 170.3, 'l': 178.7, 'm':174.9, 'n':128.4,
'p':137.2, 'q':156, 'r':170, 's':100.7, 't':127.6,
'v':150.6, 'w':239, 'y':205.3,
}
def calc_prop(variantName):
#print(variantName,variantName[0],variantName[-1])
if variantName == 'wt':
return 0
names=variantName.split('-') # for double mutants
volDiff=0
for name in names:
# compute volume difference between wt and mutated residues
volWT = properties[variantName[0]]
volMut = properties[variantName[-1]]
volDiff += abs(volWT-volMut)
return volDiff
df[newTag] = df.apply( lambda row:
calc_prop(row['VARIANT'].lower()),
axis=1)
####### change in aa sidechain hydrophobicity is estimated.
### Refs: EISE1982 EISE1984
def Calchydrophobicity(df,newTag="HYDROPHOBICITY"):
properties={
'a': 0.25, 'c': 0.04, 'd': -0.72, 'e': -0.62,
'f': 0.61, 'g': 0.16, 'h': -0.40, 'i': 0.73,
'k': -1.1, 'l': 0.53, 'm': 0.26, 'n': -0.64,
'p': -0.07, 'q': -0.69, 'r': -1.8, 's': -0.26, 't': -0.18,
'v': 0.54, 'w': 0.37, 'y': 0.02,
}
def calc_prop(variantName):
#print(variantName,variantName[0],variantName[-1])
if variantName == 'wt':
return 0
names=variantName.split('-') # for double mutants
hpDiff=0
for name in names:
# compute volume difference between wt and mutated residues
hpWT = properties[variantName[0]]
hpMut = properties[variantName[-1]]
hpDiff += hpMut-hpWT
return hpDiff
df[newTag] = df.apply( lambda row:
calc_prop(row['VARIANT'].lower()),
axis=1)
####### aa charges
def Calccharge(df,newTag="CHARGE"):
properties={
'a':0, 'c':0, 'd':-1, 'e':-1,
'f':0, 'g':0, 'h':1, 'i':0,
'k':1, 'l':0, 'm':0, 'n':0,
'p':0, 'q':0, 'r':1, 's':0, 't':0,
'v':0, 'w':0, 'y':0,
}
####### APBS solvation energy ######
def CalcAPBS(df,apbsFileName,newTag="APBS" ):
# convert into dictionary for easy lookup
#print( df.loc[df['VARIANT'] == 'a57p'] )
df.loc[:,newTag] = 0
with open(apbsFileName) as f:
for line in f:
# his format has a header with a single entry
vals = line.split()
if len(vals)<2:
continue
mut,val = vals
idx = df.index
cond = df['VARIANT']==mut #vals[0] )
varIdx = idx[cond].tolist()
if len(varIdx)<1:
print(mut, " not found in input list")
continue
df.loc[varIdx,newTag] = float( val )
####### SASA for the mutated residues ######
def CalcSASASingleSite(df,sasaFileName,newTag="SASASingleSite" ):
# convert into dictionary for easy lookup
#print( df.loc[df['VARIANT'] == 'a57p'] )
df.loc[:,newTag] = 0
with open(sasaFileName) as f:
for line in f:
# his format has a header with a single entry
vals = line.split()
if len(vals)<2:
continue
mut,val = vals
idx = df.index
cond = df['VARIANT']==mut #vals[0] )
varIdx = idx[cond].tolist()
if len(varIdx)<1:
print(mut, " not found in input list")
continue
df.loc[varIdx,newTag] = float( val )