Commit 0d87ecd0 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

use factory to create Virgo genes

parent 6bbb575f
Pipeline #29799 passed with stages
in 3 minutes and 22 seconds
......@@ -68,7 +68,10 @@ class Command(BaseCommand):
help = 'Create or update all KEGG annotation for Virgo genes (from `8.A.kegg.ortholog.txt` file).'
def add_arguments(self, parser):
parser.add_argument('annotation', help='8.A.kegg.ortholog.txt file from Virgo')
help='8.A.kegg.ortholog.txt file from Virgo. Genes need to exist in DB for this script to work.'
parser.add_argument('--test', action='store_true', help='Run only on first 10000 entries.')
def set_logger_level(self, verbosity):
......@@ -3,36 +3,30 @@ import os
from rest_framework.test import APITestCase
from metagenedb.apps.catalog.models import Gene
from import ImportVirgoGenes
from import ImportVirgoGeneKeggAnnotation
from metagenedb.apps.catalog.factory import GeneFactory
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)
def setUpTestData(cls):
virgo_gene_length_file = os.path.join(os.path.dirname(__file__), "./test_files/virgo_gene_length.tsv")
loader = ImportVirgoGenes(virgo_gene_length_file)
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',
......@@ -42,8 +36,7 @@ class TestEndToEnd(APITestCase):
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])
self.assertEqual(getattr(created_gene, 'name'), expected_genes[created_gene.gene_id]['name'])
# Check functions
for function in created_gene.functions.all():
self.assertIn(function.source, ['kegg', 'eggnog'])
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