def test_convert(self): path_core_1 = os.path.join(self.dir, 'core_1.xlsx') path_core_2 = os.path.join(self.dir, 'core_2-*.csv') path_core_3 = os.path.join(self.dir, 'core_3.xlsx') path_seq_1 = os.path.join(self.dir, 'seq_1.fna') path_seq_2 = os.path.join(self.dir, 'seq_2.fna') path_seq_3 = os.path.join(self.dir, 'seq_3.fna') io.Writer().run(path_core_1, self.kb, seq_path=path_seq_1, data_repo_metadata=False) self.assertTrue(filecmp.cmp(path_seq_1, self.seq_path, shallow=False)) io.convert(path_core_1, path_seq_1, path_core_2, path_seq_2) kb = io.Reader().run(path_core_2, seq_path=self.seq_path)[core.KnowledgeBase][0] self.assertTrue(kb.is_equal(self.kb)) self.assertTrue(filecmp.cmp(path_seq_1, path_seq_2, shallow=False)) io.convert(path_core_2, path_seq_2, path_core_3, path_seq_3) kb = io.Reader().run(path_core_3, seq_path=self.seq_path)[core.KnowledgeBase][0] self.assertTrue(kb.is_equal(self.kb)) self.assertTrue(filecmp.cmp(path_seq_2, path_seq_3, shallow=False))
def _default(self): args = self.app.pargs io.convert(args.source_core, args.source_seq, args.dest_core, args.dest_seq, strict=args.strict)
def _default(self): args = self.app.pargs io.convert(args.source_core, args.source_seq, args.dest_core, args.dest_seq, taxon=args.taxon, protected=(not args.unprotected))
def test_convert_sloppy(self): path_core_1 = os.path.join(self.dir, 'core_1.xlsx') path_core_2 = os.path.join(self.dir, 'core_2-*.csv') path_core_3 = os.path.join(self.dir, 'core_3.xlsx') path_seq_1 = os.path.join(self.dir, 'seq_1.fna') path_seq_2 = os.path.join(self.dir, 'seq_2.fna') path_seq_3 = os.path.join(self.dir, 'seq_3.fna') io.Writer().run(path_core_1, self.kb, seq_path=path_seq_1, data_repo_metadata=False) self.assertTrue(filecmp.cmp(path_seq_1, self.seq_path, shallow=False)) wb = wc_utils.workbook.io.read(path_core_1) row = wb['!!KB'].pop(4) wb['!!KB'].insert(5, row) wc_utils.workbook.io.write(path_core_1, wb) with self.assertRaisesRegex(ValueError, "cannot be loaded because"): io.convert(path_core_1, path_seq_1, path_core_2, path_seq_2) env = EnvironmentVarGuard() env.set('CONFIG__DOT__wc_kb__DOT__io__DOT__strict', '0') with env: io.convert(path_core_1, path_seq_1, path_core_2, path_seq_2) kb = io.Reader().run(path_core_2, seq_path=self.seq_path)[core.KnowledgeBase][0] self.assertTrue(kb.is_equal(self.kb)) self.assertTrue(filecmp.cmp(path_seq_1, path_seq_2, shallow=False)) io.convert(path_core_2, path_seq_2, path_core_3, path_seq_3) kb = io.Reader().run(path_core_3, seq_path=self.seq_path)[core.KnowledgeBase][0] self.assertTrue(kb.is_equal(self.kb)) self.assertTrue(filecmp.cmp(path_seq_2, path_seq_3, shallow=False))
def test_convert_sloppy(self): path_core_1 = os.path.join(self.dir, 'core_1.xlsx') path_core_2 = os.path.join(self.dir, 'core_2-*.csv') path_core_3 = os.path.join(self.dir, 'core_3.xlsx') path_seq_1 = os.path.join(self.dir, 'seq_1.fna') path_seq_2 = os.path.join(self.dir, 'seq_2.fna') path_seq_3 = os.path.join(self.dir, 'seq_3.fna') io.Writer().run(self.kb, path_core_1, path_seq_1, set_repo_metadata_from_path=False) self.assertTrue(filecmp.cmp(path_seq_1, self.seq_path, shallow=False)) wb = wc_utils.workbook.io.read(path_core_1) row = wb['Knowledge base'].pop(0) wb['Knowledge base'].insert(1, row) wc_utils.workbook.io.write(path_core_1, wb) with self.assertRaisesRegex(ValueError, "The columns of worksheet 'Knowledge base' must be defined in this order"): io.convert(path_core_1, path_seq_1, path_core_2, path_seq_2) io.convert(path_core_1, path_seq_1, path_core_2, path_seq_2, strict=False) kb = io.Reader().run(path_core_2, self.seq_path) self.assertTrue(kb.is_equal(self.kb)) self.assertTrue(filecmp.cmp(path_seq_1, path_seq_2, shallow=False)) io.convert(path_core_2, path_seq_2, path_core_3, path_seq_3) kb = io.Reader().run(path_core_3, self.seq_path) self.assertTrue(kb.is_equal(self.kb)) self.assertTrue(filecmp.cmp(path_seq_2, path_seq_3, shallow=False))