예제 #1
0
    def test_main_no_outdir(self):
        outfile = 'merged.integrons'
        out_dir = os.path.join(self.out_dir, 'real_outdir')
        command = 'integron_merge {} {} {}'.format(out_dir, outfile,
                                                   ' '.join(self.res_dirs))
        with self.catch_io(out=True, err=True):
            merge.main(command.split()[1:])
            # out = sys.stdout.getvalue()

        integron_file = os.path.join(out_dir, outfile)
        merge.merge_integrons(integron_file, *self.res_dirs)
        agg_results = pd.read_csv(integron_file, sep="\t", comment="#")

        expe_result_file = self.find_data('acba_lian_pssu_merged.integrons')
        expected_results = pd.read_csv(expe_result_file, sep="\t", comment="#")

        pdt.assert_frame_equal(agg_results, expected_results)

        merge.copy_file(self.out_dir, '.gbk', *self.res_dirs)
        merge.copy_file(self.out_dir, '.pdf', *self.res_dirs)
        for _id in self.ids:
            self.assertTrue(
                os.path.exists(os.path.join(out_dir, '{}.gbk'.format(_id))))
            self.assertTrue(
                os.path.exists(os.path.join(out_dir, '{}_1.pdf'.format(_id))))
예제 #2
0
    def test_merge_integrons(self):
        outfile = os.path.join(self.out_dir, 'merged.integrons')
        merge.merge_integrons(outfile, *self.res_dirs)
        agg_results = pd.read_csv(outfile, sep="\t", comment="#")

        expe_result_file = self.find_data('acba_lian_pssu_merged.integrons')
        expected_results = pd.read_csv(expe_result_file, sep="\t", comment="#")
        pdt.assert_frame_equal(agg_results, expected_results)
예제 #3
0
    def test_merge_integrons(self):
        outfile = os.path.join(self.out_dir, 'merged.integrons')
        merge.merge_integrons(outfile, *self.res_dirs)
        agg_results = pd.read_csv(outfile, sep="\t")

        expe_result_file = self.find_data('acba_lian_pssu_merged.integrons')
        expected_results = pd.read_csv(expe_result_file, sep="\t")
        pdt.assert_frame_equal(agg_results, expected_results)
예제 #4
0
 def test_merge_no_files(self):
     outfile = os.path.join(self.out_dir, 'merged.integrons')
     for rep, res_dir in zip(self.replicons, self.res_dirs):
         os.unlink(os.path.join(res_dir, "{}.integrons".format(rep)))
     exp_msg = 'No integrons file to merge'
     with self.assertRaises(IntegronError) as ctx:
         # 100 is to disable CRITICAL log message
         logger_set_level(100)
         merge.merge_integrons(outfile, *self.res_dirs)
     self.assertEqual(str(ctx.exception), exp_msg)
예제 #5
0
 def test_merge_no_files(self):
     outfile = os.path.join(self.out_dir, 'merged.integrons')
     for rep, res_dir in zip(self.replicons, self.res_dirs):
         os.unlink(os.path.join(res_dir, "{}.integrons".format(rep)))
     exp_msg = 'No integrons file to merge'
     with self.assertRaises(IntegronError) as ctx:
         # 100 is to disable CRITICAL log message
         logger_set_level(100)
         merge.merge_integrons(outfile, *self.res_dirs)
     self.assertEqual(str(ctx.exception), exp_msg)
예제 #6
0
    def test_main(self):
        outfile = 'merged.integrons'
        command = 'integron_merge {} {} {}'.format(self.out_dir, outfile, ' '.join(self.res_dirs))
        with self.catch_io(out=True, err=True):
            merge.main(command.split()[1:])
            # out = sys.stdout.getvalue()

        integron_file = os.path.join(self.out_dir, outfile)
        merge.merge_integrons(integron_file, *self.res_dirs)
        agg_results = pd.read_csv(integron_file, sep="\t")

        expe_result_file = self.find_data('acba_lian_pssu_merged.integrons')
        expected_results = pd.read_csv(expe_result_file, sep="\t")

        pdt.assert_frame_equal(agg_results, expected_results)

        merge.copy_file(self.out_dir, '.gbk', *self.res_dirs)
        merge.copy_file(self.out_dir, '.pdf', *self.res_dirs)
        for _id in self.ids:
            self.assertTrue(os.path.exists(os.path.join(self.out_dir, '{}.gbk'.format(_id))))
            self.assertTrue(os.path.exists(os.path.join(self.out_dir, '{}_1.pdf'.format(_id))))