In [24]:
# import barnaba
import barnaba.enm as enm
import time
import numpy as np
times=[]
n_beads_AA=[]
n_res=[]
for fname in flist:
t0=time.time()
enm_tmp=enm.Enm(fname,cutoff=0.7,sele_atoms="AA",sparse=True)
t1=time.time()-t0
fluc,rl=enm_tmp.c2_fluctuations()
t2=time.time()-t0-t1
n_beads_AA.append(enm_tmp.n_beads)
n_res.append(len(rl))
times.append([t1,t2])
t_AA_sparse=np.array(times)
In [9]:
import matplotlib.pyplot as plt
import seaborn as sns
plt.plot(n_beads_AA,t_AA_sparse[:,0],marker='o',ls='',label='Diagonalization')
plt.plot(n_beads_AA,t_AA_sparse[:,1],marker='o',ls='',label='Dist. fluc. calculation')
plt.ylabel('execution time (s)')
plt.xlabel('N. beads')
plt.legend()
plt.yscale('log')
In [10]:
plt.plot(n_res,t_AA_sparse[:,0],marker='o',ls='',label='Diagonalization')
plt.plot(n_res,t_AA_sparse[:,1],marker='o',ls='',label='Dist. fluc. calculation')
plt.ylabel('execution time (s)')
plt.xlabel('N. res')
plt.legend()
plt.yscale('log')
In [12]:
times=[]
n_beads_AA=[]
for fname in flist:
t0=time.time()
enm_tmp=enm.Enm(fname,cutoff=0.7,sele_atoms="AA",sparse=False)
t1=time.time()-t0
fluc,rl=enm_tmp.c2_fluctuations()
t2=time.time()-t0-t1
n_beads_AA.append(enm_tmp.n_beads)
times.append([t1,t2])
t_AA_vanilla=np.array(times)
In [13]:
plt.figure(figsize=(12,4))
plt.subplot2grid((1,2),(0,0))
plt.title('Diagonalization only')
plt.plot(n_beads_AA,t_AA_sparse[:,0],marker='o',ls='',label='Sparse',c='r')
plt.plot(n_beads_AA,t_AA_vanilla[:,0],marker='o',ls='',label='Vanilla',c='b')
plt.ylabel('execution time (s)')
plt.xlabel('N. beads')
plt.legend()
plt.yscale('log')
plt.subplot2grid((1,2),(0,1))
plt.title('Total')
plt.plot(n_beads_AA,np.sum(t_AA_sparse,axis=1),marker='s',ls='',label='Sparse',c='r')
plt.plot(n_beads_AA,np.sum(t_AA_vanilla,axis=1),marker='s',ls='',label='Vanilla',c='b')
plt.ylabel('execution time (s)')
plt.xlabel('N. beads')
plt.legend()
plt.yscale('log')
In [14]:
plt.figure(figsize=(12,4))
plt.subplot2grid((1,2),(0,0))
plt.title('Diagonalization only')
plt.plot(n_res,t_AA_sparse[:,0],marker='o',ls='',label='Sparse',c='r')
plt.plot(n_res,t_AA_vanilla[:,0],marker='o',ls='',label='Vanilla',c='b')
plt.ylabel('execution time (s)')
plt.xlabel('N. res')
plt.legend()
plt.yscale('log')
plt.subplot2grid((1,2),(0,1))
plt.title('Total')
plt.plot(n_res,np.sum(t_AA_sparse,axis=1),marker='s',ls='',label='Sparse',c='r')
plt.plot(n_res,np.sum(t_AA_vanilla,axis=1),marker='s',ls='',label='Vanilla',c='b')
plt.ylabel('execution time (s)')
plt.xlabel('N. res')
plt.legend()
plt.yscale('log')
In [16]:
times=[]
n_beads_SBP=[]
for fname in flist:
t0=time.time()
enm_tmp=enm.Enm(fname,sparse=True,cutoff=1.0)
t1=time.time()-t0
fluc,rl=enm_tmp.c2_fluctuations()
t2=time.time()-t0-t1
n_beads_SBP.append(enm_tmp.n_beads)
times.append([t1,t2])
t_SBP_sparse=np.array(times)
In [17]:
plt.plot(n_beads_SBP,t_SBP_sparse[:,0],marker='o',ls='',label='Diagonalization')
plt.plot(n_beads_SBP,t_SBP_sparse[:,1],marker='o',ls='',label='Dist. fluc. calculation')
plt.ylabel('execution time (s)')
plt.xlabel('N. beads')
plt.legend()
plt.yscale('log')
In [18]:
times=[]
n_beads_SBP=[]
for fname in flist:
t0=time.time()
enm_tmp=enm.Enm(fname,sparse=False,cutoff=1.0)
t1=time.time()-t0
fluc,rl=enm_tmp.c2_fluctuations()
t2=time.time()-t0-t1
n_beads_SBP.append(enm_tmp.n_beads)
times.append([t1,t2])
t_SBP_vanilla=np.array(times)
In [19]:
plt.figure(figsize=(12,4))
plt.subplot2grid((1,2),(0,0))
plt.title('Diagonalization only')
plt.plot(n_beads_SBP,t_SBP_sparse[:,0],marker='o',ls='',label='Sparse',c='r')
plt.plot(n_beads_SBP,t_SBP_vanilla[:,0],marker='o',ls='',label='Vanilla',c='b')
plt.ylabel('execution time (s)')
plt.xlabel('N. beads')
plt.legend()
plt.yscale('log')
plt.subplot2grid((1,2),(0,1))
plt.title('Total')
plt.plot(n_beads_SBP,np.sum(t_SBP_sparse,axis=1),marker='s',ls='',label='Sparse',c='r')
plt.plot(n_beads_SBP,np.sum(t_SBP_vanilla,axis=1),marker='s',ls='',label='Vanilla',c='b')
plt.ylabel('execution time (s)')
plt.xlabel('N. beads')
plt.legend()
plt.yscale('log')
In [20]:
fout=open('performances.dat','w')
fout.write('# PDB | n_beads_AA | n_beads_SBP | n_res | \
t_AA_sprs diag | t_AA_sprs fluc | t_AA_vnll diag | t_AA_vnll fluc | \
t_SBP_sprs diag | t_SBP_sprs fluc | t_SBP_vnll diag | t_SBP_vnll fluc \n')
for i,finname in enumerate(flist):
pdb=finname.split(".")[0]
fout.write("%s %d %d %d %e %e %e %e %e %e %e %e \n" % \
(pdb,n_beads_AA[i],n_beads_SBP[i],n_res[i],\
t_AA_sparse[i,0],t_AA_sparse[i,1],t_AA_vanilla[i,0],t_AA_vanilla[i,1],\
t_SBP_sparse[i,0],t_SBP_sparse[i,1],t_SBP_vanilla[i,0],t_SBP_vanilla[i,1]))
fout.close()
In [21]:
plt.figure(figsize=(12,4))
plt.subplot2grid((1,2),(0,0))
plt.subplots_adjust(wspace=0)
plt.title('Diagonalization only')
plt.plot(n_res,t_SBP_sparse[:,0],marker='^',ls='',label='Sparse',c='r',ms=8,markeredgecolor='k')
plt.plot(n_res,t_SBP_vanilla[:,0],marker='^',ls='',label='Vanilla',c='gold',ms=8,markeredgecolor='k')
#plt.legend()
plt.plot(n_res,t_AA_sparse[:,0],marker='o',ls='',label='Sparse',c='r',ms=8,markeredgecolor='k')
plt.plot(n_res,t_AA_vanilla[:,0],marker='o',ls='',label='Vanilla',c='gold',ms=8,markeredgecolor='k')
plt.ylabel('execution time (s)')
plt.xlabel('N. res')
#plt.legend()
plt.yscale('log')
plt.xscale('log')
plt.ylim(0.01,2000)
ax=plt.subplot2grid((1,2),(0,1))
plt.title('Total')
ax.plot(n_res,np.sum(t_AA_sparse,axis=1),marker='o',ls='',label='Sparse',c='r',ms=8,markeredgecolor='k')
ax.plot(n_res,np.sum(t_AA_vanilla,axis=1),marker='o',ls='',label='Dense',c='gold',ms=8,markeredgecolor='k')
plt.legend()
ax.plot(n_res,np.sum(t_SBP_sparse,axis=1),marker='^',ls='',label='Sparse',c='r',ms=8,markeredgecolor='k')
ax.plot(n_res,np.sum(t_SBP_vanilla,axis=1),marker='^',ls='',label='Dense',c='gold',ms=8,markeredgecolor='k')
ax.yaxis.tick_right()
plt.xlabel('N. res')
#plt.legend()
plt.ylim(0.01,2000)
plt.yscale('log')
plt.xscale('log')
plt.savefig('ENM-performance.pdf',bbox_inches="tight")