utils/db_utils.py
def reset_is_significant(clan_comp_type='FULL'):
    """
    This function resets full_region's is_singificant field's back to 1.
    This should be able to update all or part of the table for clan
    competition initialization and restoration.
    """
    seq_regs = []

    cnx = RfamDB.connect()

    # cursor to fetch data
    d_cursor = cnx.cursor(buffered=True)

    # query to fetch all non significant sequences
    if clan_comp_type.upper() == 'FULL':
        select_query = ("SELECT rfam_acc, rfamseq_acc, seq_start FROM full_region "
                        "WHERE is_significant=0")

        # query to update 0 fields from s_query
        update_query = ("UPDATE full_region SET is_significant=1 "
                        "WHERE rfam_acc=%s AND rfamseq_acc=%s AND seq_start=%s")

    elif clan_comp_type.upper() == 'PDB':
        select_query = ("SELECT rfam_acc, pdb_id, chain, pdb_start from pdb_full_region "
                        "WHERE is_significant=0")

        update_query = ("UPDATE pdb_full_region SET is_significant=1 "
                        "WHERE rfam_acc=%s AND pdb_id=%s AND chain=%s AND pdb_start=%s")

        d_cursor.execute(select_query)

    # construct region list here
    for row in d_cursor:
        if clan_comp_type.upper() == 'FULL':
            seq_regs.append((str(row[0]), str(row[1]), int(row[2])))

        elif clan_comp_type.upper() == 'PDB':
            seq_regs.append((str(row[0]), str(row[1]), str(row[2]), int(row[3])))

    d_cursor.close()

    # get a new cursor for db updates
    u_cursor = cnx.cursor(raw=True)

    # update db
    try:
        u_cursor.executemany(update_query, seq_regs)
        cnx.commit()
    except:
        print ("MySQL Update Error. Rolling back...")
        cnx.rollback()
        u_cursor.close()
        RfamDB.disconnect(cnx)

    u_cursor.close()
    RfamDB.disconnect(cnx)

    This function resets full_region's is_singificant field's back to 1.
    This should be able to update all or part of the table for clan
    competition initialization and restoration.
    
This function resets full_region's is_singificant field's back to 1.
This should be able to update all or part of the table for clan
competition initialization and restoration.
This function resets full_region ' s is_singificant field ' s back to 1 . This should be able to update all or part of the table for clan competition initialization and restoration .
def reset_is_significant(clan_comp_type='FULL'):
    seq_regs = []
    cnx = RfamDB.connect()
    d_cursor = cnx.cursor(buffered=True)
    if clan_comp_type.upper() == 'FULL':
        select_query = ("SELECT rfam_acc, rfamseq_acc, seq_start FROM full_region "
                        "WHERE is_significant=0")
        update_query = ("UPDATE full_region SET is_significant=1 "
                        "WHERE rfam_acc=%s AND rfamseq_acc=%s AND seq_start=%s")
    elif clan_comp_type.upper() == 'PDB':
        select_query = ("SELECT rfam_acc, pdb_id, chain, pdb_start from pdb_full_region "
                        "WHERE is_significant=0")
        update_query = ("UPDATE pdb_full_region SET is_significant=1 "
                        "WHERE rfam_acc=%s AND pdb_id=%s AND chain=%s AND pdb_start=%s")
        d_cursor.execute(select_query)
    for row in d_cursor:
        if clan_comp_type.upper() == 'FULL':
            seq_regs.append((str(row[0]), str(row[1]), int(row[2])))
        elif clan_comp_type.upper() == 'PDB':
            seq_regs.append((str(row[0]), str(row[1]), str(row[2]), int(row[3])))
    d_cursor.close()
    u_cursor = cnx.cursor(raw=True)
    try:
        u_cursor.executemany(update_query, seq_regs)
        cnx.commit()
    except:
        print ("MySQL Update Error. Rolling back...")
        cnx.rollback()
        u_cursor.close()
        RfamDB.disconnect(cnx)
    u_cursor.close()
    RfamDB.disconnect(cnx)
def reset_is_significant ( clan_comp_type = 'FULL' ) : seq_regs = [ ] cnx = RfamDB . connect ( ) d_cursor = cnx . cursor ( buffered = True ) if clan_comp_type . upper ( ) == 'FULL' : select_query = ( "SELECT rfam_acc, rfamseq_acc, seq_start FROM full_region " "WHERE is_significant=0" ) update_query = ( "UPDATE full_region SET is_significant=1 " "WHERE rfam_acc=%s AND rfamseq_acc=%s AND seq_start=%s" ) elif clan_comp_type . upper ( ) == 'PDB' : select_query = ( "SELECT rfam_acc, pdb_id, chain, pdb_start from pdb_full_region " "WHERE is_significant=0" ) update_query = ( "UPDATE pdb_full_region SET is_significant=1 " "WHERE rfam_acc=%s AND pdb_id=%s AND chain=%s AND pdb_start=%s" ) d_cursor . execute ( select_query ) for row in d_cursor : if clan_comp_type . upper ( ) == 'FULL' : seq_regs . append ( ( str ( row [ 0 ] ) , str ( row [ 1 ] ) , int ( row [ 2 ] ) ) ) elif clan_comp_type . upper ( ) == 'PDB' : seq_regs . append ( ( str ( row [ 0 ] ) , str ( row [ 1 ] ) , str ( row [ 2 ] ) , int ( row [ 3 ] ) ) ) d_cursor . close ( ) u_cursor = cnx . cursor ( raw = True ) try : u_cursor . executemany ( update_query , seq_regs ) cnx . commit ( ) except : print ( "MySQL Update Error. Rolling back..." ) cnx . rollback ( ) u_cursor . close ( ) RfamDB . disconnect ( cnx ) u_cursor . close ( ) RfamDB . disconnect ( cnx )
This function resets full_region's is_singificant field's back to 1.
This function resets full_region ' s is_singificant field ' s back to 1 .
"""
    This function resets full_region's is_singificant field's back to 1.
    This should be able to update all or part of the table for clan
    competition initialization and restoration.
    """ # cursor to fetch data # query to fetch all non significant sequences # query to update 0 fields from s_query # construct region list here # get a new cursor for db updates # update db
clan_comp_type