예제 #1
0
def feather_single(d,force_no_adhesion=False,**kw):
    """
    :param d: FEC to get FJC+WLC fit of
    :param min_F_N: minimum force, in Newtons, for fitting event. helps avoid
     occasional small force events
    :param kw: keywords to use for fitting...
    :return:
    """
    force_N = d.Force
    where_above_surface = np.where(force_N >= 0)[0]
    assert where_above_surface.size > 0, "Force never above surface "
    # use FEATHER; fit to the first event, don't look for adhesion
    d_pred_only = d._slice(slice(0,None,1))
    # first, try removing surface adhesions
    is_600 = _is_PEG600(d)
    skip_adhesion = force_no_adhesion or is_600
    f_refs_initial = [Detector.delta_mask_function] if skip_adhesion else None
    feather_kw =  dict(d=d_pred_only,**kw)
    pred_info,tau_n = _detect_retract_FEATHER(f_refs=f_refs_initial,
                                              **feather_kw)
    # if we removed more than 20nm or we didnt find any events, then
    # FEATHER got confused by a near-surface BR. Tell it not to look for
    # surface adhesions
    expected_surface_m = d.Separation[pred_info.slice_fit.start]
    expected_gf_m = 20e-9
    if ((len(pred_info.event_idx) == 0) or (expected_surface_m > expected_gf_m)):
        f_refs = [Detector.delta_mask_function]
        pred_info,tau_n = _detect_retract_FEATHER(f_refs=f_refs,
                                                  **feather_kw)
    pred_info.tau_n = tau_n
    assert len(pred_info.event_idx) > 0 , "FEATHER can't find an event..."
    # POST: found at least one event.
    to_ret = ProcessingUtil.AlignedFEC(d,info_fit=None,feather_info=pred_info)
    return to_ret
예제 #2
0
def align_single(d,min_F_N,**kw):
    """
    :param d: FEC to get FJC+WLC fit of
    :param min_F_N: minimum force, in Newtons, for fitting event. helps avoid
     occasional small force events
    :param kw: keywords to use for fitting...
    :return:
    """
    force_N = d.Force
    pred_info = d.info_feather
    max_fit_idx = GF2_event_idx(d,min_F_N)
    # determine the minimum fit index by the maximum of...
    # (1) the surface
    where_above_surface = np.where(force_N >= 0)[0]
    assert where_above_surface.size > 0 , "Never above surface"
    first_time_above_surface = where_above_surface[0]
    assert first_time_above_surface < max_fit_idx , \
        "Couldn't find fitting region"
    # (2) the last event *before* the current, if it exists
    event_idx = pred_info.event_idx
    idx_last_event_before = np.where(event_idx < max_fit_idx)[0]
    start_idx = first_time_above_surface
    if idx_last_event_before.size > 0:
        # then we have an event *before* the final GC helix one.
        # make that the start idx, if it is later (it should be!)
        new_start = event_idx[idx_last_event_before[-1]]
        assert new_start > start_idx , "First event is less than surface?!"
        start_idx = new_start
    # start the fit after any potential adhesions
    fit_start = max(start_idx,pred_info.slice_fit.start)
    fit_slice = slice(fit_start,max_fit_idx,1)
    # slice the object to just the region we want
    obj_slice = d._slice(fit_slice)
    # fit wlc to the f vs x of that slice
    info_fit = WLCHao.hao_fit(obj_slice.Separation,obj_slice.Force,**kw)
    info_fit.fit_slice = fit_slice
    to_ret = ProcessingUtil.AlignedFEC(d,info_fit,feather_info=pred_info)
    return to_ret