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

fix handling of taxonomy and way it is skipped

parent 220b598c
......@@ -55,6 +55,8 @@ class ImportIGCGenes(object):
"""
phylum = gene_dict.pop(self.PHYLUM_COL)
genus = gene_dict.pop(self.GENUS_COL)
if self.skip_tax:
return gene_dict
resp_dict = {}
if genus != unknown_val:
resp_dict = self.metagenedb_taxonomy_api.get_all(params={'name': genus, 'rank': 'genus'})
......@@ -81,10 +83,7 @@ class ImportIGCGenes(object):
gene_dict['gene_name'] = gene_dict['gene_id']
gene_dict['gene_id'] = slugify(gene_dict['gene_id'])
gene_dict['functions'] = gene_dict.pop('kegg_ko')
if gene_dict.get('taxonomy', None) == 'unknown' or self.skip_tax:
gene_dict.pop('taxonomy')
else:
gene_dict = self._select_taxonomy(gene_dict)
gene_dict = self._select_taxonomy(gene_dict)
if self.skip_functions or 'unknown' in gene_dict['functions']:
gene_dict.pop('functions')
return gene_dict
......
......@@ -76,23 +76,10 @@ class TestCleanGene(TestCase):
self.gene_dict = {
'gene_id': 'gene.01',
'length': 135,
'taxonomy': 'Taxo',
'kegg_ko': ['K00001']
}
def test_clean_gene(self):
expected_gene_dict = {
'gene_id': 'gene-01',
'gene_name': 'gene.01',
'length': 135,
'taxonomy': 'Taxo',
'functions': ['K00001']
}
test_gene_dict = self.import_igc_genes._clean_gene(self.gene_dict)
self.assertDictEqual(test_gene_dict, expected_gene_dict)
def test_clean_gene_skip_taxo(self):
self.import_igc_genes.skip_tax = True
expected_gene_dict = {
'gene_id': 'gene-01',
'gene_name': 'gene.01',
......@@ -108,7 +95,6 @@ class TestCleanGene(TestCase):
'gene_id': 'gene-01',
'gene_name': 'gene.01',
'length': 135,
'taxonomy': 'Taxo',
}
test_gene_dict = self.import_igc_genes._clean_gene(self.gene_dict)
self.assertDictEqual(test_gene_dict, expected_gene_dict)
......
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