ribolands/pathfinder.py
def findpath_split(seq, ss1, ss2, md, th = 5, w = None):
    """ Calculate findpath barriers for smaller components.

    Args:
        seq: RNA sequence.
        ss1: Structure 1.
        ss2: Structure 2.
        md: ViennaRNA model details.
        th: Threshold of how many basepairs must change for an independent findpath run. Defaults to 5.
        w: Findpath width. Defaults to None.

    Returns:
        path, barrier: The folding path and the barrier height. 
            WARNING: If path splitting actually took place, then energy values
            given in the path data are only relative to the starting structure.
    """
    pt1 = make_pair_table(ss1, base = 0, chars = list('.x'))
    pt2 = make_pair_table(ss2, base = 0, chars = list('.x'))
    mindiff = None
    recurse = None
    for ij in chain(common_exterior_bases(pt1, pt2),
                    common_basepairs(pt1, pt2)):
        (i, j) = ij if isinstance(ij, tuple) else (ij, None)
        st1O, st1I = split_struct(ss1, i, j, spacer = '...')
        st2O, st2I = split_struct(ss2, i, j, spacer = '...')
        do = RNA.bp_distance(st1O, st2O)
        if do < th: continue
        di = RNA.bp_distance(st1I, st2I)
        if di < th: continue
        diff = abs(di-do)
        if mindiff is None or diff < mindiff:
            mindiff = diff
            seqO, seqI = split_struct(seq, i, j, spacer = 'NNN')
            recurse = ((i, j),
                       (seqO, st1O, st2O), 
                       (seqI, st1I, st2I))
        elif mindiff is not None and diff > mindiff:
            # No need to check the rest if we are getting worse.
            break

    if mindiff is not None:
        pathO, _ = findpath_split(*recurse[1], md, th, w)
        pathI, _ = findpath_split(*recurse[2], md, th, w)
        return findpath_merge(pathO, pathI, *recurse[0])
    else:
        fpw = 4 * RNA.bp_distance(ss1, ss2) if w is None else w
        return call_findpath(seq, ss1, ss2, md, w = fpw)
 Calculate findpath barriers for smaller components.

    Args:
        seq: RNA sequence.
        ss1: Structure 1.
        ss2: Structure 2.
        md: ViennaRNA model details.
        th: Threshold of how many basepairs must change for an independent findpath run. Defaults to 5.
        w: Findpath width. Defaults to None.

    Returns:
        path, barrier: The folding path and the barrier height. 
            WARNING: If path splitting actually took place, then energy values
            given in the path data are only relative to the starting structure.
    
Calculate findpath barriers for smaller components.
Calculate findpath barriers for smaller components .
def findpath_split(seq, ss1, ss2, md, th = 5, w = None):
    pt1 = make_pair_table(ss1, base = 0, chars = list('.x'))
    pt2 = make_pair_table(ss2, base = 0, chars = list('.x'))
    mindiff = None
    recurse = None
    for ij in chain(common_exterior_bases(pt1, pt2),
                    common_basepairs(pt1, pt2)):
        (i, j) = ij if isinstance(ij, tuple) else (ij, None)
        st1O, st1I = split_struct(ss1, i, j, spacer = '...')
        st2O, st2I = split_struct(ss2, i, j, spacer = '...')
        do = RNA.bp_distance(st1O, st2O)
        if do < th: continue
        di = RNA.bp_distance(st1I, st2I)
        if di < th: continue
        diff = abs(di-do)
        if mindiff is None or diff < mindiff:
            mindiff = diff
            seqO, seqI = split_struct(seq, i, j, spacer = 'NNN')
            recurse = ((i, j),
                       (seqO, st1O, st2O), 
                       (seqI, st1I, st2I))
        elif mindiff is not None and diff > mindiff:
            break
    if mindiff is not None:
        pathO, _ = findpath_split(*recurse[1], md, th, w)
        pathI, _ = findpath_split(*recurse[2], md, th, w)
        return findpath_merge(pathO, pathI, *recurse[0])
    else:
        fpw = 4 * RNA.bp_distance(ss1, ss2) if w is None else w
        return call_findpath(seq, ss1, ss2, md, w = fpw)
def findpath_split ( seq , ss1 , ss2 , md , th = 5 , w = None ) : pt1 = make_pair_table ( ss1 , base = 0 , chars = list ( '.x' ) ) pt2 = make_pair_table ( ss2 , base = 0 , chars = list ( '.x' ) ) mindiff = None recurse = None for ij in chain ( common_exterior_bases ( pt1 , pt2 ) , common_basepairs ( pt1 , pt2 ) ) : ( i , j ) = ij if isinstance ( ij , tuple ) else ( ij , None ) st1O , st1I = split_struct ( ss1 , i , j , spacer = '...' ) st2O , st2I = split_struct ( ss2 , i , j , spacer = '...' ) do = RNA . bp_distance ( st1O , st2O ) if do < th : continue di = RNA . bp_distance ( st1I , st2I ) if di < th : continue diff = abs ( di - do ) if mindiff is None or diff < mindiff : mindiff = diff seqO , seqI = split_struct ( seq , i , j , spacer = 'NNN' ) recurse = ( ( i , j ) , ( seqO , st1O , st2O ) , ( seqI , st1I , st2I ) ) elif mindiff is not None and diff > mindiff : break if mindiff is not None : pathO , _ = findpath_split ( * recurse [ 1 ] , md , th , w ) pathI , _ = findpath_split ( * recurse [ 2 ] , md , th , w ) return findpath_merge ( pathO , pathI , * recurse [ 0 ] ) else : fpw = 4 * RNA . bp_distance ( ss1 , ss2 ) if w is None else w return call_findpath ( seq , ss1 , ss2 , md , w = fpw )
Calculate findpath barriers for smaller components.
Calculate findpath barriers for smaller components .
""" Calculate findpath barriers for smaller components.

    Args:
        seq: RNA sequence.
        ss1: Structure 1.
        ss2: Structure 2.
        md: ViennaRNA model details.
        th: Threshold of how many basepairs must change for an independent findpath run. Defaults to 5.
        w: Findpath width. Defaults to None.

    Returns:
        path, barrier: The folding path and the barrier height. 
            WARNING: If path splitting actually took place, then energy values
            given in the path data are only relative to the starting structure.
    """ # No need to check the rest if we are getting worse.
path, barrier: The folding path and the barrier height.
WARNING: If path splitting actually took place, then energy values
given in the path data are only relative to the starting structure.
path barrier : The folding path and the barrier height . WARNING : If path splitting actually took place then energy values given in the path data are only relative to the starting structure .
seq
None
ss1
None
ss2
None
md
ViennaRNA model details.
ViennaRNA model details .
th
Threshold of how many basepairs must change for an independent findpath run. Defaults to 5.
Threshold of how many basepairs must change for an independent findpath run . Defaults to 5 .
5
w
Findpath width. Defaults to None.
Findpath width . Defaults to None .
None