import sqlite3


def get_annotation_status_dict(database, cat_type):
    """ Query the provided database and return a dictionary as follows:
            ID of gene or transcript -> [ KNOWN/NOVEL, SOURCE]
        The 'cat_type' variable should be either 'gene' or 'transcript',
        indicating which table to query. """

    annotation_status = {}

    conn = sqlite3.connect(database)
    cursor = conn.cursor()

    query = "SELECT * FROM " + cat_type + "_annotations WHERE attribute = '" + cat_type + "_status'"
    cursor.execute(query)
    annot_status = cursor.fetchall()
   
    for result in annot_status:
        ID = str(result[0])
        annotation = result[-1]
        source = result[2]

        if ID not in annotation_status:
            annotation_status[ID] = [annotation, source]
        else:
            if annotation_status[ID][0] == "KNOWN":
                continue
            else:
                annotation_status[ID] = [annotation, source]

    conn.close()
    return annotation_status