X-Git-Url: http://mmka.chem.univ.gda.pl/gitweb/?a=blobdiff_plain;f=files%2Ffluct_plot.py;h=1064e90c21242ad00b634dfe5703edde00294dbe;hb=54cd6e1d5ddfde7997eaaacb3e83f4f09a4cbb16;hp=609ca4db6ec64fc88e6040a9a99577c8cef5b3dc;hpb=161801e60a4b6ac75ee8704dfb2d508e513cfa66;p=django_unres.git diff --git a/files/fluct_plot.py b/files/fluct_plot.py index 609ca4d..1064e90 100755 --- a/files/fluct_plot.py +++ b/files/fluct_plot.py @@ -7,6 +7,7 @@ import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import os.path +from itertools import cycle iatom=0 nmol=0 @@ -49,15 +50,21 @@ for i in range(1,natom+1): y.append(fluct) b=[] -ires='' +newchain=True if os.path.exists('plik.pdb'): with open('plik.pdb') as f: for line in f: if line[0:4]=='ATOM' and line[13:15]=='CA': # print line - if ires=='' or int(line[22:26])>ires: + if newchain or int(line[22:26])>ires: b.append(math.sqrt(float(line[60:66])*3/8/math.pi/math.pi)) ires=int(line[22:26]) + newchain=False + if line[0:3]=='TER': + newchain=True + if line[0:3]=='END': + break + plt.xlabel('residue') @@ -68,4 +75,16 @@ if len(b)!=0: plt.plot(x,b,'-',c='red') plt.legend(['fluctuations','sqrt(3*bfactor/8*pi^2)']) plt.savefig('fluct_plot.png') + +ycycle=cycle(y) +with open('plik.pdb') as f, open ('plik_bf.pdb','w') as fw: + prev_ires=None + for line in f: + if line[0:4]=='ATOM': + if line[22:26] != prev_ires: + prev_ires=line[22:26] + bf=next(ycycle) + fw.write(line[0:60]+'{:6.2f}'.format(bf)+line[66:]) + elif line[0:3] == 'TER' or line[0:6] == 'CONECT': + fw.write(line) \ No newline at end of file