Exemple #1
0
def _G0_plot(plot_dir, data_sliced, landscape, fmt):
    # XXX why is this necessary?? screwing up absolute values
    previous_JCP = FigureUtil.read_non_peg_landscape(base="../../FigData/")
    offset_s = np.mean([d.Separation[0] for d in data_sliced])
    G_hao = landscape.G0_kcal_per_mol
    idx_zero = np.where(landscape.q_nm <= 100)
    G_hao = G_hao - landscape.G0_kcal_per_mol[0]
    G_JCP = previous_JCP.G0_kcal_per_mol - previous_JCP.G0_kcal_per_mol[0] + 50
    offset_jcp_nm = min(previous_JCP.q_nm)
    landscape_offset_nm = min(landscape.q_nm)
    q_JCP_nm = previous_JCP.q_nm - offset_jcp_nm + 5
    q_Hao_nm = landscape.q_nm - landscape_offset_nm
    fig = FigureUtil._fig_single(y=6)
    xlim, ylim = FigureUtil._limits(data_sliced)
    ax1 = plt.subplot(2, 1, 1)
    FigureUtil._plot_fec_list(data_sliced, **fmt)
    FigureUtil._plot_fmt(ax1, **fmt)
    ax2 = plt.subplot(2, 1, 2)
    plt.plot(q_Hao_nm, G_hao, label="Aligned, IWT")
    plt.plot(q_JCP_nm, G_JCP, 'r--', label="JCP landscape")
    FigureUtil._plot_fmt(ax2,
                         ylabel="G (kcal/mol)",
                         is_bottom=True,
                         xlim=xlim,
                         ylim=[None, None])
    PlotUtilities.legend(ax=ax2, handlelength=2)
    ax2.set_xlim(fmt['xlim'])
    PlotUtilities.savefig(fig, plot_dir + "FigureSX_LandscapeComparison.png")
Exemple #2
0
def _plot_comparison(plot_dir, heatmap_jcp, iwt_obj, data_sliced_plot):
    fmt = dict(xlim=[-20, 55], ylim=[-20, 150])
    _G0_plot(plot_dir, data_sliced_plot, iwt_obj, fmt=fmt)
    fig = FigureUtil._fig_single(y=6)
    ax1 = plt.subplot(2, 1, 1)
    extent = heatmap_jcp._extent_nm_and_pN(offset_x_nm=0)
    plt.imshow(heatmap_jcp.heatmap,
               origin='lower',
               aspect='auto',
               extent=extent,
               cmap=plt.cm.afmhot)
    FigureUtil._plot_fmt(is_bottom=False, ax=ax1, **fmt)
    PlotUtilities.title("Top: JCP.\n Bottom: New data, - PEG3400")
    ax2 = plt.subplot(2, 1, 2)
    FEC_Plot.heat_map_fec(data_sliced_plot,
                          use_colorbar=False,
                          num_bins=(150, 75),
                          separation_max=fmt['xlim'][1])
    FigureUtil._plot_fmt(is_bottom=True, ax=ax2, **fmt)
    out_name = plot_dir + "FigureSX_jcp_fec_comparison.png"
    PlotUtilities.savefig(fig, out_name, tight=True)
Exemple #3
0
def _heatmap_alignment(gs, alignment, col_idx):
    xlim, ylim = FigureUtil._limits(alignment._all_fecs)
    max_x = xlim[1]
    bin_step_nm = 1
    bin_step_pN = 5
    bins_x = np.arange(xlim[0], xlim[1] + bin_step_nm, step=bin_step_nm)
    bins_y = np.arange(ylim[0], ylim[1] + bin_step_pN, step=bin_step_pN)
    common_kw = dict(separation_max=max_x,
                     use_colorbar=False,
                     title="",
                     bins=(bins_x, bins_y))
    ax1 = plt.subplot(gs[0, col_idx])
    FEC_Plot.heat_map_fec(alignment.zeroed.fec_list, **common_kw)
    FigureUtil._plot_fmt(ax1, xlim, ylim, color=True)
    ax2 = plt.subplot(gs[1, col_idx])
    FEC_Plot.heat_map_fec(alignment.polished.fec_list, **common_kw)
    FigureUtil._plot_fmt(ax2, xlim, ylim, color=True)
    title_kw = dict(color='b', y=0.95, loc='left', fontsize=6)
    downarrow = "$\Downarrow$"
    title_sub = downarrow + " Subtract $X_{\mathbf{PEG3400}}(F)$ + " + \
                "$L_{\mathbf{0,C-term}}$"
    PlotUtilities.title(title_sub, **title_kw)
    PlotUtilities.no_x_label(ax=ax2)
    ax3 = plt.subplot(gs[2, col_idx])
    FEC_Plot.heat_map_fec(alignment.blacklisted.fec_list, **common_kw)
    FigureUtil._plot_fmt(ax3, xlim, ylim, is_bottom=True, color=True)
    PlotUtilities.title(downarrow + " Remove poorly-fit FECs", **title_kw)
    return [ax1, ax2, ax3]
def run():
    input_dir = "../../../../Data/FECs180307/"
    out_dir = "./"
    q_offset_nm = 100
    q_interp, energy_list_arr, _ = FigureUtil.\
        _read_energy_list_and_q_interp(input_dir, q_offset=q_offset_nm,
                                       min_fecs=9)
    # read in some example data
    base_dir_BR = input_dir + "BR+Retinal/"
    names_BR = ["/BR+Retinal/3000nms/170503FEC/landscape_"]
    PEG600 = FigureUtil._read_samples(base_dir_BR,names_BR)[0]
    # read in the FECs
    fecs = FigureUtil._snapsnot(PEG600.base_dir,
                                step=Pipeline.Step.REDUCED).fec_list
    args_mean = (energy_list_arr, q_interp)
    mean_A = mean_A_jarzynski(*args_mean)
    mean_G = mean_G_iwt(*args_mean)
    mean_F_from_dot = mean_A_dot_iwt(*args_mean)[0]
    ex = fecs[0]
    q = q_interp * 1e-9
    # xxx offset q and z... probably a little off!
    z = ex.ZFunc(ex) + q[0]
    k = ex.SpringConstant
    beta = ex.Beta
    A = mean_A[0]
    G = mean_G[0]
    n_iters = 5000
    force =True
    kw_lr = dict(G0=G, A=A, q=q, z=z, k=k, beta=beta,n_iters=n_iters)
    lr = CheckpointUtilities.getCheckpoint("./lr_deconv.pkl",
                                           _deconvoled_lr,force,**kw_lr)
    diff_kT = np.array(lr.mean_diffs) * beta
    min_idx = np.argmin(diff_kT)
    idx_search = np.logspace(start=3,stop=np.floor(np.log2(min_idx)),
                             endpoint=True,num=10,base=2)
    idx_to_use = [int(i) for i in idx_search]
    # fit a spline to the converged G to get the mean restoring force
    fig = PlotUtilities.figure((4,6))
    xlim = [min(q_interp)-5, max(q_interp)]
    fmt_kw = dict(xlim=xlim,ylim=[None,None])
    ax1 = plt.subplot(3,1,1)
    plt.plot(diff_kT)
    plt.axvline(min_idx)
    FigureUtil._plot_fmt(ax1,is_bottom=True,xlabel="iter #",
                         ylabel="diff G (kT)",xlim=[None,None],ylim=[None,None])
    ax2 = plt.subplot(3,1,2)
    plt.plot(q_interp,lr._G0_initial_lr.G0_kT,color='b',linewidth=3)
    plt.plot(q_interp,lr.G0_kT,color='r',linewidth=3)
    FigureUtil._plot_fmt(ax2,is_bottom=False,ylabel="G (kT)",**fmt_kw)
    ax1 = plt.subplot(3,1,3)
    FigureUtil._plot_fec_list(fecs, xlim, ylim=[None,None])
    for i in idx_to_use:
        _plot_f_at_iter_idx(lr, i)
    _plot_f_at_iter_idx(lr, 0,label="F from G0",linewidth=4)
    plt.plot(q_interp,mean_F_from_dot*1e12,label="F from A_z_dot",linewidth=2)
    # also plot the force we expect from the original A_z_dot
    FigureUtil._plot_fmt(ax1,is_bottom=True,xlim=xlim,ylim=[None,None])
    PlotUtilities.legend()
    PlotUtilities.savefig(fig,"FigureS_A_z.png")
    pass
Exemple #5
0
def _ensemble_alignment(gs, alignment, col_idx):
    xlim, ylim = FigureUtil._limits(alignment._all_fecs)
    common_kw = dict(xlim=xlim, ylim=ylim)
    kw_fmt = dict(color=False, is_left=(col_idx == 0), **common_kw)
    ax1 = plt.subplot(gs[0, col_idx])
    FigureUtil._plot_fec_list(alignment.zeroed.fec_list, **common_kw)
    FigureUtil._plot_fmt(ax1, **kw_fmt)
    ax2 = plt.subplot(gs[1, col_idx])
    FigureUtil._plot_fec_list(alignment.polished.fec_list, **common_kw)
    FigureUtil._plot_fmt(ax2, **kw_fmt)
    PlotUtilities.no_x_label(ax=ax2)
    ax3 = plt.subplot(gs[2, col_idx])
    FigureUtil._plot_fec_list(alignment.blacklisted.fec_list, **common_kw)
    FigureUtil._plot_fmt(ax3, is_bottom=True, **kw_fmt)
Exemple #6
0
def _make_work_plot(fec_list,x_arr,works_kcal,gs,col,color,title):
    # get the interpolated work
    x_interp, mean_W, std_W = _mean_work(x_arr, works_kcal)
    # use Davids function
    shift_david_nm_plot = 10
    L0_david = 11e-9
    max_david = L0_david * 0.95
    x_david = np.linspace(0,max_david,num=100)
    style_david = dict(color='b',linestyle='--',label="David")
    legend_kw = dict(handlelength=1.5,handletextpad=0.3,fontsize=6)
    david_F = _f_david(kbT=4.1e-21, L0=L0_david, Lp=0.4e-9, x=x_david)
    david_W = _single_work(x=x_david,f=david_F)
    x_david_plot = x_david * 1e9 - shift_david_nm_plot
    W_david_plot = david_W * kcal_per_mol_per_J()
    f_david_plot = david_F * 1e12
    is_left = (col == 0)
    fmt_kw = dict(is_left=is_left)
    label_work = "$W$ (kcal/mol)"
    # interpolate each work onto a grid
    xlim, ylim, ylim_work = xlim_ylim()
    fudge_work = max(std_W)
    ax1 = plt.subplot(gs[0,col])
    FigureUtil._plot_fec_list(fec_list,xlim,ylim)
    plt.plot(x_david_plot,f_david_plot,**style_david)
    if is_left:
        PlotUtilities.legend(**legend_kw)
    FigureUtil._plot_fmt(ax1, xlim, ylim,**fmt_kw)
    PlotUtilities.title(title,color=color)
    ax2 = plt.subplot(gs[1,col])
    for x,w in zip(x_arr,works_kcal):
        plt.plot(x * 1e9,w,linewidth=0.75)
    FigureUtil._plot_fmt(ax2, xlim, ylim_work,ylabel=label_work,**fmt_kw)
    ax3 = plt.subplot(gs[2,col])
    _plot_mean_works(x_interp, mean_W, std_W, color, title)
    style_lower_david = dict(**style_david)
    if (not is_left):
        style_lower_david['label'] = None
    plt.plot(x_david_plot,W_david_plot,'b--',zorder=5,**style_lower_david)
    PlotUtilities.legend(**legend_kw)
    FigureUtil._plot_fmt(ax3, xlim, ylim_work,is_bottom=True,
                         ylabel=label_work,**fmt_kw)