|
41 | 41 | ABOUT_MD = "$about_md" |
42 | 42 | CONTAINERS = "$containers_config" |
43 | 43 | PLOT_MISASSEMBLY_PER_REFERENCE = "$plot_misassembly_per_ref" |
| 44 | + SNP_REPORT_REFERENCE = "$snp_report_json" |
44 | 45 |
|
45 | 46 | logger.debug("Running {} with parameters:".format( |
46 | 47 | os.path.basename(__file__))) |
|
69 | 70 | logger.debug("ABOUT_MD: {}".format(ABOUT_MD)) |
70 | 71 | logger.debug("CONTAINERS: {}".format(CONTAINERS)) |
71 | 72 | logger.debug("CONTAINERS: {}".format(PLOT_MISASSEMBLY_PER_REFERENCE)) |
| 73 | + logger.debug("SNP_REPORT_REFERENCE: {}".format(SNP_REPORT_REFERENCE)) |
72 | 74 |
|
73 | 75 |
|
74 | 76 | html_template = """ |
@@ -327,7 +329,7 @@ def process_sample_reads(reads_jsons): |
327 | 329 | def main(main_js, pipeline_stats, assembly_stats_report, contig_size_plots, mapping_stats_report, completness_plot, |
328 | 330 | lmas_logo, reference_file, lx_json, shrimp_json, gap_reference_json, gap_histogram, plot_misassembly, misassembly_report, |
329 | 331 | min_contig_size, nax_json, ngx_json, reads_json, snp_reference_json, versions_json, misassembly_per_ref, about_md, |
330 | | - containers_config, plot_misassembly_per_reference_json): |
| 332 | + containers_config, plot_misassembly_per_reference_json, snp_per_ref): |
331 | 333 |
|
332 | 334 | metadata = { |
333 | 335 | "nfMetadata": { |
@@ -433,6 +435,29 @@ def main(main_js, pipeline_stats, assembly_stats_report, contig_size_plots, mapp |
433 | 435 | except KeyError: |
434 | 436 | item['misassembled_contigs'] = 0 |
435 | 437 | item['misassembly_events'] = 0 |
| 438 | + |
| 439 | + # add snp stats |
| 440 | + with open(snp_per_ref) as snp_fh: |
| 441 | + snp_stats = json.load(snp_fh) |
| 442 | + for sample_id in main_data_tables_js.keys(): |
| 443 | + for reference in main_data_tables_js[sample_id]["ReferenceTables"].keys(): |
| 444 | + for item_row in main_data_tables_js[sample_id]["ReferenceTables"][reference]: |
| 445 | + for item in item_row: |
| 446 | + assembler = item['assembler'] |
| 447 | + try: |
| 448 | + references = list( |
| 449 | + snp_stats[sample_id][assembler][0].keys()) |
| 450 | + if reference in references: |
| 451 | + index = references.index(reference) |
| 452 | + ref_name = references[index] |
| 453 | + try: |
| 454 | + item['snps'] = snp_stats[sample_id][assembler][0][ref_name]["snps"] |
| 455 | + except KeyError: |
| 456 | + item['snps'] = 0 |
| 457 | + else: |
| 458 | + item['snps'] = 0 |
| 459 | + except KeyError: |
| 460 | + item['snps'] = 0 |
436 | 461 |
|
437 | 462 | for sample_id in main_data_tables_js.keys(): |
438 | 463 | main_data_plots_js[sample_id] = {} |
@@ -628,5 +653,5 @@ def main(main_js, pipeline_stats, assembly_stats_report, contig_size_plots, mapp |
628 | 653 | main(MAIN_JS, PIPELINE_STATS, ASSEMBLY_STATS_REPORT, CONTIG_SIZE_DISTRIBUTION, MAPPING_STATS_REPORT, |
629 | 654 | COMPLETNESS_JSON, LMAS_LOGO, REFERENCE_FILE, LX_JSON, SHRIMP_JSON, GAP_REFERENCE_JSON, GAP_HISTOGRAM, |
630 | 655 | MISASSEMBLY_PLOT, MISASSEMBLY_REPORT, MIN_CONTIG_SIZE, NAX_JSON, NGX_JSON, READS_NUMBER, SNP_REFERENCE_JSON, |
631 | | - VERSIONS_JSON, MISASSEMBLY_PER_REF, ABOUT_MD, CONTAINERS, PLOT_MISASSEMBLY_PER_REFERENCE) |
| 656 | + VERSIONS_JSON, MISASSEMBLY_PER_REF, ABOUT_MD, CONTAINERS, PLOT_MISASSEMBLY_PER_REFERENCE, SNP_REPORT_REFERENCE) |
632 | 657 |
|
0 commit comments