Commit 6bbb575f authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

add end to end test for kegg annotation of virgo

parent 220bb356
Pipeline #29794 passed with stages
in 3 minutes and 14 seconds
V1 K12345 ljo:LJ0360 dvvi:GSVIVP00035275001 GSVIVT00035275001; assembled CDS; K02948 small subunit ribosomal protein S11
V2 K67890 shg:Sph21_4943 dtni:5367 ;
import os
from rest_framework.test import APITestCase
from metagenedb.apps.catalog.models import Gene
from metagenedb.apps.catalog.management.commands.import_virgo_genes import ImportVirgoGenes
from metagenedb.apps.catalog.management.commands.import_virgo_kegg import ImportVirgoGeneKeggAnnotation
from metagenedb.apps.catalog.factory.function import generate_fake_functions_db
class TestEndToEnd(APITestCase):
"""
This test depends on two files, one to create genes (gene_length) and the other for this test (kegg)
"""
@classmethod
def setUpTestData(cls):
generate_fake_functions_db()
virgo_gene_length_file = os.path.join(os.path.dirname(__file__), "./test_files/virgo_gene_length.tsv")
loader = ImportVirgoGenes(virgo_gene_length_file)
loader.load_all()
def test_end_to_end(self):
test_file = os.path.join(os.path.dirname(__file__), "./test_files/virgo_kegg.tsv")
loader = ImportVirgoGeneKeggAnnotation(test_file)
expected_genes = {
'v1': {
'source': 'virgo',
'name': 'V1',
'functions': {
'kegg': 'K12345',
}
},
'v2': {
'source': 'virgo',
'name': 'V2',
'functions': {
'kegg': 'K67890',
}
},
}
loader.load_all()
created_genes = Gene.objects.all().prefetch_related('functions')
for created_gene in created_genes:
for key in ['source', 'name']:
self.assertEqual(getattr(created_gene, key), expected_genes[created_gene.gene_id][key])
# Check functions
for function in created_gene.functions.all():
self.assertIn(function.source, ['kegg', 'eggnog'])
self.assertEqual(
function.function_id, expected_genes[created_gene.gene_id]['functions'][function.source]
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment