def InTheWeedsPlot(OutBase,UnfoldObj,RefoldObj=[],Example=None, Bins=[50,75,100,150,200,500,1000],**kwargs): """ Plots a detailed energy landscape, and saves Args: OutBase: where to start the save UnfoldObj: unfolding objects RefoldObj: refolding objects Bins: how many bins to use in the energy landscape plots <min/max>_landscape_kT: bounds on the landscape Returns: nothing """ # get the IWT kT = 4.1e-21 for b in Bins: LandscapeObj = InverseWeierstrass.\ FreeEnergyAtZeroForce(UnfoldObj,NumBins=b,RefoldingObjs=RefoldObj) # make a 2-D histogram of everything if (Example is not None): fig = PlotUtilities.figure(figsize=(8,8)) ext_nm = Example.Separation*1e9 IWT_Util.ForceExtensionHistograms(ext_nm, Example.Force*1e12, AddAverage=False, nBins=b) PlotUtilities.savefig(fig,OutBase + "0_{:d}hist.pdf".format(b)) # get the distance to the transition state etc print("DeltaG_Dagger is {:.1f}kT".format(Obj.DeltaGDagger)) fig = PlotUtilities.figure(figsize=(12,12)) plot_single_landscape(LandscapeObj,add_meta_half=True, add_meta_free=True,**kwargs) PlotUtilities.savefig(fig,OutBase + "1_{:d}IWT.pdf".format(b))
def run(): """ <Description> Args: param1: This is the first param. Returns: This is a description of what is returned. """ # run a comparison of fwd,rev,both base = "../Data/" plot_both = dict(color='b', linestyle='--', label="Bi-directional") plot_unfold = dict(color='m', linestyle=':', label="Only unfold") plot_refold = dict(color='r', linestyle='-', label="Only refold") input_files = [ [base + "UnfoldandRefold.pxp", "", plot_both], [base + "JustUnfold.pxp", "-unfold_only 1", plot_unfold], [base + "JustRefold.pxp", "-refold_only 1", plot_refold], ] fig = PlotUtilities.figure(figsize=(3.5, 6)) f_one_half_N = 12e-12 for f, extra_str, plot_opt in input_files: # run just the 'normal' IO x_nm, G_kT, tilt = run_single(n_pairs=50, v=50e-9, f_one_half=f_one_half_N, input_file=f, extra_str=extra_str) # save out the data header = "# (C) PRH \n #Extension (nm),\t G (kT), \t G_tilt (kT)" fname = f.split("/")[-1] + ".csv" np.savetxt(X=np.array((x_nm, G_kT, tilt)).T, fname=fname, header=header, delimiter=",") ax1 = plt.subplot(2, 1, 1) plt.plot(x_nm, G_kT, **plot_opt) label_y = ("$G_0$ ($k_\mathrm{B}$T)") PlotUtilities.lazyLabel("", label_y, "") PlotUtilities.no_x_label(ax=ax1) plt.subplot(2, 1, 2) plt.plot(x_nm, tilt, **plot_opt) label_y = ("$G_\mathrm{F_{1/2}=" + "{:.0f}".format(f_one_half_N*1e12) +\ "pN}$ ($k_\mathrm{B}$T)") PlotUtilities.lazyLabel("x (nm)", label_y, "") PlotUtilities.savefig(fig, "example_unfold_refold.png") # run just the 'normal' IO x_nm,G_kT,tilt = \ run_single(n_pairs=16,v=20e-9,input_file="../Data/input.pxp") fig = PlotUtilities.figure() plt.plot(x_nm, G_kT, 'r-') PlotUtilities.lazyLabel("x (nm)", "$G_0$ ($k_\mathrm{B}$T)", "") PlotUtilities.savefig(fig, "example_bidirectional.png")
def TomPlot(LandscapeObj,OutBase,UnfoldObj,RefoldObj,idx,f_one_half_N=0e-12): # get a forward and reverse ToX = lambda x: x * 1e9 ToForceY = lambda y: y * 1e12 fig = PlotUtilities.figure(figsize=(8,4)) plt.subplot(1,2,1) SubplotArgs = dict(alpha=0.4,linewidth=0.5) FilterN = 500 Unfold = FEC_Util.GetFilteredForce(UnfoldObj[idx],FilterN) Refold = FEC_Util.GetFilteredForce(RefoldObj[idx],FilterN) UnfoldX = ToX(Unfold.Extension) UnfoldY = ToForceY(Unfold.Force) FoldX = ToX(Refold.Extension) FoldY = ToForceY(Refold.Force) plt.plot(UnfoldX,UnfoldY,color='r',label="Unfolding", **SubplotArgs) plt.plot(FoldX,FoldY,color='b',label="Refolding", **SubplotArgs) fontdict = dict(fontsize=13) x_text_dict = dict(x=60, y=22.5, s="2 nm", fontdict=fontdict, withdash=False, rotation="horizontal") y_text_dict = dict(x=59, y=27, s="5 pN", fontdict=fontdict, withdash=False, rotation="vertical") PlotUtilities.ScaleBar(x_kwargs=dict(x=[60,62],y=[24,24]), y_kwargs=dict(x=[60,60],y=[25,30]), text_x=x_text_dict,text_y=y_text_dict) PlotUtilities.legend(loc=[0.4,0.8],**fontdict) plt.subplot(1,2,2) Obj = IWT_Util.TiltedLandscape(LandscapeObj,f_one_half_N=f_one_half_N) plt.plot(Obj.landscape_ext_nm,Obj.OffsetTilted_kT) plt.xlim([56,69]) plt.ylim([-1,4]) yoffset = 1 x_text_dict = dict(x=58.5, y=yoffset+1.5, s="2 nm", fontdict=fontdict, withdash=False,rotation="horizontal") y_text_dict = dict(x=57, y=yoffset+2.5, s=r"1 k$_\mathrm{b}$T", fontdict=fontdict, withdash=False, rotation="vertical") PlotUtilities.ScaleBar(x_kwargs=dict(x=[58,60], y=[yoffset+1.75,yoffset+1.75]), y_kwargs=dict(x=[58,58],y=[yoffset+2,yoffset+3]), text_x=x_text_dict,text_y=y_text_dict, kill_axis=True) PlotUtilities.savefig(fig,OutBase + "TomMockup" + str(idx) + ".png", subplots_adjust=dict(bottom=-0.1)) # save out the data exactly as we want to plot it common = dict(delimiter=",") ext = str(idx) + ".txt" np.savetxt(X=np.c_[UnfoldX,UnfoldY],fname=OutBase+"Unfold" + ext,**common) np.savetxt(X=np.c_[FoldX,FoldY],fname=OutBase+"Fold"+ext,**common) np.savetxt(X=np.c_[Obj.landscape_ext_nm,Obj.OffsetTilted_kT], fname=OutBase+"Landscape"+ext,**common)