def test_gene_annot(self): """ Try to add gene annotation entries to database in batches """ conn, cursor = get_db_cursor() build = "toy_build" annot = [(1, "toy", "TALON", "status", "NOVEL"), (2, "toy", "TALON", "status", "NOVEL")] # Write observed to file os.system("mkdir -p scratch/db_updates/") with open("scratch/db_updates/gene_annot.tsv", 'w') as f: for entry in annot: f.write("\t".join([str(x) for x in entry]) + "\n") batch_size = 1 talon.batch_add_annotations(cursor, "scratch/db_updates/gene_annot.tsv", "gene", batch_size) # Test if items are there query = "SELECT * FROM gene_annotations WHERE value = 'NOVEL'" cursor.execute(query) assert len(cursor.fetchall()) == 2 conn.close()
def test_exon_annot(self): """ Try to add exon annotation entries to database in batches """ conn, cursor = get_db_cursor() build = "toy_build" edge_dict = talon.make_edge_dict(cursor) run_info = talon.init_run_info(cursor, build) annot = [(1, "toy", "TALON", "status", "NOVEL"), (2, "toy", "TALON", "status", "NOVEL")] batch_size = 3 talon.batch_add_annotations(cursor, annot, "exon", batch_size) # Test if items are there query = "SELECT * FROM exon_annotations WHERE value = 'NOVEL'" cursor.execute(query) assert len(cursor.fetchall()) == 2 conn.close()