long job names (40 char) no respa for D amino
[django_unres.git] / files / fluct_plot.py
index d228324..1064e90 100755 (executable)
@@ -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
@@ -61,6 +62,8 @@ if os.path.exists('plik.pdb'):
          newchain=False
       if line[0:3]=='TER':
         newchain=True
+      if line[0:3]=='END':
+        break
                         
 
 
@@ -72,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