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

remove end line

parent b3c47f2f
...@@ -15,7 +15,7 @@ class EggNogAnnotationLineParser(object): ...@@ -15,7 +15,7 @@ class EggNogAnnotationLineParser(object):
return { return {
'functional_category': elements[2], 'functional_category': elements[2],
'function_id': elements[1], 'function_id': elements[1],
'name': elements[3], 'name': elements[3].rstrip(),
} }
except Exception: except Exception:
_LOGGER.error(f"Could not parse: {line.rstrip()}. Are you sure it comes from eggnog annotations.tsv?") _LOGGER.error(f"Could not parse: {line.rstrip()}. Are you sure it comes from eggnog annotations.tsv?")
......
...@@ -5,8 +5,8 @@ from metagenedb.common.utils.parsers import EggNogAnnotationLineParser ...@@ -5,8 +5,8 @@ from metagenedb.common.utils.parsers import EggNogAnnotationLineParser
class TestEggNogAnnotationLineParser(TestCase): class TestEggNogAnnotationLineParser(TestCase):
def test_ko_list(self): def test_get_dict(self):
ko_line = "1\t28H54\tK\ttranslational termination" ko_line = "1\t28H54\tK\ttranslational termination\n"
expected_dict = { expected_dict = {
'function_id': "28H54", 'function_id': "28H54",
'name': "translational termination", 'name': "translational termination",
...@@ -15,7 +15,17 @@ class TestEggNogAnnotationLineParser(TestCase): ...@@ -15,7 +15,17 @@ class TestEggNogAnnotationLineParser(TestCase):
test_dict = EggNogAnnotationLineParser.get_dict(ko_line) test_dict = EggNogAnnotationLineParser.get_dict(ko_line)
self.assertDictEqual(test_dict, expected_dict) self.assertDictEqual(test_dict, expected_dict)
def test_ko_list_wrong_format(self): def test_get_dict_no_name(self):
ko_line = "1\t28H50\tS\t\n"
expected_dict = {
'function_id': "28H50",
'name': "",
'functional_category': "S"
}
test_dict = EggNogAnnotationLineParser.get_dict(ko_line)
self.assertDictEqual(test_dict, expected_dict)
def test_get_dict_wrong_format(self):
ko_line = "This is a wrong line format, with; information and tab" ko_line = "This is a wrong line format, with; information and tab"
with self.assertRaises(Exception) as context: # noqa with self.assertRaises(Exception) as context: # noqa
EggNogAnnotationLineParser.get_dict(ko_line) EggNogAnnotationLineParser.get_dict(ko_line)
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