ribolands/utils.py
def make_pair_table(ss, base=0, chars=['.']):
    """ Return a secondary struture in form of pair table.

    Args:
      ss (str): secondary structure in dot-bracket format
      base (int, optional): choose between a pair-table with base 0 or 1
      chars (list, optional): a list of characters to be are ignored, default:
        ['.']

    **Example:**
       base=0: ((..)). => [5,4,-1,-1,1,0,-1]
        i.e. start counting from 0, unpaired = -1
       base=1: ((..)). => [7,6,5,0,0,2,1,0]
        i.e. start counting from 1, unpaired = 0, pt[0]=len(ss)

    Returns:
      [list]: A pair-table
    """
    stack = []
    if base == 0:
        pt = [-1] * len(ss)
    elif base == 1:
        pt = [0] * (len(ss) + base)
        pt[0] = len(ss)
    else:
        raise RiboUtilsError(f"unexpected value in make_pair_table: (base = {base})")

    for i, char in enumerate(ss, base):
        if (char == '('):
            stack.append(i)
        elif (char == ')'):
            try:
                j = stack.pop()
            except IndexError as e:
                raise RiboUtilsError("Too many closing brackets in secondary structure")
            pt[i] = j
            pt[j] = i
        elif (char not in set(chars)):
            raise RiboUtilsError(f"unexpected character in sequence: '{char}'")
    if stack != []:
        raise RiboUtilsError("Too many opening brackets in secondary structure")
    return pt
 Return a secondary struture in form of pair table.

    Args:
      ss (str): secondary structure in dot-bracket format
      base (int, optional): choose between a pair-table with base 0 or 1
      chars (list, optional): a list of characters to be are ignored, default:
        ['.']

    **Example:**
       base=0: ((..)). => [5,4,-1,-1,1,0,-1]
        i.e. start counting from 0, unpaired = -1
       base=1: ((..)). => [7,6,5,0,0,2,1,0]
        i.e. start counting from 1, unpaired = 0, pt[0]=len(ss)

    Returns:
      [list]: A pair-table
    
Return a secondary struture in form of pair table.
Return a secondary struture in form of pair table .
def make_pair_table(ss, base=0, chars=['.']):
    stack = []
    if base == 0:
        pt = [-1] * len(ss)
    elif base == 1:
        pt = [0] * (len(ss) + base)
        pt[0] = len(ss)
    else:
        raise RiboUtilsError(f"unexpected value in make_pair_table: (base = {base})")
    for i, char in enumerate(ss, base):
        if (char == '('):
            stack.append(i)
        elif (char == ')'):
            try:
                j = stack.pop()
            except IndexError as e:
                raise RiboUtilsError("Too many closing brackets in secondary structure")
            pt[i] = j
            pt[j] = i
        elif (char not in set(chars)):
            raise RiboUtilsError(f"unexpected character in sequence: '{char}'")
    if stack != []:
        raise RiboUtilsError("Too many opening brackets in secondary structure")
    return pt
def make_pair_table ( ss , base = 0 , chars = [ '.' ] ) : stack = [ ] if base == 0 : pt = [ - 1 ] * len ( ss ) elif base == 1 : pt = [ 0 ] * ( len ( ss ) + base ) pt [ 0 ] = len ( ss ) else : raise RiboUtilsError ( f"unexpected value in make_pair_table: (base = {base})" ) for i , char in enumerate ( ss , base ) : if ( char == '(' ) : stack . append ( i ) elif ( char == ')' ) : try : j = stack . pop ( ) except IndexError as e : raise RiboUtilsError ( "Too many closing brackets in secondary structure" ) pt [ i ] = j pt [ j ] = i elif ( char not in set ( chars ) ) : raise RiboUtilsError ( f"unexpected character in sequence: '{char}'" ) if stack != [ ] : raise RiboUtilsError ( "Too many opening brackets in secondary structure" ) return pt
Return a secondary struture in form of pair table.
Return a secondary struture in form of pair table .
""" Return a secondary struture in form of pair table.

    Args:
      ss (str): secondary structure in dot-bracket format
      base (int, optional): choose between a pair-table with base 0 or 1
      chars (list, optional): a list of characters to be are ignored, default:
        ['.']

    **Example:**
       base=0: ((..)). => [5,4,-1,-1,1,0,-1]
        i.e. start counting from 0, unpaired = -1
       base=1: ((..)). => [7,6,5,0,0,2,1,0]
        i.e. start counting from 1, unpaired = 0, pt[0]=len(ss)

    Returns:
      [list]: A pair-table
    """
None
[list]
ss
secondary structure in dot-bracket format
secondary structure in dot - bracket format
base
choose between a pair-table with base 0 or 1
choose between a pair - table with base 0 or 1
chars
a list of characters to be are ignored, default:
['.']
a list of characters to be are ignored default : [ ' . ' ]