コード例 #1
0
ファイル: controller.py プロジェクト: malvikasharan/ANNOgesic
 def terminator(self):
     """Run TransTermHP for detecting terminators."""
     print("Running terminator prediction...")
     if self._args.TransTermHP_path is None:
         print("Please assign the folder where you install TransTermHP.")
     self.check_folder([self._args.fasta_folder,
                        self._args.annotation_folder,
                        self._args.transcript_folder])
     self.check_no_require_folder([self._args.sRNA])
     project_creator.create_subfolders(
         self._paths.required_folders("terminator"))
     args_term = self.args_container.container_terminator(
         self._args.TransTermHP_path, self._args.expterm_path,
         self._args.RNAfold_path,
         self._paths.transterm_folder, self._args.fasta_folder,
         self._args.annotation_folder, self._args.transcript_folder,
         self._args.sRNA, self._args.statistics,
         self._args.tex_wig_folder, self._args.frag_wig_folder,
         self._args.decrease, self._args.highest_coverage,
         self._args.fuzzy_detect_coverage,
         self._args.fuzzy_within_transcript,
         self._args.fuzzy_downstream_transcript,
         self._args.fuzzy_within_gene,
         self._args.fuzzy_downstream_gene, self._paths.transtermhp_folder,
         self._args.tex_notex_libs, self._args.frag_libs,
         self._args.tex_notex, self._args.replicates_tex,
         self._args.replicates_frag, self._args.table_best,
         self._args.min_loop_length, self._args.max_loop_length,
         self._args.min_stem_length,
         self._args.max_stem_length, self._args.min_U_tail_length,
         self._args.miss_rate, self._args.range_U_tail)
     terminator = Terminator(args_term)
     terminator.run_terminator(args_term)
コード例 #2
0
 def setUp(self):
     self.example = Example()
     self.mock_args = MockClass()
     self.mock = Mock_func()
     self.mock_parser = Mock_Multiparser()
     self.test_folder = "test_folder"
     self.out = "test_folder/output"
     self.fastas = "test_folder/fastas"
     self.gffs = "test_folder/gffs"
     self.srnas = "test_folder/srnas"
     self.trans = "test_folder/trans"
     if (not os.path.exists(self.test_folder)):
         os.mkdir(self.test_folder)
         os.mkdir(self.out)
         os.mkdir(self.fastas)
         os.mkdir(self.gffs)
         os.mkdir(self.srnas)
         os.mkdir(self.trans)
         os.mkdir(os.path.join(self.out, "tables"))
         os.mkdir(os.path.join(self.out, "gffs"))
         os.mkdir(os.path.join(self.gffs, "tmp"))
         os.mkdir(os.path.join(self.fastas, "tmp"))
     args = self.mock_args.mock()
     args.gffs = self.gffs
     args.fastas = self.fastas
     args.trans = self.trans
     args.out_folder = self.out
     args.srnas = self.srnas
     self.term = Terminator(args)
コード例 #3
0
ファイル: controller.py プロジェクト: malvikasharan/ANNOgesic
 def terminator(self):
     """Run TransTermHP for detecting terminators."""
     print("Running terminator prediction...")
     if self._args.TransTermHP_path is None:
         print("Please assign the folder where you install TransTermHP.")
     self.check_folder([
         self._args.fasta_folder, self._args.annotation_folder,
         self._args.transcript_folder
     ])
     self.check_no_require_folder([self._args.sRNA])
     project_creator.create_subfolders(
         self._paths.required_folders("terminator"))
     args_term = self.args_container.container_terminator(
         self._args.TransTermHP_path, self._args.expterm_path,
         self._args.RNAfold_path, self._paths.transterm_folder,
         self._args.fasta_folder, self._args.annotation_folder,
         self._args.transcript_folder, self._args.sRNA,
         self._args.statistics, self._args.tex_wig_folder,
         self._args.frag_wig_folder, self._args.decrease,
         self._args.highest_coverage, self._args.fuzzy_detect_coverage,
         self._args.fuzzy_within_transcript,
         self._args.fuzzy_downstream_transcript,
         self._args.fuzzy_within_gene, self._args.fuzzy_downstream_gene,
         self._paths.transtermhp_folder, self._args.tex_notex_libs,
         self._args.frag_libs, self._args.tex_notex,
         self._args.replicates_tex, self._args.replicates_frag,
         self._args.table_best, self._args.min_loop_length,
         self._args.max_loop_length, self._args.min_stem_length,
         self._args.max_stem_length, self._args.min_U_tail_length,
         self._args.miss_rate, self._args.range_U_tail)
     terminator = Terminator(args_term)
     terminator.run_terminator(args_term)
コード例 #4
0
 def setUp(self):
     self.example = Example()
     self.mock_args = MockClass()
     self.mock = Mock_func()
     self.mock_parser = Mock_Multiparser()
     self.test_folder = "test_folder"
     self.out = "test_folder/output"
     self.fastas = "test_folder/fastas"
     self.gffs = "test_folder/gffs"
     self.srnas = "test_folder/srnas"
     self.trans = "test_folder/trans"
     if (not os.path.exists(self.test_folder)):
         os.mkdir(self.test_folder)
         os.mkdir(self.out)
         os.mkdir(self.fastas)
         os.mkdir(self.gffs)
         os.mkdir(self.srnas)
         os.mkdir(self.trans)
         os.mkdir(os.path.join(self.out, "tables"))
         os.mkdir(os.path.join(self.out, "gffs"))
         os.mkdir(os.path.join(self.gffs, "tmp"))
         os.mkdir(os.path.join(self.fastas, "tmp"))
     args = self.mock_args.mock()
     args.gffs = self.gffs
     args.fastas = self.fastas
     args.trans = self.trans
     args.out_folder = self.out
     args.srnas = self.srnas
     self.term = Terminator(args)
コード例 #5
0
ファイル: controller.py プロジェクト: Pranjpb/ANNOgesic
 def terminator(self):
     """Run TransTermHP and Gene converaged for detecting terminators"""
     print("Running terminator prediction")
     if self._args.transtermhp_path is None:
         print("Please assign the folder where you install TransTermHP.")
     self.check_multi_files(
             [self._args.fasta_files, self._args.annotation_files,
              self._args.transcript_files, self._args.srna_files],
             ["--fasta_files", "--annotation_files",
              "--transcript_files", "--srna_files"])
     for prop in ("transtermhp_path", "expterm_path", "rnafold_path"):
         setattr(self._args, prop,
                 self.check_execute_file(getattr(self._args, prop)))
     project_creator.create_subfolders(
         self._paths.required_folders("terminator"))
     args_term = self.args_container.container_terminator(
         self._args.transtermhp_path, self._args.expterm_path,
         self._args.rnafold_path,
         self._paths.transterm_folder, self._args.fasta_files,
         self._args.annotation_files, self._args.transcript_files,
         self._args.srna_files, self._args.statistics,
         self._args.decrease, self._args.highest_coverage,
         self._args.fuzzy_detect_coverage,
         self._args.fuzzy_within_transcript,
         self._args.fuzzy_downstream_transcript,
         self._args.fuzzy_within_gene,
         self._args.fuzzy_downstream_gene, self._paths.transtermhp_folder,
         self._args.tex_notex_libs, self._args.frag_libs,
         self._args.tex_notex, self._args.replicate_tex,
         self._args.replicate_frag, self._args.table_best,
         self._args.min_loop_length, self._args.max_loop_length,
         self._args.min_stem_length, self._args.max_stem_length,
         self._args.min_u_tail_length, self._args.miss_rate,
         self._args.range_u_tail, self._args.keep_multi_term,
         self._args.window_size, self._args.window_shift)
     terminator = Terminator(args_term)
     terminator.run_terminator(args_term)
コード例 #6
0
class TestTerminator(unittest.TestCase):
    def setUp(self):
        self.example = Example()
        self.mock_args = MockClass()
        self.mock = Mock_func()
        self.mock_parser = Mock_Multiparser()
        self.test_folder = "test_folder"
        self.out = "test_folder/output"
        self.fastas = "test_folder/fastas"
        self.gffs = "test_folder/gffs"
        self.srnas = "test_folder/srnas"
        self.trans = "test_folder/trans"
        if (not os.path.exists(self.test_folder)):
            os.mkdir(self.test_folder)
            os.mkdir(self.out)
            os.mkdir(self.fastas)
            os.mkdir(self.gffs)
            os.mkdir(self.srnas)
            os.mkdir(self.trans)
            os.mkdir(os.path.join(self.out, "tables"))
            os.mkdir(os.path.join(self.out, "gffs"))
            os.mkdir(os.path.join(self.gffs, "tmp"))
            os.mkdir(os.path.join(self.fastas, "tmp"))
        args = self.mock_args.mock()
        args.gffs = self.gffs
        args.fastas = self.fastas
        args.trans = self.trans
        args.out_folder = self.out
        args.srnas = self.srnas
        self.term = Terminator(args)

    def tearDown(self):
        if os.path.exists(self.test_folder):
            shutil.rmtree(self.test_folder)
        if os.path.exists("tmp_transterm"):
            shutil.rmtree("tmp_transterm")
        if os.path.exists("tmp_term_table"):
            shutil.rmtree("tmp_term_table")
        if os.path.exists("tmp_merge_gff"):
            shutil.rmtree("tmp_merge_gff")

    def test_convert_gff2rntptt(self):
        os.mkdir(os.path.join(self.srnas, "tmp"))
        gen_file(os.path.join(self.gffs, "aaa.gff"), self.example.gff_file)
        gen_file(os.path.join(self.srnas, "aaa_sRNA.gff"),
                 self.example.srna_file)
        gen_file(os.path.join(self.fastas, "aaa.fa"), self.example.fasta_file)
        file_types, prefixs = self.term._convert_gff2rntptt(
            self.gffs, self.fastas, self.srnas)
        self.assertDictEqual(file_types, {'aaa': 'srna'})
        self.assertListEqual(prefixs, ['aaa'])

    def test_combine_annotation(self):
        test1 = os.path.join(self.test_folder, "test1.ptt")
        test2 = os.path.join(self.test_folder, "test2.ptt")
        gen_file(test1, self.example.ptt)
        gen_file(test2, self.example.ptt)
        files = [test1, test2]
        combine_file = os.path.join(self.test_folder, "combine")
        self.term._combine_annotation(combine_file, files)
        datas = import_data(combine_file)
        result = self.example.ptt.split("\n")[3:]
        self.assertEqual("\n".join(datas), "\n".join(result + result))

    def test_run_TransTermHP(self):
        self.term._TransTermHP = self.mock.mock_TransTermHP
        os.mkdir(os.path.join(self.gffs, "tmp/combine"))
        gen_file(os.path.join(self.gffs, "tmp/combine/aaa.ptt"),
                 self.example.ptt)
        gen_file(os.path.join(self.fastas, "tmp/aaa.fa"),
                 self.example.fasta_file)
        args = self.mock_args.mock()
        args.gffs = self.gffs
        args.fastas = self.fastas
        args.hp_folder = self.out
        self.term._run_TransTermHP(args)
        self.assertTrue(os.path.exists(os.path.join(self.out, "aaa")))

    def test_convert_to_gff(self):
        self.term.multiparser = self.mock_parser
        hp_folder = os.path.join(self.out, "aaa")
        os.mkdir(hp_folder)
        gen_file(os.path.join(hp_folder, "aaa_best_terminator_after_gene.bag"),
                 self.example.bag)
        os.mkdir("tmp_transterm")
        args = self.mock_args.mock()
        args.hp_folder = self.out
        args.gffs = self.gffs
        self.term._convert_to_gff(["aaa"], args)
        datas = import_data(
            "/home/silas/ANNOgesic/tmp_transterm/aaa_transtermhp.gff")
        self.assertEqual("\n".join(datas), self.example.gff_bag)

    def test_merge_sRNA(self):
        os.mkdir(os.path.join(self.srnas, "tmp"))
        self.term.multiparser = self.mock_parser
        gen_file(os.path.join(self.gffs, "aaa.gff"), self.example.gff_file)
        gen_file(os.path.join(self.srnas, "tmp/aaa_sRNA.gff"),
                 self.example.srna_file)
        merge = self.term._merge_sRNA(self.srnas, ["aaa"], self.gffs)
        self.assertEqual(merge.split("/")[-1], "tmp_merge_gff")
        shutil.rmtree("tmp_merge_gff")

    def test_move_file(self):
        term_outfolder = self.gffs
        csv_outfolder = self.out
        gen_file(os.path.join(term_outfolder, "aaa_term.gff"),
                 self.example.term_file)
        if (not os.path.exists("tmp_term_table")):
            os.mkdir("tmp_term_table")
        gen_file("tmp_term_table/aaa_term_raw.csv", "test")
        self.term._move_file(term_outfolder, csv_outfolder)
        shutil.rmtree("tmp_term_table")
        self.assertTrue(
            "test_folder/output/gffs/all_candidates/aaa_term_all.gff")
        self.assertTrue(
            "test_folder/output/tables/all_candidates/aaa_term_all.csv")

    def test_compute_intersection_forward_reverse(self):
        self.term.multiparser = self.mock_parser
        te.intergenic_seq = self.mock.mock_intergenic_seq
        te.poly_t = self.mock.mock_poly_t
        te.detect_coverage = self.mock.mock_detect_coverage
        self.term._run_rnafold = self.mock.mock_run_rnafold
        term_outfolder = os.path.join(self.out, "gffs")
        csv_outfolder = os.path.join(self.out, "tables")
        args = self.mock_args.mock()
        args.trans = self.trans
        args.fastas = self.fastas
        args.tex_notex = "tex_notex"
        args.libs = "libs"
        args.replicates = "rep"
        args.RNAfold_path = "test"
        self.term._compute_intersection_forward_reverse(["aaa"],
                                                        self.test_folder,
                                                        "wig_path",
                                                        "merge_wigs", args)
        self.assertTrue(os.path.join(self.out, "inter_seq_aaa"))
        self.assertTrue(os.path.join(self.out, "inter_sec_aaa"))

    def test_compute_stat(self):
        term_outfolder = os.path.join(self.out, "gffs")
        csv_outfolder = os.path.join(self.out, "tables")
        te.stat_term = self.mock.mock_stat_term
        gen_file(
            os.path.join(term_outfolder, "all_candidates/aaa_term_all.gff"),
            self.example.term_file)
        gen_file(os.path.join(term_outfolder, "best/aaa_term.csv"),
                 self.example.term_file)
        gen_file(os.path.join(term_outfolder, "express/aaa_term.csv"),
                 self.example.term_file)
        gen_file(os.path.join(term_outfolder, "non_express/aaa_term.csv"),
                 self.example.term_file)
        args = self.mock_args.mock()
        args.stat = True
        args.out_folder = self.out
        self.term._compute_stat(args)
        self.assertTrue(
            os.path.exists(os.path.join(csv_outfolder,
                                        "express/aaa_term.csv")))
        self.assertTrue(
            os.path.exists(os.path.join(csv_outfolder, "best/aaa_term.csv")))
        self.assertTrue(
            os.path.exists(
                os.path.join(csv_outfolder, "non_express/aaa_term.csv")))

    def test_run_terminator(self):
        te.stat_term = self.mock.mock_stat_term
        te.intergenic_seq = self.mock.mock_intergenic_seq
        te.poly_t = self.mock.mock_poly_t
        te.detect_coverage = self.mock.mock_detect_coverage
        self.term.multiparser = self.mock_parser
        self.term._run_rnafold = self.mock.mock_run_rnafold
        self.term._TransTermHP = self.mock.mock_TransTermHP
        self.term._compare_term_tran = self.mock.mock_compare_term_tran
        self.term._remove_tmp_file = self.mock.mock_remove_tmp_file
        os.mkdir(os.path.join(self.srnas, "tmp"))
        os.mkdir(os.path.join(self.trans, "tmp"))
        gen_file(os.path.join(self.gffs, "tmp/aaa.gff"), self.example.gff_file)
        gen_file(os.path.join(self.fastas, "tmp/aaa.fa"),
                 self.example.fasta_file)
        gen_file(os.path.join(self.srnas, "tmp/aaa_sRNA.gff"),
                 self.example.srna_file)
        gen_file(os.path.join(self.trans, "tmp/aaa_transcript.gff"),
                 self.example.tran_file)
        tex_wigs = os.path.join(self.test_folder, "tex")
        frag_wigs = os.path.join(self.test_folder, "frag")
        os.mkdir(tex_wigs)
        os.mkdir(frag_wigs)
        gen_file(os.path.join(frag_wigs, "frag.wig"), "text")
        gen_file(os.path.join(tex_wigs, "tex.wig"), "text")
        args = self.mock_args.mock()
        args.out_folder = self.out
        args.fastas = self.fastas
        args.gffs = self.gffs
        args.trans = self.trans
        args.srnas = self.srnas
        args.tex_wigs = tex_wigs
        args.frag_wigs = frag_wigs
        args.hp_folder = self.test_folder
        args.tex_notex = "tex_notex"
        args.wig_path = self.test_folder
        args.merge_wigs = self.test_folder
        args.RNAfold_path = "RNAfold_path"
        args.stat = True
        args.fuzzy_up_ta = 2
        args.fuzzy_up_gene = 2
        args.fuzzy_down_ta = 2
        args.fuzzy_down_gene = 2
        self.term.run_terminator(args)
        self.assertTrue(
            os.path.exists(os.path.join(self.out, "tables/all_candidates")))
        self.assertTrue(
            os.path.exists(os.path.join(self.out, "tables/express")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "tables/best")))
        self.assertTrue(
            os.path.exists(os.path.join(self.out, "gffs/all_candidates")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "gffs/express")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "gffs/best")))
コード例 #7
0
class TestTerminator(unittest.TestCase):

    def setUp(self):
        self.example = Example()
        self.mock_args = MockClass()
        self.mock = Mock_func()
        self.mock_parser = Mock_Multiparser()
        self.test_folder = "test_folder"
        self.out = "test_folder/output"
        self.fastas = "test_folder/fastas"
        self.gffs = "test_folder/gffs"
        self.srnas = "test_folder/srnas"
        self.trans = "test_folder/trans"
        if (not os.path.exists(self.test_folder)):
            os.mkdir(self.test_folder)
            os.mkdir(self.out)
            os.mkdir(self.fastas)
            os.mkdir(self.gffs)
            os.mkdir(self.srnas)
            os.mkdir(self.trans)
            os.mkdir(os.path.join(self.out, "tables"))
            os.mkdir(os.path.join(self.out, "gffs"))
            os.mkdir(os.path.join(self.gffs, "tmp"))
            os.mkdir(os.path.join(self.fastas, "tmp"))
        args = self.mock_args.mock()
        args.gffs = self.gffs
        args.fastas = self.fastas
        args.trans = self.trans
        args.out_folder = self.out
        args.srnas = self.srnas
        self.term = Terminator(args)

    def tearDown(self):
        if os.path.exists(self.test_folder):
            shutil.rmtree(self.test_folder)
        if os.path.exists("tmp_transterm"):
            shutil.rmtree("tmp_transterm")
        if os.path.exists("tmp_term_table"):
            shutil.rmtree("tmp_term_table")
        if os.path.exists("tmp_merge_gff"):
            shutil.rmtree("tmp_merge_gff")

    def test_convert_gff2rntptt(self):
        os.mkdir(os.path.join(self.srnas, "tmp"))
        gen_file(os.path.join(self.gffs, "aaa.gff"), self.example.gff_file)
        gen_file(os.path.join(self.srnas, "aaa_sRNA.gff"), self.example.srna_file)
        gen_file(os.path.join(self.fastas, "aaa.fa"), self.example.fasta_file)
        file_types, prefixs = self.term._convert_gff2rntptt(self.gffs, self.fastas, self.srnas)
        self.assertDictEqual(file_types, {'aaa': 'srna'})
        self.assertListEqual(prefixs, ['aaa'])

    def test_combine_annotation(self):
        test1 = os.path.join(self.test_folder, "test1.ptt")
        test2 = os.path.join(self.test_folder, "test2.ptt")
        gen_file(test1, self.example.ptt)
        gen_file(test2, self.example.ptt)
        files = [test1, test2]
        combine_file = os.path.join(self.test_folder, "combine")
        self.term._combine_annotation(combine_file, files)
        datas = import_data(combine_file)
        result = self.example.ptt.split("\n")[3:]
        self.assertEqual("\n".join(datas), "\n".join(result + result))

    def test_run_TransTermHP(self):
        self.term._TransTermHP = self.mock.mock_TransTermHP
        os.mkdir(os.path.join(self.gffs, "tmp/combine"))
        gen_file(os.path.join(self.gffs, "tmp/combine/aaa.ptt"), self.example.ptt)
        gen_file(os.path.join(self.fastas, "tmp/aaa.fa"), self.example.fasta_file)
        args = self.mock_args.mock()
        args.gffs = self.gffs
        args.fastas = self.fastas
        args.hp_folder = self.out
        self.term._run_TransTermHP(args)
        self.assertTrue(os.path.exists(os.path.join(self.out, "aaa")))

    def test_convert_to_gff(self):
        self.term.multiparser = self.mock_parser
        hp_folder = os.path.join(self.out, "aaa")
        os.mkdir(hp_folder)
        gen_file(os.path.join(hp_folder, "aaa_best_terminator_after_gene.bag"), self.example.bag)
        os.mkdir("tmp_transterm")
        args = self.mock_args.mock()
        args.hp_folder = self.out
        args.gffs = self.gffs
        self.term._convert_to_gff(["aaa"], args)
        datas = import_data("/home/silas/ANNOgesic/tmp_transterm/aaa_transtermhp.gff")
        self.assertEqual("\n".join(datas), self.example.gff_bag)

    def test_merge_sRNA(self):
        os.mkdir(os.path.join(self.srnas, "tmp"))
        self.term.multiparser = self.mock_parser
        gen_file(os.path.join(self.gffs, "aaa.gff"), self.example.gff_file)
        gen_file(os.path.join(self.srnas, "tmp/aaa_sRNA.gff"), self.example.srna_file)
        merge = self.term._merge_sRNA(self.srnas, ["aaa"], self.gffs)
        self.assertEqual(merge.split("/")[-1], "tmp_merge_gff")
        shutil.rmtree("tmp_merge_gff")

    def test_move_file(self):
        term_outfolder = self.gffs
        csv_outfolder = self.out
        gen_file(os.path.join(term_outfolder, "aaa_term.gff"), self.example.term_file)
        if (not os.path.exists("tmp_term_table")):
            os.mkdir("tmp_term_table")
        gen_file("tmp_term_table/aaa_term_raw.csv", "test")
        self.term._move_file(term_outfolder, csv_outfolder)
        shutil.rmtree("tmp_term_table")
        self.assertTrue("test_folder/output/gffs/all_candidates/aaa_term_all.gff")
        self.assertTrue("test_folder/output/tables/all_candidates/aaa_term_all.csv")

    def test_compute_intersection_forward_reverse(self):
        self.term.multiparser = self.mock_parser
        te.intergenic_seq = self.mock.mock_intergenic_seq
        te.poly_t = self.mock.mock_poly_t
        te.detect_coverage = self.mock.mock_detect_coverage
        self.term._run_rnafold = self.mock.mock_run_rnafold
        term_outfolder = os.path.join(self.out, "gffs")
        csv_outfolder = os.path.join(self.out, "tables")
        args = self.mock_args.mock()
        args.trans = self.trans
        args.fastas = self.fastas
        args.tex_notex = "tex_notex"
        args.libs = "libs"
        args.replicates = "rep"
        args.RNAfold_path = "test"
        self.term._compute_intersection_forward_reverse(["aaa"], self.test_folder,
                                    "wig_path", "merge_wigs", args)
        self.assertTrue(os.path.join(self.out, "inter_seq_aaa"))
        self.assertTrue(os.path.join(self.out, "inter_sec_aaa"))

    def test_compute_stat(self):
        term_outfolder = os.path.join(self.out, "gffs")
        csv_outfolder = os.path.join(self.out, "tables")
        te.stat_term = self.mock.mock_stat_term
        gen_file(os.path.join(term_outfolder, "all_candidates/aaa_term_all.gff"), self.example.term_file)
        gen_file(os.path.join(term_outfolder, "best/aaa_term.csv"), self.example.term_file)
        gen_file(os.path.join(term_outfolder, "express/aaa_term.csv"), self.example.term_file)
        gen_file(os.path.join(term_outfolder, "non_express/aaa_term.csv"), self.example.term_file)
        args = self.mock_args.mock()
        args.stat = True
        args.out_folder = self.out
        self.term._compute_stat(args)
        self.assertTrue(os.path.exists(os.path.join(csv_outfolder, "express/aaa_term.csv")))
        self.assertTrue(os.path.exists(os.path.join(csv_outfolder, "best/aaa_term.csv")))
        self.assertTrue(os.path.exists(os.path.join(csv_outfolder, "non_express/aaa_term.csv")))

    def test_run_terminator(self):
        te.stat_term = self.mock.mock_stat_term
        te.intergenic_seq = self.mock.mock_intergenic_seq
        te.poly_t = self.mock.mock_poly_t
        te.detect_coverage = self.mock.mock_detect_coverage
        self.term.multiparser = self.mock_parser
        self.term._run_rnafold = self.mock.mock_run_rnafold
        self.term._TransTermHP = self.mock.mock_TransTermHP
        self.term._compare_term_tran = self.mock.mock_compare_term_tran
        self.term._remove_tmp_file = self.mock.mock_remove_tmp_file
        os.mkdir(os.path.join(self.srnas, "tmp"))
        os.mkdir(os.path.join(self.trans, "tmp"))
        gen_file(os.path.join(self.gffs, "tmp/aaa.gff"), self.example.gff_file)
        gen_file(os.path.join(self.fastas, "tmp/aaa.fa"), self.example.fasta_file)
        gen_file(os.path.join(self.srnas, "tmp/aaa_sRNA.gff"), self.example.srna_file)
        gen_file(os.path.join(self.trans, "tmp/aaa_transcript.gff"), self.example.tran_file)
        tex_wigs = os.path.join(self.test_folder, "tex")
        frag_wigs = os.path.join(self.test_folder, "frag")
        os.mkdir(tex_wigs)
        os.mkdir(frag_wigs)
        gen_file(os.path.join(frag_wigs, "frag.wig"), "text")
        gen_file(os.path.join(tex_wigs, "tex.wig"), "text")
        args = self.mock_args.mock()
        args.out_folder = self.out
        args.fastas = self.fastas
        args.gffs = self.gffs
        args.trans = self.trans
        args.srnas = self.srnas
        args.tex_wigs = tex_wigs
        args.frag_wigs = frag_wigs
        args.hp_folder = self.test_folder
        args.tex_notex = "tex_notex"
        args.wig_path = self.test_folder
        args.merge_wigs = self.test_folder
        args.RNAfold_path = "RNAfold_path"
        args.stat = True
        args.fuzzy_up_ta = 2
        args.fuzzy_up_gene = 2
        args.fuzzy_down_ta = 2
        args.fuzzy_down_gene = 2
        self.term.run_terminator(args)
        self.assertTrue(os.path.exists(os.path.join(self.out, "tables/all_candidates")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "tables/express")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "tables/best")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "gffs/all_candidates")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "gffs/express")))
        self.assertTrue(os.path.exists(os.path.join(self.out, "gffs/best")))