예제 #1
0
 def test_read(self):
     expected = {
         'GCF_005435136.1':
         ['d__D', 'p__P', 'c__C', 'f__F', 'g__G', 's__S1'],
         '2': ['d__D', 'p__P', 'c__C', 'f__F', 'g__G', 's__S2']
     }
     path_tax = os.path.join(self.dir_tmp, 'tax_file.tsv')
     with open(path_tax, 'w') as f:
         for k, v in expected.items():
             f.write(f'{k}\t{";".join(v)}\n')
     t = Taxonomy()
     result = t.read(path_tax)
     self.assertDictEqual(expected, result)
예제 #2
0
 def test_read_canonical(self):
     to_write = {
         'GCF_005435136.1':
         ['d__D', 'p__P', 'c__C', 'f__F', 'g__G', 's__S1'],
         'RS_GCF_005435135.1':
         ['d__D', 'p__P', 'c__C', 'f__F', 'g__G', 's__S2']
     }
     expected = {
         'G005435136': to_write['GCF_005435136.1'],
         'G005435135': to_write['RS_GCF_005435135.1'],
     }
     path_tax = os.path.join(self.dir_tmp, 'tax_file.tsv')
     with open(path_tax, 'w') as f:
         for k, v in to_write.items():
             f.write(f'{k}\t{";".join(v)}\n')
     t = Taxonomy()
     result = t.read(path_tax, canonical_ids=True)
     self.assertDictEqual(expected, result)