8 import matplotlib.pyplot as plt
10 from itertools import cycle
20 with open(sys.argv[1]) as f:
22 if line[0:4]=='ATOM' and line[13:15]=='CA':
29 sx[iatom]=sx.get(iatom,0)+x
30 sy[iatom]=sy.get(iatom,0)+y
31 sz[iatom]=sz.get(iatom,0)+z
32 s2x[iatom]=s2x.get(iatom,0)+x*x
33 s2y[iatom]=s2y.get(iatom,0)+y*y
34 s2z[iatom]=s2z.get(iatom,0)+z*z
37 if line[0:6]=='ENDMDL':
44 for i in range(1,natom+1):
45 fluct=math.sqrt((s2x.get(i)-sx.get(i)*sx.get(i)/nmol\
46 +s2y.get(i)-sy.get(i)*sy.get(i)/nmol\
47 +s2z.get(i)-sz.get(i)*sz.get(i)/nmol )/nmol)
54 if os.path.exists('plik.pdb'):
55 with open('plik.pdb') as f:
57 if line[0:4]=='ATOM' and line[13:15]=='CA':
59 if newchain or int(line[22:26])>ires:
60 b.append(math.sqrt(float(line[60:66])*3/8/math.pi/math.pi))
71 plt.ylabel('fluctuations')
75 plt.plot(x,b,'-',c='red')
76 plt.legend(['fluctuations','sqrt(3*bfactor/8*pi^2)'])
77 plt.savefig('fluct_plot.png')
80 with open('plik.pdb') as f, open ('plik_bf.pdb','w') as fw:
84 if line[22:26] != prev_ires:
87 fw.write(line[0:60]+'{:6.2f}'.format(bf)+line[66:])
88 elif line[0:3] == 'TER' or line[0:6] == 'CONECT':