def _compute_utr(self, args_utr): for gff in os.listdir(args_utr.gffs): if gff.endswith(".gff"): prefix = gff[:-4] tss = self.helper.get_correct_file(self.tss_path, "_TSS.gff", prefix, None, None) tran = self.helper.get_correct_file(self.tran_path, "_transcript.gff", prefix, None, None) if args_utr.terms: term = self.helper.get_correct_file( os.path.join(args_utr.terms, "tmp"), "_term.gff", prefix, None, None) else: term = None print("Computing 5'UTR of {0}".format(prefix)) detect_5utr( tss, os.path.join(args_utr.gffs, gff), tran, os.path.join(self.utr5_path, "gffs", "_".join([prefix, "5UTR.gff"])), args_utr) print("Computing 3'UTR of {0}".format(prefix)) detect_3utr( tran, os.path.join(args_utr.gffs, gff), term, os.path.join(self.utr3_path, "gffs", "_".join([prefix, "3UTR.gff"])), args_utr) self.helper.move_all_content(os.getcwd(), self.utr5_stat_path, ["_5utr_length.png"]) self.helper.move_all_content(os.getcwd(), self.utr3_stat_path, ["_3utr_length.png"])
def _compute_utr(self, args_utr): for gff in os.listdir(args_utr.gffs): if gff.endswith(".gff"): prefix = gff[:-4] tss = self.helper.get_correct_file( self.tss_path, "_TSS.gff", prefix, None, None) tran = self.helper.get_correct_file( self.tran_path, "_transcript.gff", prefix, None, None) if args_utr.terms: term = self.helper.get_correct_file( os.path.join(args_utr.terms, "tmp"), "_term.gff", prefix, None, None) else: term = None print("computing 5'UTR of {0} .....".format(prefix)) detect_5utr(tss, os.path.join(args_utr.gffs, gff), tran, os.path.join(self.utr5_path, "gffs", "_".join([prefix, "5UTR.gff"])), args_utr) print("computing 3'UTR of {0} .....".format(prefix)) detect_3utr(tran, os.path.join(args_utr.gffs, gff), term, os.path.join(self.utr3_path, "gffs", "_".join([prefix, "3UTR.gff"])), args_utr) self.helper.move_all_content( os.getcwd(), self.utr5_stat_path, ["_5utr_length.png"]) self.helper.move_all_content( os.getcwd(), self.utr3_stat_path, ["_3utr_length.png"])
def _compute_utr(self, args_utr, log): log.write("Running detect_utr.py to detect UTRs.\n") for gff in os.listdir(args_utr.gffs): if gff.endswith(".gff"): prefix = gff[:-4] tss = self.helper.get_correct_file( self.tss_path, "_TSS.gff", prefix, None, None) tran = self.helper.get_correct_file( self.tran_path, "_transcript.gff", prefix, None, None) if args_utr.terms: term = self.helper.get_correct_file( os.path.join(args_utr.terms, "tmp"), "_term.gff", prefix, None, None) else: term = None print("Computing 5'UTRs of {0}".format(prefix)) detect_5utr(tss, os.path.join(args_utr.gffs, gff), tran, os.path.join(self.utr5_path, "gffs", "_".join([prefix, "5UTR.gff"])), args_utr) print("Computing 3'UTRs of {0}".format(prefix)) detect_3utr(tran, os.path.join(args_utr.gffs, gff), term, os.path.join(self.utr3_path, "gffs", "_".join([prefix, "3UTR.gff"])), args_utr) self.helper.move_all_content( os.getcwd(), self.utr5_stat_path, ["_5utr_length.png"]) self.helper.move_all_content( os.getcwd(), self.utr3_stat_path, ["_3utr_length.png"]) log.write("The following files are generated:\n") for folder in (os.path.join(self.utr5_path, "gffs"), os.path.join(self.utr3_path, "gffs"), self.utr5_stat_path, self.utr3_stat_path): for file_ in os.listdir(folder): log.write("\t" + os.path.join(folder, file_) + "\n")
def test_detect_3utr(self): args = self.mock_args.mock() args.fuzzy = 5 args.base_3utr = "transcript" args.length = 300 du.read_file = Mock_func().mock_read_file du.plot = Mock_func().mock_plot out_file = os.path.join(self.test_folder, "3utr.gff") du.detect_3utr("test.ta", "test.gff", "test.term", out_file, args) # du.detect_3utr("test.ta", "test.gff", "test.term", 5, out_file) datas = import_data(out_file) self.assertEqual(set(datas), set(self.example.out_3utr_gff.split("\n")))
def test_detect_3utr(self): args = self.mock_args.mock() args.fuzzy = 5 args.base_3utr = "transcript" args.fuzzy_3utr = 10 args.length = 300 du.read_file = Mock_func().mock_read_file du.plot = Mock_func().mock_plot out_file = os.path.join(self.test_folder, "3utr.gff") du.detect_3utr("test.ta", "test.gff", "test.term", out_file, args) datas = import_data(out_file) self.assertEqual(set(datas), set(self.example.out_3utr_gff.split("\n")))
def _compute_utr(self, args_utr, log): log.write("Running detect_utr.py to detect UTRs.\n") for gff in os.listdir(args_utr.gffs): if gff.endswith(".gff"): prefix = gff[:-4] tss = self.helper.get_correct_file(self.tss_path, "_TSS.gff", prefix, None, None) tran = self.helper.get_correct_file(self.tran_path, "_transcript.gff", prefix, None, None) if args_utr.terms: term = self.helper.get_correct_file( os.path.join(args_utr.terms, "tmp"), "_term.gff", prefix, None, None) else: term = None print("Computing 5'UTRs of {0}".format(prefix)) detect_5utr( tss, os.path.join(args_utr.gffs, gff), tran, os.path.join(self.utr5_path, "gffs", "_".join([prefix, "5UTR.gff"])), args_utr) print("Computing 3'UTRs of {0}".format(prefix)) detect_3utr( tran, os.path.join(args_utr.gffs, gff), term, os.path.join(self.utr3_path, "gffs", "_".join([prefix, "3UTR.gff"])), args_utr) self.helper.move_all_content(os.getcwd(), self.utr5_stat_path, ["_5utr_length.png"]) self.helper.move_all_content(os.getcwd(), self.utr3_stat_path, ["_3utr_length.png"]) log.write("The following files are generated:\n") for folder in (os.path.join(self.utr5_path, "gffs"), os.path.join(self.utr3_path, "gffs"), self.utr5_stat_path, self.utr3_stat_path): for file_ in os.listdir(folder): log.write("\t" + os.path.join(folder, file_) + "\n")