コード例 #1
0
ファイル: sv.py プロジェクト: Genomon-Project/paplot
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()
コード例 #2
0
ファイル: qc.py プロジェクト: Genomon-Project/paplot
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()
コード例 #3
0
ファイル: prep.py プロジェクト: aokad/paplot
def recreate_index(config, output_dir, remarks = ""):

    import paplot.subcode.tools as tools
    import os

    json_data = _reload_metadata(output_dir)
      
    link_text = _convert_index_item(json_data)
    
    f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/index.html")
    html_template = f_template.read()
    f_template.close()
    
    if remarks == "":
        remarks = tools.config_getstr(config, "style", "remarks")
        
    f_html = open(output_dir + "/index.html", "w")
    f_html.write(
        html_template.format(
            version = version_text(),
            date = tools.now_string(),
            remarks = remarks,
            link = link_text
        )
    )
    f_html.close()
コード例 #4
0
ファイル: qc.py プロジェクト: kinkalow/paplot
def create_html(dataset, output_di, config):

    import paplot.subcode.tools as tools
    import paplot.prep as prep
    import os

    chart_txt = ""
    js_txt = ""

    for i in range(len(dataset["plots"])):
        js_txt += html_js_template.format(i=str(i), chart_id=dataset["plots"][i])
        if dataset["plots"][i] == "chart_brush":
            chart_txt += '<p class="muted pull-left" style="margin-right: 15px;">Select a range to zoom in</p>\n'
            js_txt += html_js_brushed_template.format(i=str(i))
        chart_txt += html_chart_template.format(chart_id=dataset["plots"][i])

    f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/graph_qc.html")
    html_template = f_template.read()
    f_template.close()

    f_html = open(output_di["dir"] + "/" + output_di["html"], "w")
    f_html.write(
        html_template.format(project=output_di["project"],
                             title=output_di["title"],
                             data_js=output_di["js"],
                             version=prep.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()
コード例 #5
0
ファイル: prep.py プロジェクト: aokad/paplot
def create_index(config, output_dir, output_html, project_name, name, overview = "", sub_text = "", composite = False, remarks = ""):

    import paplot.subcode.tools as tools
    import os
    
    html_exists = os.path.exists(output_dir + "/" + project_name + "/" + output_html)
    if output_html == "":
        html_exists = False
        
    json_data = _load_metadata(output_dir, output_html, project_name, name, overview, sub_text, composite, html_exists)
    
    link_text = _convert_index_item(json_data)
    
    f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/index.html")
    html_template = f_template.read()
    f_template.close()
    
    if remarks == "":
        remarks = tools.config_getstr(config, "style", "remarks")
        
    f_html = open(output_dir + "/index.html", "w")
    f_html.write(
        html_template.format(
            version = version_text(),
            date = tools.now_string(),
            remarks = remarks,
            link = link_text
        )
    )
    f_html.close()
コード例 #6
0
def create_html(dataset, params, config):
    import os
    import paplot.subcode.tools as tools
    import paplot.prep as prep

    html_div_template = "<div style='float: left;' id='div_pm{id}'></div>\n"
    html_add_template = "msig_draw.add_div('div_pm{id}');\n"

    div_text = ""
    add_text = ""
    for i in range(dataset["sig_num"]):
        div_text += html_div_template.format(id=i)
        add_text += html_add_template.format(id=i)

    integral_text = ""
    if dataset["intergral"] is True:
        integral_text = html_integral_template

    f_template = open(
        os.path.dirname(os.path.abspath(__file__)) +
        "/templates/graph_pmsignature.html")
    html_template = f_template.read()
    f_template.close()

    sig_num_sift = 0
    if tools.config_getboolean(config, "result_format_pmsignature",
                               "background"):
        sig_num_sift = 1

    f_html = open(params["dir"] + "/" + dataset["html"], "w")
    f_html.write(
        html_template.format(
            project=params["project"],
            title="%s(#sig %d)" %
            (params["title"], dataset["sig_num"] + sig_num_sift),
            data_js=dataset["js"],
            version=prep.version_text(),
            date=tools.now_string(),
            divs=div_text,
            add_divs=add_text,
            integral=integral_text,
            style="../style/%s" % os.path.basename(
                tools.config_getpath(config, "style", "path", "default.js")),
        ))
    f_html.close()
コード例 #7
0
def create_html(dataset, output_di, config):
    import os
    import paplot.subcode.tools as tools
    import paplot.prep as prep

    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/graph_mutation.html")
    html_template = f_template.read()
    f_template.close()

    f_html = open(output_di["dir"] + "/" + output_di["html"], "w")
    f_html.write(
        html_template.format(
            project=output_di["project"],
            title=output_di["title"],
            data_js=output_di["js"],
            version=prep.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()
コード例 #8
0
ファイル: prep.py プロジェクト: Genomon-Project/paplot
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()
コード例 #9
0
def create_html(dataset, output_di, config):
    import os
    import paplot.prep as prep

    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])
        detail_txt += detail_template.format(id=str(i),
                                             title=dataset["id_list"][i])
        call_txt += call_template.format(id=str(i),
                                         title=dataset["id_list"][i])


#        if i >= 50:
#            if i == 50:
#                call_txt += call_later_header
#            call_txt += call_later_template.format(id = str(i), title = dataset["id_list"][i])
#        else:
#            call_txt += call_template.format(id = str(i), title = dataset["id_list"][i])

    f_template = open(
        os.path.dirname(os.path.abspath(__file__)) +
        "/templates/graph_ca.html")
    html_template = f_template.read()
    f_template.close()

    f_html = open(output_di["dir"] + "/" + output_di["html"], "w")
    f_html.write(
        html_template.format(
            project=output_di["project"],
            title=output_di["title"],
            data_js=output_di["js"],
            version=prep.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()
コード例 #10
0
ファイル: mut.py プロジェクト: Genomon-Project/paplot
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()
コード例 #11
0
ファイル: ca.py プロジェクト: kinkalow/paplot
def create_html(dataset, output_di, config):
    """
    Create HTML file for CA

    Parameters
    ----------
    dataset: dict: {"id_list"   : [id column values],
                    "group_list": [group names],
                    "color"     : [group colors]}
    output_di: dict: {"dir"    : project directory full path,
                      "data"   : filenames for formatted data
                      "js"     : JavaScript file name
                      "html"   : HTML file name
                      "project": Project name given by user on command line
                      "title"  : Report title. The default is "CA graphs"}
    config: configparser.RawConfigParser

    Return
    ------
    None
    """
    import os
    import paplot.prep as prep
    import paplot.subcode.tools as tools

    # Create strings of thumbnails to embed in HTML
    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])         # Rough thumbnail
        detail_txt += detail_template.format(id=str(i), title=dataset["id_list"][i])  # Detailed thumbnail
        call_txt += call_template.format(id=str(i), title=dataset["id_list"][i])      # Drawing rough thumbnail
#        if i >= 50:
#            if i == 50:
#                call_txt += call_later_header
#            call_txt += call_later_template.format(id = str(i), title = dataset["id_list"][i])
#        else:
#            call_txt += call_template.format(id = str(i), title = dataset["id_list"][i])

    # Overlay
    overlay_txt = overlay_template.format(id=str(len(dataset["id_list"])))

    # Get HTML template
    f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/graph_ca.html")  # ./templates/graph_ca.html
    html_template = f_template.read()
    f_template.close()

    # Create HTML file
    f_html = open(output_di["dir"] + "/" + output_di["html"], "w")  # Create a file under the project directory
    f_html.write(
        html_template.format(
            project=output_di["project"],  # Project name
            title=output_di["title"],      # Report title
            data_js=output_di["js"],       # JavaScript file
            version=prep.version_text(),   # Paplot version
            date=tools.now_string(),       # Cuurent time
            div_list=div_txt,              # Rough thumbnail
            details=detail_txt,            # Detailed thumbnail
            overlay=overlay_txt,           # Overlay thumbnail
            call_list=call_txt,            # Drawing rough thumbnail
            style="../style/%s" % os.path.basename(tools.config_getpath(config, "style", "path", "default.js")),  # ./style/default.js
        ))
    f_html.close()
コード例 #12
0
ファイル: prep.py プロジェクト: kinkalow/paplot
def create_index(config,
                 output_dir,
                 output_html,
                 project_name,
                 name,
                 overview="",
                 sub_text="",
                 composite=False,
                 remarks=""):
    """
    Create homepage

    Parameters
    ----------
    config      : configparser.RawConfigParser
    output_dir  : string: Output directory path
    output_html : string: HTML file name
    project_name: string: Project name given by user on command line
    name        : string: Report title
    overview    : string: Report summary
    sub_text    : string: Additional string to display if composite=True and a report does not exist
    composite   : bool  : Whether or not to have multiple reports
    remarks     : string: Additional information about report

    Return
    ----------
    None
    """

    import paplot.subcode.tools as tools
    import os

    # Confirm existence of homepage
    html_exists = os.path.exists(output_dir + "/" + project_name + "/" +
                                 output_html)
    if output_html == "":
        html_exists = False

    # Create json data
    json_data = _load_metadata(output_dir, output_html, project_name, name,
                               overview, sub_text, composite, html_exists)

    # Create html for link
    link_text = _convert_index_item(json_data)

    # Load the template html for the homepage
    f_template = open(
        os.path.dirname(os.path.abspath(__file__)) +
        "/templates/index.html")  # ./templates/index.html
    html_template = f_template.read()
    f_template.close()

    # Extract remarks from a configuration
    if remarks == "":
        remarks = tools.config_getstr(config, "style", "remarks")

    # Create html file for a homepage
    f_html = open(output_dir + "/index.html", "w")
    f_html.write(
        html_template.format(
            version=version_text(),  # Version
            date=tools.now_string(),  # Current time
            remarks=remarks,  # Some string
            link=link_text)  # HTML for link
    )
    f_html.close()