def test_sorf_detection(self):
     fasta = os.path.join(self.fasta, "fasta")
     gen_file(fasta, ">aaa\nTAGGAGGCCGCTATGCCATTA")
     srna_gff = os.path.join(self.gff, "srna.gff")
     inter_gff = os.path.join(self.gff, "inter.gff")
     tss_file = os.path.join(self.gff, "tss.gff")
     sd.get_coverage = self.mock.mock_get_coverage
     sd.read_libs = self.mock.mock_read_libs
     sd.read_wig = self.mock.mock_read_wig
     sd.get_inter_coverage = self.mock.mock_get_inter_coverage
     gen_file(srna_gff, self.example.srna)
     gen_file(inter_gff, self.example.inter)
     gen_file(tss_file, self.example.tss)
     args = self.mock_args.mock()
     args.start_codon = ["ATG"]
     args.stop_codon = ["TTA"]
     args.cutoff_5utr = "p_0.5"
     args.cutoff_intercds = "n_20"
     args.cutoff_3utr = "n_11"
     args.cutoff_inter = 50
     args.cutoff_anti = 50
     args.libs = ["frag:frag:1:a:+"]
     args.merge_wigs = "wig_folder"
     args.utr_detect = True
     args.background = 10
     args.print_all = True
     sd.sorf_detection(fasta, srna_gff, inter_gff, tss_file, "wig_f_file",
                       "wig_r_file", "test_folder/test", args)
     sd.get_coverage = copy.deepcopy(get_coverage)
     sd.replicate_comparison = self.mock.mock_replicate_comparison
     self.assertTrue(os.path.exists("test_folder/test_all.csv"))
     self.assertTrue(os.path.exists("test_folder/test_all.gff"))
     self.assertTrue(os.path.exists("test_folder/test_best.csv"))
     self.assertTrue(os.path.exists("test_folder/test_best.gff"))
 def test_sorf_detection(self):
     fasta = os.path.join(self.fasta, "fasta")
     gen_file(fasta, ">aaa\nTAGGAGGCCGCTATGCCATTA")
     srna_gff = os.path.join(self.gff, "srna.gff")
     inter_gff = os.path.join(self.gff, "inter.gff")
     tss_file = os.path.join(self.gff, "tss.gff")
     sd.get_coverage = self.mock.mock_get_coverage
     sd.read_libs = self.mock.mock_read_libs
     sd.read_wig = self.mock.mock_read_wig
     sd.get_inter_coverage = self.mock.mock_get_inter_coverage
     gen_file(srna_gff, self.example.srna)
     gen_file(inter_gff, self.example.inter)
     gen_file(tss_file, self.example.tss)
     args = self.mock_args.mock()
     args.start_codon = ["ATG"]
     args.stop_codon = ["TTA"]
     args.cutoff_5utr = "p_0.5"
     args.cutoff_intercds = "n_20"
     args.cutoff_3utr = "n_11"
     args.cutoff_inter = 50
     args.cutoff_anti = 50
     args.libs = ["frag:frag:1:a:+"]
     args.merge_wigs = "wig_folder"
     args.utr_detect = True
     args.background = 10
     args.print_all = True
     sd.sorf_detection(fasta, srna_gff, inter_gff, tss_file, "wig_f_file",
                       "wig_r_file", "test_folder/test", args)
     sd.get_coverage = copy.deepcopy(get_coverage)
     sd.replicate_comparison = self.mock.mock_replicate_comparison
     self.assertTrue(os.path.exists("test_folder/test_all.csv"))
     self.assertTrue(os.path.exists("test_folder/test_all.gff"))
     self.assertTrue(os.path.exists("test_folder/test_best.csv"))
     self.assertTrue(os.path.exists("test_folder/test_best.gff"))
示例#3
0
 def _start_stop_codon(self, prefixs, args_sorf, log):
     '''detect the sORF based on start and stop codon 
     and ribosome binding site'''
     log.write("Running sORF_detection.py for detecting sORFs.\n")
     log.write("The following files are generated:\n")
     for prefix in prefixs:
         print("Searching sORFs of {0}".format(prefix))
         if self.srna_path is not None:
             srna_file = os.path.join(self.srna_path,
                                      "_".join([prefix, "sRNA.gff"]))
         else:
             srna_file = None
         if self.tss_path is not None:
             tss_file = os.path.join(self.tss_path,
                                     "_".join([prefix, "TSS.gff"]))
         else:
             tss_file = None
         sorf_detection(
             os.path.join(self.fasta_path, prefix + ".fa"), srna_file,
             os.path.join(args_sorf.out_folder,
                          "_".join([prefix, "inter.gff"])), tss_file,
             os.path.join(args_sorf.wig_path,
                          "_".join([prefix, "forward.wig"])),
             os.path.join(args_sorf.wig_path,
                          "_".join([prefix, "reverse.wig"])),
             os.path.join(self.gff_output, self.all_cand,
                          "_".join([prefix, "sORF"])), args_sorf)
         if "_".join([prefix, "sORF_all.gff"]) in os.listdir(
                 os.path.join(self.gff_output, self.all_cand)):
             gff_all = os.path.join(self.gff_output, self.all_cand,
                                    "_".join([prefix, "sORF.gff"]))
             gff_best = os.path.join(self.gff_output, self.best,
                                     "_".join([prefix, "sORF.gff"]))
             csv_all = os.path.join(self.table_output, self.all_cand,
                                    "_".join([prefix, "sORF.csv"]))
             csv_best = os.path.join(self.table_output, self.best,
                                     "_".join([prefix, "sORF.csv"]))
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_all.gff"])), gff_all)
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_best.gff"])),
                 gff_best)
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_all.csv"])), csv_all)
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_best.csv"])),
                 csv_best)
             log.write("\t" + gff_all + "\n")
             log.write("\t" + gff_best + "\n")
             log.write("\t" + csv_all + "\n")
             log.write("\t" + csv_best + "\n")
示例#4
0
 def _start_stop_codon(self, prefixs, args_sorf, log):
     '''detect the sORF based on start and stop codon 
     and ribosome binding site'''
     log.write("Running sORF_detection.py for detecting sORFs.\n")
     log.write("The following files are generated:\n")
     for prefix in prefixs:
         print("Searching sORFs of {0}".format(prefix))
         if self.srna_path is not None:
             srna_file = os.path.join(self.srna_path,
                                      "_".join([prefix, "sRNA.gff"]))
         else:
             srna_file = None
         if self.tss_path is not None:
             tss_file = os.path.join(self.tss_path,
                                     "_".join([prefix, "TSS.gff"]))
         else:
             tss_file = None
         sorf_detection(os.path.join(self.fasta_path, prefix + ".fa"),
                        srna_file, os.path.join(args_sorf.out_folder,
                        "_".join([prefix, "inter.gff"])), tss_file,
                        os.path.join(args_sorf.wig_path,
                        "_".join([prefix, "forward.wig"])),
                        os.path.join(args_sorf.wig_path,
                        "_".join([prefix, "reverse.wig"])),
                        os.path.join(self.gff_output, self.all_cand,
                        "_".join([prefix, "sORF"])), args_sorf)
         if "_".join([prefix, "sORF_all.gff"]) in os.listdir(
                      os.path.join(self.gff_output, self.all_cand)):
             gff_all = os.path.join(self.gff_output, self.all_cand,
                                    "_".join([prefix, "sORF.gff"]))
             gff_best = os.path.join(self.gff_output, self.best,
                                     "_".join([prefix, "sORF.gff"]))
             csv_all = os.path.join(self.table_output, self.all_cand,
                                    "_".join([prefix, "sORF.csv"]))
             csv_best =  os.path.join(self.table_output, self.best,
                                      "_".join([prefix, "sORF.csv"]))
             shutil.move(os.path.join(self.gff_output, self.all_cand,
                         "_".join([prefix, "sORF_all.gff"])), gff_all)
             shutil.move(os.path.join(self.gff_output, self.all_cand,
                         "_".join([prefix, "sORF_best.gff"])), gff_best)
             shutil.move(os.path.join(self.gff_output, self.all_cand,
                         "_".join([prefix, "sORF_all.csv"])), csv_all)
             shutil.move(os.path.join(self.gff_output, self.all_cand,
                         "_".join([prefix, "sORF_best.csv"])), csv_best)
             log.write("\t" + gff_all + "\n")
             log.write("\t" + gff_best + "\n")
             log.write("\t" + csv_all + "\n")
             log.write("\t" + csv_best + "\n")
示例#5
0
 def _start_stop_codon(self, prefixs, args_sorf):
     '''detect the sORF based on start and stop codon 
     and ribosome binding site'''
     for prefix in prefixs:
         if self.srna_path is not None:
             srna_file = os.path.join(self.srna_path,
                                      "_".join([prefix, "sRNA.gff"]))
         else:
             srna_file = None
         if self.tss_path is not None:
             tss_file = os.path.join(self.tss_path,
                                     "_".join([prefix, "TSS.gff"]))
         else:
             tss_file = None
         sorf_detection(
             os.path.join(self.fasta_path, prefix + ".fa"), srna_file,
             os.path.join(args_sorf.out_folder,
                          "_".join([prefix, "inter.gff"])), tss_file,
             os.path.join(args_sorf.wig_path,
                          "_".join([prefix, "forward.wig"])),
             os.path.join(args_sorf.wig_path,
                          "_".join([prefix, "reverse.wig"])),
             os.path.join(self.gff_output, self.all_cand,
                          "_".join([prefix, "sORF"])), args_sorf)
         if "_".join([prefix, "sORF_all.gff"]) in os.listdir(
                 os.path.join(self.gff_output, self.all_cand)):
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_all.gff"])),
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF.gff"])))
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_best.gff"])),
                 os.path.join(self.gff_output, self.best,
                              "_".join([prefix, "sORF.gff"])))
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_all.csv"])),
                 os.path.join(self.table_output, self.all_cand,
                              "_".join([prefix, "sORF.csv"])))
             shutil.move(
                 os.path.join(self.gff_output, self.all_cand,
                              "_".join([prefix, "sORF_best.csv"])),
                 os.path.join(self.table_output, self.best,
                              "_".join([prefix, "sORF.csv"])))