Import Numpy As NP
Import Numpy As NP
font_dirs = ['palantino/']
font_files = font_manager.findSystemFonts(fontpaths=font_dirs)
for font_file in font_files:
font_manager.fontManager.addfont(font_file)
# set font
plt.rcParams['font.family'] = 'Palatino Linotype'
def rmsf_fab_heavy():
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
label = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
for file in sorted(os.listdir('rmsf')):
if "_ab.xvg" in file:
complex = file.replace("_ab.xvg","")
c = next(color)
file = "rmsf/"+file
x,y = np.loadtxt(file,comments=['#',"@"],unpack=True)
x=x[0:226]
y=y[0:226]
plt.plot(x,y,c=c,label=next(label),linewidth=1,alpha=0.8)
plt.title('a)')
plt.xlabel('Residue')
plt.ylabel('RMSF (nm)')
plt.xticks(np.arange(0, 228, 20))
plt.minorticks_on()
plt.xlim([-5, 235])
plt.ylim([0, 1.25])
plt.legend(loc="upper left")
plt.savefig('fab_heavy.png')
plt.show()
def rmsf_fab_light():
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
label = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
for file in sorted(os.listdir('rmsf')):
if "_ab.xvg" in file:
complex = file.replace("_ab.xvg","")
c = next(color)
file = "rmsf/"+file
x,y = np.loadtxt(file,comments=['#',"@"],unpack=True)
x=x[226:]
y=y[226:]
plt.plot(x,y,c=c,label=next(label),linewidth=1)
plt.title('b)')
plt.xlabel('Residue')
plt.ylabel('RMSF (nm)')
plt.xticks(np.arange(0, 228, 20))
plt.minorticks_on()
plt.xlim([-5, 235])
plt.ylim([0, 1.25])
plt.legend(loc="upper left")
plt.savefig('fab_light.png')
plt.show()
def rmsf_gp1():
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
label = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
last = iter([280,279,278,278])
for file in sorted(os.listdir('rmsf')):
if "gp.xvg" in file:
complex = file.replace("_gp.xvg","")
file = "rmsf/"+file
x,y = np.loadtxt(file,comments=['#',"@"],unpack=True)
index=next(last)
x=x[0:index]
y=y[0:index]
plt.plot(x,y,c=next(color),label=next(label),linewidth=None)
plt.title('c)')
plt.xlabel('Residue')
plt.ylabel('RMSF (nm)')
plt.xticks(np.arange(0, 310, 20))
plt.minorticks_on()
plt.xlim([25, 320])
plt.ylim([0, 1.25])
#base = pd.DataFrame(data=np.array([[33,70],[95,105],[158,168],
[176,190]]),columns=['start','end'])
#head = pd.DataFrame(data=np.array([[70,95],[105,158],[168,176],
[214,227]]),columns=['start','end'])
plt.legend(loc="upper left")
plt.savefig('gp1.png')
plt.show()
def rmsf_gp2():
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
label = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
last = iter([280,279,278,278])
for file in sorted(os.listdir('rmsf')):
if "gp.xvg" in file:
complex = file.replace("_gp.xvg","")
file = "rmsf/"+file
x,y = np.loadtxt(file,comments=['#',"@"],unpack=True)
index=next(last)
x=x[index:]
y=y[index:]
plt.plot(x,y,c=next(color),label=next(label),linewidth=None)
plt.title('d)')
plt.xlabel('Residue')
plt.ylabel('RMSF (nm)')
plt.xticks(np.arange(500, 600, 20))
plt.minorticks_on()
plt.xlim([490, 610])
plt.ylim([0, 1.25])
#base = pd.DataFrame(data=np.array([[33,70],[95,105],[158,168],
[176,190]]),columns=['start','end'])
#head = pd.DataFrame(data=np.array([[70,95],[105,158],[168,176],
[214,227]]),columns=['start','end'])
plt.legend(loc="upper left")
plt.savefig('gp2.png')
plt.show()
def rmsd():
labels = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
output_name=iter(['rmsd_complex1.png', 'rmsd_complex2.png', 'rmsd_complex3.png',
'rmsd_complex4.png'])
points=iter(['a)','b)','c)','d)'])
for file in sorted(os.listdir('rmsd')):
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
file = "rmsd/"+file
x1,y1=np.loadtxt(file,comments=['#',"@"],unpack=True)
c=next(color)
plt.plot(x1,y1,c=c,linewidth=1,alpha=0.8,label=next(labels))
plt.title(next(points))
plt.xlabel('Time (ns)')
plt.ylabel('RMSD (nm)')
#plt.xticks(np.arange(0, 228, 20))
plt.minorticks_on()
#plt.xlim([-5, 235])
plt.ylim([0, 1.0])
plt.legend(loc="upper left")
plt.savefig(next(output_name))
def rmsd_all():
labels = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
for file in sorted(os.listdir('rmsd')):
file = "rmsd/"+file
x1,y1=np.loadtxt(file,comments=['#',"@"],unpack=True)
c=next(color)
plt.plot(x1,y1,c=c,linewidth=1,alpha=0.8,label=next(labels))
plt.xlabel('Time (ns)')
plt.ylabel('RMSD (nm)')
#plt.xticks(np.arange(0, 228, 20))
plt.minorticks_on()
#plt.xlim([-5, 235])
plt.ylim([0, 1.0])
plt.legend(loc="upper left")
plt.savefig('rmsd_all.png')
def mmpbsa():
color = iter(['#e41a1c','#377eb8','#4daf4a','#984ea3'])
label = iter(['Complex 1', 'Complex 2', 'Complex 3', 'Complex 4'])
mmpbsa = pd.DataFrame(data={'Energy_Component':
['dVDWAALS','dEEL','dEPB','dENPOLAR','dTOTAL']})
#['van der Waals ','Electrostatic ','Polar Solvation','Non-polar ','Total']})
for file in sorted(os.listdir('mmpbsa')):
df=pd.read_csv('mmpbsa/'+file)
df=df[['Energy_Component','Average']]
df=df.iloc[[6,7,10,11,15]]
lab=next(label)
df=df.rename(columns={'Average':lab})
mmpbsa=mmpbsa.merge(df,how='inner', on='Energy_Component')
mmpbsa.plot.bar(rot=0)
print(mmpbsa)
fig = plt.figure(dpi=300,figsize=(8.667,6.667))
plt.bar(mmpbsa['Energy_Component'],mmpbsa['Complex 1'])
plt.show()
plt.savefig('mmpbsa1.png')
def count_files(dirpath):
frames=0
for file in os.listdir(dirpath):
if os.path.isfile(os.path.join(dirpath, file)):
frames += 1
return frames #Ile klatek otrzymamy - Z
x=count_res(dirpath,first_res=first_res_value, last_res=last_res_value)
result=create_array(dirpath,x[0],first_res=first_res_value,last_res=last_res_value)
print(result.shape)
print(result)
print(result[0][0])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
res=x[1]
print(res)
time=count_files(dirpath)
time=time+1
time = [ns for ns in np.arange(1,time,1)]
print(time)
for ns in time:
rmsf_frame=ns-1
rmsf=result[:][rmsf_frame]
ax.scatter(res, ns, rmsf, c=rmsf, alpha=1)
ax.set_xlabel('Residue')
ax.set_ylabel('Time (ns)')
ax.set_zlabel('RMSF (nm)')
ax.set_xticks(np.arange(first_res_value,last_res_value,1))
ax.set_xticks(np.arange)
ax.set_zticks(np.arange(-0.4,0.4,0.05))
ax.set_xticklabels([int(i) for i in x[1]])
ax.set_zlim(-0.5,0.5)
plt.show()