def create_html(dataset, output_html_dir, org_html, project_name, config): import paplot.subcode.tools as tools import os chart_txt = "" js_txt = "" for i in range(len(dataset["plots"])): chart_txt += html_chart_template.format(chart_id = dataset["plots"][i]) js_txt += html_js_template.format(i = str(i), chart_id = dataset["plots"][i]) if dataset["plots"][i] == "chart_brush": js_txt += html_js_brushed_template.format(i = str(i)) f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/" + org_html) html_template = f_template.read() f_template.close() f_html = open(output_html_dir + "/" + org_html, "w") f_html.write( html_template.format(project = project_name, version = tools.version_text(), date = tools.now_string(), charts = chart_txt, js_add_div = js_txt, style = "../style/%s" % os.path.basename(tools.config_getpath(config, "style", "path", "default.js")), )) f_html.close()
def create_html(dataset, output_html_dir, org_html, project_name, config): import os div_txt = "" call_txt = "" detail_txt = "" for i in range(len(dataset["id_list"])): div_txt += li_template.format(id = str(i), title = dataset["id_list"][i]) call_txt += call_template.format(id = str(i), title = dataset["id_list"][i]) detail_txt += detail_template.format(id = str(i), title = dataset["id_list"][i]) f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/" + org_html) html_template = f_template.read() f_template.close() f_html = open(output_html_dir + "/" + org_html, "w") f_html.write( html_template.format(project = project_name, version = tools.version_text(), date = tools.now_string(), div_list = div_txt, call_list = call_txt, details = detail_txt, style = "../style/%s" % os.path.basename(tools.config_getpath(config, "style", "path", "default.js")), )) f_html.close()
def main(argv): import paplot.subcode.tools as tools import argparse parser = argparse.ArgumentParser(prog = prog) parser.add_argument("--version", action = "version", version = tools.version_text()) parser.add_argument("--config_file", help = "config file", type = str, default = "") args = parser.parse_args(argv) # config [config, conf_file] = tools.load_config(args.config_file) tools.print_conf(config, conf_file, "paplot")
def main(argv): import paplot.subcode.tools as tools import paplot.subcode.merge as merge import paplot.mut as mut import paplot.prep as prep import argparse parser = argparse.ArgumentParser(prog = prog) parser.add_argument("--version", action = "version", version = tools.version_text()) parser.add_argument("input", help = "input files path", type = str) parser.add_argument("output_dir", help = "output file path", type = str) parser.add_argument("project_name", help = "project name", type = str) parser.add_argument("--config_file", help = "config file", type = str, default = "") parser.add_argument("--remarks", help = "optional text", type = str, default = "") args = parser.parse_args(argv) # config if len(args.config_file) > 0: [config, conf_file] = tools.load_config(tools.win_to_unix(args.config_file)) else: [config, conf_file] = tools.load_config("") if len(args.remarks) > 0: tools.config_set(config, "style", "remarks", args.remarks) input_list = tools.get_inputlist(args.input) if len(input_list) == 0: print ("input no file.") return [sec_in, sec_out] = tools.get_section("mutation") id_list = tools.get_IDlist(input_list, tools.config_getstr(config, sec_in, "suffix")) # dirs output_html_dir = prep.create_dirs(tools.win_to_unix(args.output_dir), args.project_name, config) positions = merge.merge_result(input_list, id_list, output_html_dir + "/data_mut.csv", "mutation", config, extract = True) if positions == {}: print ("merge.merge_result: input file is invalid.") return mut.output_html(output_html_dir + "/data_mut.csv", output_html_dir + "/data_mut.js", \ output_html_dir, "graph_mut.html", args.project_name, positions, config) prep.create_index(args.output_dir, args.project_name, config)
def create_index(output_dir, project_name, config): link_qc = """<li><a href="{project}/graph_qc.html" target=_blank>QC graphs</a>......Quality Control of bam.</li> """ link_sv = """<li><a href="{project}/graph_ca.html" target=_blank>CA graphs</a>......Chromosomal Aberration.</li> """ link_mut = """<li><a href="{project}/graph_mut.html" target=_blank>Mutation matrix</a>......Gene-sample mutational profiles.</li> """ link_sv_nodata = """<li>CA graphs......No Data.</li> """ link_mut_nodata = """<li>Mutation matrix......No Data.</li> """ import paplot.subcode.tools as tools import os f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/index.html") html_template = f_template.read() f_template.close() link_text = "" if os.path.exists(output_dir + "/" + project_name + "/graph_qc.html") == True: link_text += link_qc.format(project = project_name) if os.path.exists(output_dir + "/" + project_name + "/graph_ca.html") == True: link_text += link_sv.format(project = project_name) elif os.path.exists(output_dir + "/" + project_name + "/data_ca.csv") == True: link_text += link_sv_nodata if os.path.exists(output_dir + "/" + project_name + "/graph_mut.html") == True: link_text += link_mut.format(project = project_name) elif os.path.exists(output_dir + "/" + project_name + "/data_mut.csv") == True: link_text += link_mut_nodata f_html = open(output_dir + "/index.html", "w") f_html.write( html_template.format(project = project_name, version = tools.version_text(), date = tools.now_string(), remarks = tools.config_getstr(config, "style", "remarks"), link = link_text )) f_html.close()
def create_html(dataset, output_html_dir, org_html, project_name, config): import os import paplot.subcode.tools as tools sub1_text = "" sub2_text = "" set_sub_add_text = "" set_sub_select_text = "" for i in range(len(dataset["subdata"])): sub_text = subplot_template.format(i = i, title = dataset["subdata"][i]["title"]) if dataset["subdata"][i]["pos"] == 1: sub1_text += sub_text set_sub_add_text += js_set_sub_add.format(i = i, type = 1) else: sub2_text += sub_text set_sub_add_text += js_set_sub_add.format(i = i, type = 2) set_sub_select_text += js_set_sub_select.format(i = i) f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/" + org_html) html_template = f_template.read() f_template.close() f_html = open(output_html_dir + "/" + org_html, "w") f_html.write( html_template.format(project = project_name, version = tools.version_text(), date = tools.now_string(), sub1 = sub1_text, sub2 = sub2_text, set_sub_add = set_sub_add_text, set_sub_select = set_sub_select_text, style = "../style/%s" % os.path.basename(tools.config_getpath(config, "style", "path", "default.js")), )) f_html.close()