diff --git a/backend/metagenedb/utils/parsers.py b/backend/metagenedb/utils/parsers.py index e8c50dc762730c71f60032dc498c9225eaf20ff1..3e91b967c4244bfffab0003e576b4f272afab2de 100644 --- a/backend/metagenedb/utils/parsers.py +++ b/backend/metagenedb/utils/parsers.py @@ -29,7 +29,7 @@ class KEGGLineParser(object): 'long_name': names[1].lstrip(), 'ec_number': ec_number } - except: + except Exception: _LOGGER.error(f"Could not parse: {line.rstrip()}. Are you sure it comes from KEGG KO list?") raise @@ -61,23 +61,24 @@ class NCBITaxonomyLineParser(object): comments -- free-text comments and citations """ elements = line.rstrip().split('|') + elements = [element.strip() for element in elements] try: return { - "tax_id": elements[0].strip(), - "parent_tax_id": elements[1].strip(), - "rank": elements[2].strip(), - "embl_code": elements[3].strip(), - "division_id": elements[4].strip(), - "inherited_div_flag": elements[5].strip(), - "genetic_code_id": elements[6].strip(), - "inherited_GC_flag": elements[7].strip(), - "mitochondrial_genetic_code_id": elements[8].strip(), - "inherited_MGC_flag": elements[9].strip(), - "GenBank_hidden_flag": elements[10].strip(), - "hidden_subtree_root_flag": elements[11].strip(), - "comments": elements[12].strip() + "tax_id": elements[0], + "parent_tax_id": elements[1], + "rank": elements[2].replace(' ', '_'), + "embl_code": elements[3], + "division_id": elements[4], + "inherited_div_flag": elements[5], + "genetic_code_id": elements[6], + "inherited_GC_flag": elements[7], + "mitochondrial_genetic_code_id": elements[8], + "inherited_MGC_flag": elements[9], + "GenBank_hidden_flag": elements[10], + "hidden_subtree_root_flag": elements[11], + "comments": elements[12] } - except: + except Exception: _LOGGER.error(f"Could not parse: {line.rstrip()}. Are you sure it comes from nodes.dmp file?") raise @@ -102,6 +103,6 @@ class NCBITaxonomyLineParser(object): "unique_name": elements[2].strip(), "name_class": elements[3].strip(), } - except: + except Exception: _LOGGER.error(f"Could not parse: {line.rstrip()}. Are you sure it comes from nodes.dmp file?") raise