def write_index_page(self, job_paths): print "***Writing {}".format(self.settings.job_index_path) page = markup.page() css_path = self.copy_css_style(self.settings.job_index_path) css = [css_path] page.init(css = css_path) page = self.create_validation_content(page, job_paths, key = "comp.gd") open(self.settings.job_index_path, 'w').write(str(page) + '\n')
def mutation_rate_table(output, union_table): print "***Writing {}".format(output) page = markup.page() css = """ #wrapper { margin:0px auto; width:800px; } body { text-size:16px; } table { border:3px solid #0B5FA5; border-collapse:collapse; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; width:800px; } th { background-color:#25547B; padding:2px 7px 2px 7px; color:#ffffff; } td { border:1px solid black; padding:2px 7px 2px 7px; text-align:center; } #third_column_border { border-right:3px solid #0B5FA5; } #alternate_row_color { background-color:#BCDEFF; color:#000000; } """ page.init(css_string = css) page.div(id = "wrapper") page.table() for test_name in union_table.keys(): mut_types = [type for type in DiffEntry.line_specs if len(type) == 3] #Header #First Row page.tr() page.th(test_name.replace('_', '').capitalize(), style = "font-size:1.3em", rowspan = 2) for mut_type in mut_types: page.th(mut_type, colspan = 3) page.th() page.tr.close() #Second Row page.tr() for mut_type in mut_types: page.th("TP", style = "font-size:.8em") page.th("FN", style = "font-size:.8em") page.th("FP", style = "font-size:.8em") page.th("Files") page.tr.close() #Data Rows is_alt = False for pipeline, path in union_table[test_name].iteritems(): gd = GenomeDiff(path) if is_alt: page.tr(id = "alternate_row_color") else: page.tr() is_alt = False if is_alt else True page.th(pipeline.capitalize()) for mut_type in mut_types: n_tp = len([mut for mut in gd[mut_type] if "compare" in mut and mut["compare"] == "TP"]) n_fn = len([mut for mut in gd[mut_type] if "compare" in mut and mut["compare"] == "FN"]) n_fp = len([mut for mut in gd[mut_type] if "compare" in mut and mut["compare"] == "FP"]) total = n_tp + n_fn + n_fp if total: page.td(n_tp) page.td(n_fn) page.td(n_fp, id = "third_column_border") else: page.td('-') page.td('-') page.td('-', id = "third_column_border") href = os.path.relpath(path, os.path.split(output)[0]) page.td(e.a("union.gd", href = href)) page.tr.close() page.br() page.table.close() page.div.close() open(output, 'w').write(str(page) + '\n')