utils/db_utils.py
def update_family_ncbi():
    """
    Updates table family_ncbi by adding all distinct taxonomic ids per family.

    :return: void
    """
    cnx = RfamDB.connect()

    cursor = cnx.cursor(buffered=True)
    c_cursor = cnx.cursor(buffered=True)

    cursor.execute("select rfam_acc from family")

    rfam_accs = cursor.fetchall()

    cursor.close()

    # family_ncbi query
    get_ncbi_ids = ("select distinct rs.ncbi_id, f.rfam_id, "
                    "f.rfam_acc from full_region fr, rfamseq rs, family f "
                    "where fr.rfamseq_acc=rs.rfamseq_acc "
                    "and f.rfam_acc=fr.rfam_acc "
                    "and fr.rfam_acc=\'%s\' "
                    "and fr.is_significant=1")

    insert_query = "insert into family_ncbi (ncbi_id, rfam_id, rfam_acc) values (%s,%s,%s)"

    family_ncbi_entries = []
    cursor = cnx.cursor(buffered=True)
    cursor.execute("truncate table family_ncbi")
    for rfam_acc in rfam_accs:
        c_cursor.execute(get_ncbi_ids % rfam_acc[0])
        family_ncbi_entries = list(c_cursor.fetchall())
        entries_reformatted = [(str(x[0]), str(x[1]), str(x[2])) for x in family_ncbi_entries]

        try:
            cursor.executemany(insert_query, entries_reformatted)
            cnx.commit()

        except:
            cnx.rollback()
            sys.exit("\nError updating family_ncbi table for family %s." % rfam_acc[0])

        family_ncbi_entries = []
        entries_reformatted = []

    cursor.close()
    c_cursor.close()
    RfamDB.disconnect(cnx)

    print ("Done updating family_ncbi table")

    Updates table family_ncbi by adding all distinct taxonomic ids per family.

    :return: void
    
Updates table family_ncbi by adding all distinct taxonomic ids per family.
Updates table family_ncbi by adding all distinct taxonomic ids per family .
def update_family_ncbi():
    cnx = RfamDB.connect()
    cursor = cnx.cursor(buffered=True)
    c_cursor = cnx.cursor(buffered=True)
    cursor.execute("select rfam_acc from family")
    rfam_accs = cursor.fetchall()
    cursor.close()
    get_ncbi_ids = ("select distinct rs.ncbi_id, f.rfam_id, "
                    "f.rfam_acc from full_region fr, rfamseq rs, family f "
                    "where fr.rfamseq_acc=rs.rfamseq_acc "
                    "and f.rfam_acc=fr.rfam_acc "
                    "and fr.rfam_acc=\'%s\' "
                    "and fr.is_significant=1")
    insert_query = "insert into family_ncbi (ncbi_id, rfam_id, rfam_acc) values (%s,%s,%s)"
    family_ncbi_entries = []
    cursor = cnx.cursor(buffered=True)
    cursor.execute("truncate table family_ncbi")
    for rfam_acc in rfam_accs:
        c_cursor.execute(get_ncbi_ids % rfam_acc[0])
        family_ncbi_entries = list(c_cursor.fetchall())
        entries_reformatted = [(str(x[0]), str(x[1]), str(x[2])) for x in family_ncbi_entries]
        try:
            cursor.executemany(insert_query, entries_reformatted)
            cnx.commit()
        except:
            cnx.rollback()
            sys.exit("\nError updating family_ncbi table for family %s." % rfam_acc[0])
        family_ncbi_entries = []
        entries_reformatted = []
    cursor.close()
    c_cursor.close()
    RfamDB.disconnect(cnx)
    print ("Done updating family_ncbi table")
def update_family_ncbi ( ) : cnx = RfamDB . connect ( ) cursor = cnx . cursor ( buffered = True ) c_cursor = cnx . cursor ( buffered = True ) cursor . execute ( "select rfam_acc from family" ) rfam_accs = cursor . fetchall ( ) cursor . close ( ) get_ncbi_ids = ( "select distinct rs.ncbi_id, f.rfam_id, " "f.rfam_acc from full_region fr, rfamseq rs, family f " "where fr.rfamseq_acc=rs.rfamseq_acc " "and f.rfam_acc=fr.rfam_acc " "and fr.rfam_acc=\'%s\' " "and fr.is_significant=1" ) insert_query = "insert into family_ncbi (ncbi_id, rfam_id, rfam_acc) values (%s,%s,%s)" family_ncbi_entries = [ ] cursor = cnx . cursor ( buffered = True ) cursor . execute ( "truncate table family_ncbi" ) for rfam_acc in rfam_accs : c_cursor . execute ( get_ncbi_ids % rfam_acc [ 0 ] ) family_ncbi_entries = list ( c_cursor . fetchall ( ) ) entries_reformatted = [ ( str ( x [ 0 ] ) , str ( x [ 1 ] ) , str ( x [ 2 ] ) ) for x in family_ncbi_entries ] try : cursor . executemany ( insert_query , entries_reformatted ) cnx . commit ( ) except : cnx . rollback ( ) sys . exit ( "\nError updating family_ncbi table for family %s." % rfam_acc [ 0 ] ) family_ncbi_entries = [ ] entries_reformatted = [ ] cursor . close ( ) c_cursor . close ( ) RfamDB . disconnect ( cnx ) print ( "Done updating family_ncbi table" )
Updates table family_ncbi by adding all distinct taxonomic ids per family.
Updates table family_ncbi by adding all distinct taxonomic ids per family .
"""
    Updates table family_ncbi by adding all distinct taxonomic ids per family.

    :return: void
    """ # family_ncbi query
None