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

add full tax to csv of metadata

parent a7abdb2b
Pipeline #37722 passed with stages
in 3 minutes and 23 seconds
......@@ -54,8 +54,11 @@ class GeneViewSet(BulkViewSet):
def _extract_taxonomy_info(self, gene):
if gene.taxonomy is None:
return ['', '', '']
return [gene.taxonomy.tax_id, gene.taxonomy.name, gene.taxonomy.rank]
return ['', '', '', '']
return [
gene.taxonomy.tax_id, gene.taxonomy.name,
gene.taxonomy.rank, gene.taxonomy.one_line_detailed_taxonomy
]
def _extract_function_info(self, gene):
if not gene.functions.all():
......@@ -90,7 +93,7 @@ class GeneViewSet(BulkViewSet):
with StringIO() as csv_file:
# Write header
header = ",".join([
'gene_id', 'gene_name', 'gene_source', 'length', 'tax_id', 'tax_name', 'tax_rank',
'gene_id', 'gene_name', 'gene_source', 'length', 'tax_id', 'tax_name', 'tax_rank', 'tax_full',
'kegg_id', 'eggnog_id',
])
csv_file.write(f"{header}\n")
......
......@@ -31,7 +31,7 @@ class TestGenes(TestCase):
gene = GeneFactory()
expected_items = [
gene.gene_id, gene.name, gene.source, gene.length,
'', '', '', '', ''
'', '', '', '', '', ''
]
expected_line = ','.join([str(item) for item in expected_items])
# Make test with method from GeneViewSet
......@@ -43,7 +43,7 @@ class TestGenes(TestCase):
gene = GeneWithTaxonomyFactory()
expected_items = [
gene.gene_id, gene.name, gene.source, gene.length,
gene.taxonomy.tax_id, gene.taxonomy.name, gene.taxonomy.rank,
gene.taxonomy.tax_id, gene.taxonomy.name, gene.taxonomy.rank, gene.taxonomy.one_line_detailed_taxonomy,
'', ''
]
expected_line = ','.join([str(item) for item in expected_items])
......@@ -56,7 +56,7 @@ class TestGenes(TestCase):
gene = GeneWithKeggFactory()
expected_items = [
gene.gene_id, gene.name, gene.source, gene.length,
'', '', '',
'', '', '', '',
gene.functions.all()[0].function_id, ''
]
expected_line = ','.join([str(item) for item in expected_items])
......@@ -69,7 +69,7 @@ class TestGenes(TestCase):
gene = GeneWithEggNOGFactory()
expected_items = [
gene.gene_id, gene.name, gene.source, gene.length,
'', '', '',
'', '', '', '',
'', gene.functions.all()[0].function_id,
]
expected_line = ','.join([str(item) for item in expected_items])
......
Markdown is supported
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