-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalize_bfactor.py
More file actions
executable file
·46 lines (39 loc) · 900 Bytes
/
Copy pathnormalize_bfactor.py
File metadata and controls
executable file
·46 lines (39 loc) · 900 Bytes
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
#!/usr/bin/python
import math
import sys,os
infile = sys.argv[1]
# chainID = sys.argv[2]
outfile = sys.argv[2]
s_bf = 0.
s_bf2 = 0.
n_atom = 0.
avg_bf = 0.
for line in open(infile):
if len(line)<6 or line[0:6] not in ('ATOM ','HETATM'):
continue
# if line[21]!=chainID:
# continue
n_atom += 1
bf = float(line[60:66])
s_bf += bf
s_bf2 += bf*bf
print s_bf
print s_bf2
print n_atom
avg_bf = s_bf/n_atom
sd = math.sqrt( s_bf2/n_atom - avg_bf**2 )
print sd
print avg_bf
ofp = open(outfile,"w")
for line in open(infile):
if len(line)<6 or line[0:6] not in ('ATOM ','HETATM'):
ofp.write(line)
continue
# if line[21]!=chainID:
# ofp.write(line)
# continue
else:
bf = float(line[60:66])
new_bf = ( bf - avg_bf ) / sd
ofp.write("%s%6.2f%s"%(line[0:60],new_bf,line[66:]))
pass