import sqlite3


def get_gene_novelty(database):
    """ Given a database, get the novelty status of each gene. """

    gene_novelty = {}
    with sqlite3.connect(database) as conn:
        conn.row_factory = sqlite3.Row
        cursor = conn.cursor()

        # Fetch known genes
        cursor.execute("""SELECT ID FROM gene_annotations
                              WHERE attribute = "gene_status"
                              AND value = "KNOWN";""")
        for entry in cursor:
            gene_novelty[entry[0]] = "Known"

        # Fetch antisense genes
        cursor.execute("""SELECT ID FROM gene_annotations
                              WHERE attribute = "antisense_gene"
                              AND value = "TRUE";""")
        for entry in cursor:
            gene_novelty[entry[0]] = "Antisense"

        # Fetch intergenic genes
        cursor.execute("""SELECT ID FROM gene_annotations
                              WHERE attribute = "intergenic_novel"
                              AND value = "TRUE";""")
        for entry in cursor:
            gene_novelty[entry[0]] = "Intergenic"

    return gene_novelty