Esempio n. 1
0
 def _run_normal(self, prefix, gff, tran, fuzzy_tss, args_srna):
     '''detection of intergenic and antisense sRNA'''
     tex_datas = None
     frag_datas = None
     if "tmp_cutoff_inter" in os.listdir(args_srna.out_folder):
         os.remove(os.path.join(args_srna.out_folder, "tmp_cutoff_inter"))
     files = {
         "frag_gff": None,
         "frag_csv": None,
         "tex_gff": None,
         "tex_csv": None,
         "merge_gff": None,
         "merge_csv": None
     }
     if self.tss_path is not None:
         tss = self.helper.get_correct_file(self.tss_path, "_TSS.gff",
                                            prefix, None, None)
     else:
         tss = None
     if self.pro_path is not None:
         pro = self.helper.get_correct_file(self.pro_path,
                                            "_processing.gff", prefix, None,
                                            None)
     else:
         pro = None
     if args_srna.frag_wigs is not None:
         files["frag_gff"] = os.path.join(args_srna.out_folder,
                                          "_".join(["tmp_frag", prefix]))
         files["frag_csv"] = os.path.join(
             args_srna.out_folder, "_".join(["tmp_frag_table", prefix]))
         args_srna = self.args_container.container_intersrna(
             "frag", files, args_srna, prefix,
             os.path.join(args_srna.gffs, gff), tran, tss, pro, fuzzy_tss)
         frag_datas = self._read_lib_wig(args_srna)
         intergenic_srna(args_srna, frag_datas[0], frag_datas[1],
                         frag_datas[2], frag_datas[3])
     if args_srna.tex_wigs is not None:
         files["tex_gff"] = os.path.join(args_srna.out_folder,
                                         "_".join(["tmp_tex", prefix]))
         files["tex_csv"] = os.path.join(
             args_srna.out_folder, "_".join(["tmp_tex_table", prefix]))
         args_srna = self.args_container.container_intersrna(
             "tex", files, args_srna, prefix,
             os.path.join(args_srna.gffs, gff), tran, tss, pro, fuzzy_tss)
         tex_datas = self._read_lib_wig(args_srna)
         intergenic_srna(args_srna, tex_datas[0], tex_datas[1],
                         tex_datas[2], tex_datas[3])
     files["merge_csv"] = "_".join([self.prefixs["normal_table"], prefix])
     files["merge_gff"] = "_".join([self.prefixs["normal"], prefix])
     self._merge_frag_tex_file(files, args_srna)
     if ("TSS_class" in os.listdir(
             args_srna.out_folder)) and (not args_srna.tss_source):
         tss = os.path.join(args_srna.out_folder, "TSS_class",
                            prefix + "_TSS.gff")
     return tss, frag_datas, tex_datas
Esempio n. 2
0
    def _run_normal(self, prefix, gff, tran, fuzzy_tss, args_srna):
        if "tmp_cutoff_inter" in os.listdir(args_srna.out_folder):
            os.remove(os.path.join(args_srna.out_folder, "tmp_cutoff_inter"))
        files = {"frag_gff": None, "frag_csv": None,
                 "tex_gff": None, "tex_csv": None,
                 "merge_gff": None, "merge_csv": None}
        if ("tss" in args_srna.import_info):
            tss = self.helper.get_correct_file(self.tss_path, "_TSS.gff",
                                               prefix, None, None)
        else:
            tss = None
        if self.pro_path is not None:
            pro = self.helper.get_correct_file(
                    self.pro_path, "_processing.gff", prefix, None, None)
        else:
            pro = None
        if args_srna.frag_wigs is not None:
            files["frag_gff"] = os.path.join(
                    args_srna.out_folder, "_".join(["tmp_frag", prefix]))
            files["frag_csv"] = os.path.join(
                    args_srna.out_folder, "_".join(["tmp_frag_table", prefix]))

            args_srna = self.args_container.container_intersrna(
                             "frag", files, args_srna, prefix,
                             os.path.join(args_srna.gffs, gff), tran, tss,
                             pro, fuzzy_tss)
            intergenic_srna(args_srna)
        if args_srna.tex_wigs is not None:
            files["tex_gff"] = os.path.join(
                    args_srna.out_folder, "_".join(["tmp_tex", prefix]))
            files["tex_csv"] = os.path.join(
                    args_srna.out_folder, "_".join(["tmp_tex_table", prefix]))
            args_srna = self.args_container.container_intersrna(
                           "tex", files, args_srna, prefix,
                           os.path.join(args_srna.gffs, gff), tran, tss,
                           pro, fuzzy_tss)
            intergenic_srna(args_srna)
        files["merge_csv"] = "_".join([self.prefixs["normal_table"], prefix])
        files["merge_gff"] = "_".join([self.prefixs["normal"], prefix])
        self._merge_frag_tex_file(files, args_srna)
        if "TSS_class" in os.listdir(args_srna.out_folder):
            tss = os.path.join(args_srna.out_folder,
                               "TSS_class", prefix + "_TSS.gff")
        return tss
 def test_intergenic_srna(self):
     si.read_libs = self.mock.mock_read_libs
     si.read_wig = self.mock.mock_read_wig
     gff_file = os.path.join(self.test_folder, "aaa.gff")
     tss_file = os.path.join(self.test_folder, "aaa_TSS.gff")
     tran_file = os.path.join(self.test_folder, "aaa_tran.gff")
     pro_file = os.path.join(self.test_folder, "aaa_processing.gff")
     wig_f_file = os.path.join(self.wig_folder, "wig_f.wig")
     wig_r_file = os.path.join(self.wig_folder, "wig_r.wig")
     gen_file(gff_file, self.example.gff_file)
     gen_file(tss_file, self.example.gff_file)
     gen_file(tran_file, self.example.gff_file)
     gen_file(pro_file, self.example.gff_file)
     output_file = os.path.join(self.test_folder, "output")
     output_table = os.path.join(self.test_folder, "table")
     coverage = [0, 0, 0, 50, 10]
     si.replicate_comparison = self.mock.mock_replicate_comparison
     si.coverage_comparison = self.mock.mock_coverage_comparison
     args = self.mock_args.mock()
     args.gff_file = gff_file
     args.tran_file = tran_file
     args.pro_file = pro_file
     args.tss_file = tss_file
     args.table_best = True
     args.cutoffs = coverage
     args.out_folder = self.test_folder
     args.file_type = "frag"
     args.cut_notex = coverage
     args.input_libs = "input_libs"
     args.wig_folder = self.wig_folder
     args.wig_f_file = wig_f_file
     args.wig_r_file = wig_r_file
     args.tss_source = True
     args.output_file = output_file
     args.output_table = output_table
     args.in_cds = False
     args.wigs_f = None
     args.wigs_r = None
     args.ex_srna = False
     si.intergenic_srna(args, args.input_libs, None,
                        args.wigs_f, args.wigs_r, tss_file)
     self.assertTrue(os.path.exists(output_file))
     self.assertTrue(os.path.exists(output_table))
Esempio n. 4
0
 def test_intergenic_srna(self):
     si.read_libs = self.mock.mock_read_libs
     si.read_wig = self.mock.mock_read_wig
     gff_file = os.path.join(self.test_folder, "aaa.gff")
     tss_file = os.path.join(self.test_folder, "aaa_TSS.gff")
     tran_file = os.path.join(self.test_folder, "aaa_tran.gff")
     pro_file = os.path.join(self.test_folder, "aaa_processing.gff")
     wig_f_file = os.path.join(self.wig_folder, "wig_f.wig")
     wig_r_file = os.path.join(self.wig_folder, "wig_r.wig")
     gen_file(gff_file, self.example.gff_file)
     gen_file(tss_file, self.example.gff_file)
     gen_file(tran_file, self.example.gff_file)
     gen_file(pro_file, self.example.gff_file)
     output_file = os.path.join(self.test_folder, "output")
     output_table = os.path.join(self.test_folder, "table")
     coverage = [0, 0, 0, 50, 10]
     si.replicate_comparison = self.mock.mock_replicate_comparison
     si.coverage_comparison = self.mock.mock_coverage_comparison
     args = self.mock_args.mock()
     args.gff_file = gff_file
     args.tran_file = tran_file
     args.pro_file = pro_file
     args.tss_file = tss_file
     args.table_best = True
     args.cutoffs = coverage
     args.out_folder = self.test_folder
     args.file_type = "frag"
     args.cut_notex = coverage
     args.input_libs = "input_libs"
     args.wig_folder = self.wig_folder
     args.wig_f_file = wig_f_file
     args.wig_r_file = wig_r_file
     args.tss_source = True
     args.output_file = output_file
     args.output_table = output_table
     args.in_cds = False
     args.wigs_f = None
     args.wigs_r = None
     args.ex_srna = False
     si.intergenic_srna(args, args.input_libs, None, args.wigs_f,
                        args.wigs_r)
     self.assertTrue(os.path.exists(output_file))
     self.assertTrue(os.path.exists(output_table))