utils/db_utils.py
def fetch_type_specific_rfam_accessions(rna_type, return_type = "list"):
    """
    Fetches all Rfam family accessions from the database matching the
    rna_type parameter

    rna_type: A string specifying a valid type of ncRNAs to extract
    from the database
    return_type: The python type the data will be return
    """

    query = """
    select rfam_acc from family
    where type like '%s%s%s'
    """

    cnx = RfamDB.connect()
    cursor = cnx.cursor(buffered=True)

    cursor.execute(query % (chr(37), rna_type, chr(37)))

    rfam_accs = {}

    # process accessions
    if return_type == "list":
        rfam_accs = [x[0] for x in cursor.fetchall()]
    elif return_type == "dict":
        for rfam_acc in [x[0] for x in cursor.fetchall()]:
            rfam_accs[rfam_acc] = ''

    cursor.close()
    RfamDB.disconnect(cnx)

    return rfam_accs

    Fetches all Rfam family accessions from the database matching the
    rna_type parameter

    rna_type: A string specifying a valid type of ncRNAs to extract
    from the database
    return_type: The python type the data will be return
    
Fetches all Rfam family accessions from the database matching the
rna_type parameter

A string specifying a valid type of ncRNAs to extract
from the database
return_type: The python type the data will be return
Fetches all Rfam family accessions from the database matching the rna_type parameter A string specifying a valid type of ncRNAs to extract from the database return_type : The python type the data will be return
def fetch_type_specific_rfam_accessions(rna_type, return_type = "list"):
    query = """
    select rfam_acc from family
    where type like '%s%s%s'
    """
    cnx = RfamDB.connect()
    cursor = cnx.cursor(buffered=True)
    cursor.execute(query % (chr(37), rna_type, chr(37)))
    rfam_accs = {}
    if return_type == "list":
        rfam_accs = [x[0] for x in cursor.fetchall()]
    elif return_type == "dict":
        for rfam_acc in [x[0] for x in cursor.fetchall()]:
            rfam_accs[rfam_acc] = ''
    cursor.close()
    RfamDB.disconnect(cnx)
    return rfam_accs
def fetch_type_specific_rfam_accessions ( rna_type , return_type = "list" ) : query = """
    select rfam_acc from family
    where type like '%s%s%s'
    """ cnx = RfamDB . connect ( ) cursor = cnx . cursor ( buffered = True ) cursor . execute ( query % ( chr ( 37 ) , rna_type , chr ( 37 ) ) ) rfam_accs = { } if return_type == "list" : rfam_accs = [ x [ 0 ] for x in cursor . fetchall ( ) ] elif return_type == "dict" : for rfam_acc in [ x [ 0 ] for x in cursor . fetchall ( ) ] : rfam_accs [ rfam_acc ] = '' cursor . close ( ) RfamDB . disconnect ( cnx ) return rfam_accs
Fetches all Rfam family accessions from the database matching the
rna_type parameter
Fetches all Rfam family accessions from the database matching the rna_type parameter
"""
    Fetches all Rfam family accessions from the database matching the
    rna_type parameter

    rna_type: A string specifying a valid type of ncRNAs to extract
    from the database
    return_type: The python type the data will be return
    """ # process accessions
rna_type
return_type