Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)
Function: db_to_ct_brackets()

Purpose:  Convert dot-bracket notation to CT file notation.
          
Input:    Structure given as dot-bracket notation, this may include
          pseudoknots with two types of brackets, round brackets or
          square brackets.

Return:   List of base pairs, which will be written to CT file later.

        def db_to_ct_brackets(structure):
    """ Function: db_to_ct_brackets()

        Purpose:  Convert dot-bracket notation to CT file notation.
                  
        Input:    Structure given as dot-bracket notation, this may include
                  pseudoknots with two types of brackets, round brackets or
                  square brackets.
        
        Return:   List of base pairs, which will be written to CT file later.
    """    
    stack_round = []
    stack_square = []

    base_pairs = []
    
    """ Scan the structure and put different types of opening brackets on different stacks,
        i.e. in three different lists. """
    for index, element in enumerate(structure):
        if element == '(':
            stack_round.append(index + 1)
        if element == ')':
            bp = (stack_round.pop(), (index + 1))
            bp_rev = (bp[1], bp[0])
            base_pairs.append(bp)
            base_pairs.append(bp_rev)
            
        if element == '[':
            stack_square.append(index + 1)
        if element == ']':
            bp = (stack_square.pop(), (index + 1))
            bp_rev = (bp[1], bp[0])
            base_pairs.append(bp)
            base_pairs.append(bp_rev)        
            
    return base_pairs
        


src/r/n/RNArobo-HEAD/foldfilter/dotknot/dotknot.py   RNArobo(Download)
 
        # Create CT file
        base_pairs = BPs_to_CT.db_to_ct_brackets(predicted_global_structure)
        output_ct = FILE_ID + '.ct'
        BPs_to_CT.write_CT_file(seq, base_pairs, output_ct)