def setUp(self): self.mock_args = MockClass() self.mock = Mock_func() self.mock_parser = Mock_Multiparser() self.example = Example() self.test_folder = "test_folder" self.trans = "test_folder/trans" self.out = "test_folder/output" self.gffs = "test_folder/gffs" self.tsss = "test_folder/tsss" self.terms = "test_folder/terms" if (not os.path.exists(self.test_folder)): os.mkdir(self.test_folder) os.mkdir(self.trans) os.mkdir(os.path.join(self.trans, "tmp")) os.mkdir(self.out) os.mkdir(self.gffs) os.mkdir(self.tsss) os.mkdir(os.path.join(self.tsss, "tmp")) os.mkdir(self.terms) args = self.mock_args.mock() args.tsss = self.tsss args.trans = self.trans args.out_folder = self.out self.utr = UTRDetection(args)
def utr_detection(self): """Run UTR detection.""" print("Running UTR detection...") self.check_folder([self._args.annotation_folder, self._args.transcript_assembly_folder, self._args.TSS_folder]) self.check_no_require_folder([self._args.terminator_folder]) project_creator.create_subfolders(self._paths.required_folders("utr")) args_utr = self.args_container.container_utr( self._args.TSS_folder, self._args.annotation_folder, self._args.transcript_assembly_folder, self._args.terminator_folder, self._args.terminator_fuzzy, self._paths.utr_folder, self._args.TSS_source, self._args.base_5UTR, self._args.UTR_length, self._args.base_3UTR) utr = UTRDetection(args_utr) utr.run_utr_detection(args_utr)
def utr_detection(self): """Run UTR detection.""" print("Running UTR detection...") self.check_folder([ self._args.annotation_folder, self._args.transcript_assembly_folder, self._args.TSS_folder ]) self.check_no_require_folder([self._args.terminator_folder]) project_creator.create_subfolders(self._paths.required_folders("utr")) args_utr = self.args_container.container_utr( self._args.TSS_folder, self._args.annotation_folder, self._args.transcript_assembly_folder, self._args.terminator_folder, self._args.terminator_fuzzy, self._paths.utr_folder, self._args.TSS_source, self._args.base_5UTR, self._args.UTR_length, self._args.base_3UTR) utr = UTRDetection(args_utr) utr.run_utr_detection(args_utr)
def utr_detection(self): """Run UTR detection.""" print("Running UTR detection") self.check_multi_files( [self._args.annotation_files, self._args.terminator_files, self._args.transcript_files, self._args.tss_files], ["--annotation_files", "--terminator_files", "--transcript_files", "--tss_files"]) project_creator.create_subfolders(self._paths.required_folders("utr")) args_utr = self.args_container.container_utr( self._args.tss_files, self._args.annotation_files, self._args.transcript_files, self._args.terminator_files, self._args.terminator_tolerance, self._paths.utr_folder, self._args.tss_source, self._args.base_5utr, self._args.utr_length, self._args.base_3utr, self._args.tolerance_3utr, self._args.tolerance_5utr) utr = UTRDetection(args_utr) utr.run_utr_detection(args_utr)
class TestsTSSpredator(unittest.TestCase): def setUp(self): self.mock_args = MockClass() self.mock = Mock_func() self.mock_parser = Mock_Multiparser() self.example = Example() self.test_folder = "test_folder" self.trans = "test_folder/trans" self.out = "test_folder/output" self.gffs = "test_folder/gffs" self.tsss = "test_folder/tsss" self.terms = "test_folder/terms" if (not os.path.exists(self.test_folder)): os.mkdir(self.test_folder) os.mkdir(self.trans) os.mkdir(os.path.join(self.trans, "tmp")) os.mkdir(self.out) os.mkdir(self.gffs) os.mkdir(self.tsss) os.mkdir(os.path.join(self.tsss, "tmp")) os.mkdir(self.terms) args = self.mock_args.mock() args.tsss = self.tsss args.trans = self.trans args.out_folder = self.out self.utr = UTRDetection(args) def tearDown(self): if os.path.exists(self.test_folder): shutil.rmtree(self.test_folder) def test_compute_utr(self): ut.detect_5utr = self.mock.mock_detect_5utr ut.detect_3utr = self.mock.mock_detect_3utr term_path = os.path.join(self.terms, "tmp") os.mkdir(term_path) utr5_path = os.path.join(self.out, "5UTR") utr3_path = os.path.join(self.out, "3UTR") os.mkdir(utr5_path) os.mkdir(utr3_path) utr5_stat_path = os.path.join(utr5_path, "statistics") utr3_stat_path = os.path.join(utr3_path, "statistics") os.mkdir(utr5_stat_path) os.mkdir(utr3_stat_path) gen_file(os.path.join(self.gffs, "test.gff"), self.example.gff_file) gen_file(os.path.join(self.trans, "test_transcript.gff"), self.example.tran_file) gen_file(os.path.join(self.tsss, "test_TSS.gff"), self.example.tss_file) gen_file(os.path.join(term_path, "test_term.gff"), self.example.term_file) args = self.mock_args.mock() args.gffs = self.gffs args.tsss = self.tsss args.trans = self.trans args.terms = self.terms self.utr._compute_utr(args) self.assertTrue(os.path.exists(os.path.join(utr5_stat_path, "test_5utr_length.png"))) self.assertTrue(os.path.exists(os.path.join(utr3_stat_path, "test_3utr_length.png"))) def test_run_utr_detection(self): self.utr._check_gff = self.mock.mock_check_gff ut.detect_5utr = self.mock.mock_detect_5utr ut.detect_3utr = self.mock.mock_detect_3utr utr5_path = os.path.join(self.out, "5UTR") utr3_path = os.path.join(self.out, "3UTR") os.mkdir(utr5_path) os.mkdir(utr3_path) utr5_stat_path = os.path.join(utr5_path, "statistics") utr3_stat_path = os.path.join(utr3_path, "statistics") os.mkdir(utr5_stat_path) os.mkdir(utr3_stat_path) gen_file(os.path.join(self.gffs, "test.gff"), self.example.gff_file) gen_file(os.path.join(self.trans, "test_transcript.gff"), self.example.tran_file) gen_file(os.path.join(self.tsss, "test_TSS.gff"), self.example.tss_file) gen_file(os.path.join(self.terms, "test_term.gff"), self.example.term_file) args = self.mock_args.mock() args.tsss = self.tsss args.gffs = self.gffs args.trans = self.trans args.terms = self.terms args.out_folder = self.out self.utr.run_utr_detection(args) self.assertTrue(os.path.exists(os.path.join(utr5_stat_path, "test_5utr_length.png"))) self.assertTrue(os.path.exists(os.path.join(utr3_stat_path, "test_3utr_length.png")))