Exemplo n.º 1
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]
Exemplo n.º 2
0
def _make_algned_plot(alignment, label):
    fig = PlotUtilities.figure((3, 4))
    gs = gridspec.GridSpec(3, 2)
    # make the 'standard' alignment plots
    axes = _heatmap_alignment(gs, alignment, 0)
    _ensemble_alignment(gs, alignment, 1)
    out_name = "./FigureS_Alignment_{:s}.png".format(label)
    PlotUtilities.title(label, ax=axes[0])
    PlotUtilities.savefig(fig,
                          out_name,
                          subplots_adjust=dict(hspace=0.12, wspace=0.02))
Exemplo n.º 3
0
def data_plot(fecs, energies, gs1=None, xlim=[None, None]):
    n_cols = len(energies)
    n_rows = 2
    all_ax = []
    if gs1 is None:
        gs1 = gridspec.GridSpec(n_rows + 1, n_cols)
    for i, (data, e) in enumerate(zip(fecs, energies)):
        axs_tmp = [plt.subplot(gs1[j, i]) for j in range(n_rows)]
        ax1, ax2 = axs_tmp
        PlotUtil.plot_landscapes(data, e, ax1=ax1, ax2=ax2)
        # every axis after the first gets more of the decoaration chopped...
        all_ax.append(axs_tmp)
        # XXX should really put this into the meta class...
        plt.sca(ax1)
        tmp_str = e.file_name
        match = re.search(
            r"""
                          ([\w+-]+Retinal)/([\d\w]+)/([\d\w]+)/
                          """, tmp_str, re.IGNORECASE | re.VERBOSE)
        assert match is not None
        groups = match.groups()
        BR, velocity, title = groups
        vel_label = velocity.replace("nms", "")
        title_label = title.replace("FEC", "")
        title = "{:s}, v={:s}\n {:s}".format(BR, vel_label, title_label)
        PlotUtilities.title(title, fontsize=5)
        for a in axs_tmp:
            a.set_xlim(xlim)
    fix_axes(all_ax)
    xlim = all_ax[0][0].get_xlim()
    # just get the IWT
    energies_plot = [e._iwt_obj for e in energies]
    q_interp, splines = RetinalUtil.interpolating_G0(energies_plot)
    # get an average/stdev of energy
    ax = plt.subplot(gs1[-1, 0])
    mean_energy, std_energy = PlotUtil.plot_mean_landscape(q_interp,
                                                           splines,
                                                           ax=ax)
    max_q_nm = RetinalUtil.q_GF_nm_plot()
    q_at_max_energy,_,_ =  \
        PlotUtil.plot_delta_GF(q_interp,mean_energy,std_energy,
                               max_q_nm=max_q_nm)
    plt.axvspan(q_at_max_energy, max(xlim), color='k', alpha=0.3)
    ax.set_xlim(xlim)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
def _plot_fmt(ax,
              xlim,
              ylim,
              is_bottom=False,
              color=False,
              is_left=True,
              ylabel="$F$ (pN)",
              xlabel="Extension (nm)"):
    PlotUtilities.tickAxisFont(ax=ax)
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)
    PlotUtilities.title("", ax=ax)
    PlotUtilities.ylabel(ylabel, ax=ax)
    PlotUtilities.xlabel(xlabel, ax=ax)
    if (not is_bottom):
        PlotUtilities.no_x_label(ax=ax)
        PlotUtilities.xlabel("", ax=ax)
    if (not is_left):
        PlotUtilities.no_y_label(ax=ax)
        PlotUtilities.ylabel("", ax=ax)
    if color:
        color_kw = dict(ax=ax, color='w', label_color='k')
        PlotUtilities.color_x(**color_kw)
        PlotUtilities.color_y(**color_kw)