Пример #1
0
 def _stat(self, out_path, stat_path, go, goslim, out_folder, log):
     log.write("Running gene_ontology.py to Retrieve GOslim terms and "
               "do statistics.\n")
     log.write("The following files are generated:\n")
     for folder in os.listdir(out_path):
         strain_stat_path = os.path.join(stat_path, folder)
         self.helper.check_make_folder(strain_stat_path)
         fig_path = os.path.join(strain_stat_path, "figs")
         if "fig" not in os.listdir(strain_stat_path):
             os.mkdir(fig_path)
         stat_file = os.path.join(strain_stat_path,
                                 "_".join(["stat", folder + ".csv"]))
         map2goslim(goslim, go,
                    os.path.join(out_path, folder, self.all_strain),
                    stat_file, out_folder)
         log.write("\t" + stat_file + "\n")
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_three_roots.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_molecular_function.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_cellular_component.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_biological_process.png"])
         for file_ in os.listdir(fig_path):
             log.write("\t" + os.path.join(fig_path, file_) + "\n")
Пример #2
0
 def _stat(self, out_path, stat_path, go, goslim, out_folder, log):
     log.write("Running gene_ontology.py to Retrieve GOslim terms and "
               "do statistics.\n")
     log.write("The following files are generated:\n")
     for folder in os.listdir(out_path):
         strain_stat_path = os.path.join(stat_path, folder)
         self.helper.check_make_folder(strain_stat_path)
         fig_path = os.path.join(strain_stat_path, "figs")
         if "fig" not in os.listdir(strain_stat_path):
             os.mkdir(fig_path)
         stat_file = os.path.join(strain_stat_path,
                                  "_".join(["stat", folder + ".csv"]))
         map2goslim(goslim, go,
                    os.path.join(out_path, folder, self.all_strain),
                    stat_file, out_folder)
         log.write("\t" + stat_file + "\n")
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_three_roots.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_molecular_function.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_cellular_component.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_biological_process.png"])
         for file_ in os.listdir(fig_path):
             log.write("\t" + os.path.join(fig_path, file_) + "\n")
Пример #3
0
 def test_map2goslim(self):
     go.plot = Mock_func().mock_plot
     stat_file = os.path.join(self.test_folder, "stat.txt")
     term_file = os.path.join(self.test_folder, "term.txt")
     slim_file = os.path.join(self.test_folder, "slim.txt")
     go_table = os.path.join(self.test_folder, "go.csv")
     gen_file(term_file, self.example.obo)
     gen_file(slim_file, self.example.slim)
     gen_file(go_table, "aaa\t+\t150\t200\tYP_031579.1\tGO:0000003")
     go.map2goslim(slim_file, term_file, go_table, stat_file, self.test_folder)
     datas = import_data(stat_file)
     self.assertEqual(set(datas), set(self.example.out_stat.split("\n")))
Пример #4
0
 def test_map2goslim(self):
     go.plot = Mock_func().mock_plot
     stat_file = os.path.join(self.test_folder, "stat.txt")
     term_file = os.path.join(self.test_folder, "term.txt")
     slim_file = os.path.join(self.test_folder, "slim.txt")
     go_table = os.path.join(self.test_folder, "go.csv")
     gen_file(term_file, self.example.obo)
     gen_file(slim_file, self.example.slim)
     gen_file(go_table, "aaa\t+\t150\t200\tYP_031579.1\tGO:0000003")
     go.map2goslim(slim_file, term_file, go_table, stat_file,
                   self.test_folder)
     datas = import_data(stat_file)
     self.assertEqual(set(datas), set(self.example.out_stat.split("\n")))
Пример #5
0
 def _stat(self, out_path, stat_path, go, goslim, out_folder):
     for folder in os.listdir(out_path):
         strain_stat_path = os.path.join(stat_path, folder)
         self.helper.check_make_folder(strain_stat_path)
         fig_path = os.path.join(strain_stat_path, "figs")
         if "fig" not in os.listdir(strain_stat_path):
             os.mkdir(fig_path)
         map2goslim(goslim, go,
                    os.path.join(out_path, folder, self.all_strain),
                    os.path.join(strain_stat_path,
                                 "_".join(["stat", folder + ".csv"])),
                    out_folder)
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_three_roots.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_molecular_function.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_cellular_component.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_biological_process.png"])
Пример #6
0
 def _stat(self, out_path, stat_path, go, goslim, out_folder):
     for folder in os.listdir(out_path):
         strain_stat_path = os.path.join(stat_path, folder)
         self.helper.check_make_folder(strain_stat_path)
         fig_path = os.path.join(strain_stat_path, "figs")
         if "fig" not in os.listdir(strain_stat_path):
             os.mkdir(fig_path)
         print("Computing statistics of {0}".format(folder))
         map2goslim(goslim, go,
                    os.path.join(out_path, folder, self.all_strain),
                    os.path.join(strain_stat_path,
                                 "_".join(["stat", folder + ".csv"])),
                    out_folder)
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_three_roots.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_molecular_function.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_cellular_component.png"])
         self.helper.move_all_content(out_folder, fig_path,
                                      ["_biological_process.png"])