def meme(self): """promoter detectopn""" print("Running promoter detection") self.check_multi_files( [self._args.tss_files, self._args.fasta_files], ["--tss_files", "--fasta_files"]) if not self._args.tss_source: self.check_multi_files([self._args.annotation_files], ["--annotation_files"]) if (self._args.program == "both") or ( self._args.program == "meme"): self._args.meme_path = self.check_execute_file(self._args.meme_path) elif (self._args.program == "both") or ( self._args.program == "glam2"): self._args.glam2_path = self.check_execute_file(self._args.glam2_path) project_creator.create_subfolders( self._paths.required_folders("promoter")) args_pro = self.args_container.container_promoter( self._args.meme_path, self._args.glam2_path, self._paths.promoter_output_folder, self._args.tex_libs, self._args.tss_files, self._args.fasta_files, self._args.num_motifs, self._args.nt_before_tss, self._args.motif_width, self._args.tss_source, self._args.annotation_files, self._args.end_run, self._args.combine_all, self._args.e_value, self._args.parallels, self._args.program) meme = MEME(args_pro) meme.run_meme(args_pro)
class TestMEME(unittest.TestCase): def setUp(self): self.mock_args = MockClass() self.test_folder = "test_folder" self.out_folder = "test_folder/output" if (not os.path.exists(self.test_folder)): os.mkdir(self.test_folder) os.mkdir(self.out_folder) os.mkdir(os.path.join(self.out_folder, "fasta_output")) self.tss_folder = os.path.join(self.test_folder, "tss_folder") if (not os.path.exists(self.tss_folder)): os.mkdir(self.tss_folder) self.gff_folder = os.path.join(self.test_folder, "gff_folder") if (not os.path.exists(self.gff_folder)): os.mkdir(self.gff_folder) self.fa_folder = os.path.join(self.test_folder, "fa_folder") if (not os.path.exists(self.fa_folder)): os.mkdir(self.fa_folder) args = self.mock_args.mock() args.tsss = self.tss_folder args.fastas = self.fa_folder args.gffs = self.gff_folder args.output_folder = self.out_folder self.meme = MEME(args) def tearDown(self): if os.path.exists(self.test_folder): shutil.rmtree(self.test_folder) def test_move_and_merge_fasta(self): me.del_repeat_fasta = Mock_func().mock_del_repeat_fasta if (not os.path.exists("tmp")): os.mkdir("tmp") gen_file("tmp/primary.fa", "primary") gen_file("tmp/secondary.fa", "secondary") gen_file("tmp/internal.fa", "internal") gen_file("tmp/antisense.fa", "antisense") gen_file("tmp/orphan.fa", "orphan") self.meme._move_and_merge_fasta(self.test_folder, "test") self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_all_types.fa"))) self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_primary.fa"))) self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_secondary.fa"))) self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_internal.fa"))) self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_antisense.fa"))) self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_orphan.fa"))) self.assertTrue(os.path.exists(os.path.join(self.test_folder, "test_allstrain_without_orphan.fa"))) def test_split_fasta_by_strain(self): with open(os.path.join(self.fa_folder, "allstrain.fa"), "w") as fh: fh.write(""">aaa_aaa_aaa ATTATATATA >bbb_bbb_bbb AATTAATTAA""") self.meme._split_fasta_by_strain(self.fa_folder) self.assertTrue(os.path.join(self.fa_folder, "aaa.fa")) self.assertTrue(os.path.join(self.fa_folder, "bbb.fa"))
def meme(self): """promoter detectopn""" print("Running promoter detection...") self.check_folder([self._args.TSS_folder, self._args.fasta_folder]) if not self._args.TSS_source: self.check_folder([self._args.annotation_folder]) project_creator.create_subfolders( self._paths.required_folders("promoter")) args_pro = self.args_container.container_promoter( self._args.MEME_path, self._paths.promoter_output_folder, self._args.tex_libs, self._args.TSS_folder, self._args.fasta_folder, self._args.num_motif, self._args.nt_before_TSS, self._args.motif_width, self._args.TSS_source, self._args.tex_wig_path, self._args.annotation_folder, self._args.combine_all, self._args.e_value) meme = MEME(args_pro) meme.run_meme(args_pro)
def setUp(self): self.mock_args = MockClass() self.test_folder = "test_folder" self.out_folder = "test_folder/output" if (not os.path.exists(self.test_folder)): os.mkdir(self.test_folder) os.mkdir(self.out_folder) os.mkdir(os.path.join(self.out_folder, "fasta_output")) self.tss_folder = os.path.join(self.test_folder, "tss_folder") if (not os.path.exists(self.tss_folder)): os.mkdir(self.tss_folder) self.gff_folder = os.path.join(self.test_folder, "gff_folder") if (not os.path.exists(self.gff_folder)): os.mkdir(self.gff_folder) self.fa_folder = os.path.join(self.test_folder, "fa_folder") if (not os.path.exists(self.fa_folder)): os.mkdir(self.fa_folder) args = self.mock_args.mock() args.tsss = self.tss_folder args.fastas = self.fa_folder args.gffs = self.gff_folder args.output_folder = self.out_folder self.meme = MEME(args)