From 321de3084069435731da560c37a2ba6e6ce2d52a Mon Sep 17 00:00:00 2001 From: Usman Rashid Date: Wed, 28 Feb 2024 11:22:15 +1300 Subject: [PATCH] Fixed reporting issues --- bin/assemblyqc.py | 7 ++++- bin/report_modules/parsers/params_parser.py | 29 ++----------------- .../templates/params/contents.html | 2 +- lib/WorkflowAssemblyqc.groovy | 4 +++ modules/local/createreport.nf | 19 +++++++++--- workflows/assemblyqc.nf | 3 +- 6 files changed, 31 insertions(+), 33 deletions(-) diff --git a/bin/assemblyqc.py b/bin/assemblyqc.py index 99eb2d73..fc42eeed 100755 --- a/bin/assemblyqc.py +++ b/bin/assemblyqc.py @@ -27,7 +27,10 @@ from report_modules.parsers.circos_parser import parse_circos_folder if __name__ == "__main__": - params_dict, params_table = parse_params_json() + params_dict, params_table = parse_params_json("params_json.json") + params_summary_dict, params_summary_table = parse_params_json( + "params_summary_json.json" + ) tools_dict, tools_table = parse_tools_yaml() data_from_tools = {} @@ -51,6 +54,8 @@ data_from_tools = { "PARAMS_DICT": params_dict, "PARAMS_TABLE": params_table, + "PARAMS_SUMMARY_DICT": params_summary_dict, + "PARAMS_SUMMARY_TABLE": params_summary_table, "TOOLS_DICT": tools_dict, "TOOLS_TABLE": tools_table, "VERSIONS": { diff --git a/bin/report_modules/parsers/params_parser.py b/bin/report_modules/parsers/params_parser.py index bf07dc5a..7806f18f 100644 --- a/bin/report_modules/parsers/params_parser.py +++ b/bin/report_modules/parsers/params_parser.py @@ -12,32 +12,9 @@ def highlight_json(json_string): return highlight(json_string, lexer, formatter) -def format_params_dict(json_dict): - formatted_dict = {} - for key, value in json_dict.items(): - if key in ["max_cpus", "max_memory", "max_time"]: - continue - - if not isinstance(value, dict): - formatted_dict[key] = value - continue - - if "skip" in value.keys(): - if value["skip"] == 1: - formatted_dict[key] = "Skipped" - continue - - formatted_dict[key] = value - formatted_dict[key].pop("skip", None) - - return formatted_dict - - -def parse_params_json(): - with open("params_json.json", "r") as f: +def parse_params_json(file_name): + with open(file_name, "r") as f: params_dict = json.load(f) - formatted_dict_json = highlight_json( - json.dumps(format_params_dict(params_dict), indent=4) - ) + formatted_dict_json = highlight_json(json.dumps(params_dict, indent=4)) return params_dict, formatted_dict_json diff --git a/bin/report_modules/templates/params/contents.html b/bin/report_modules/templates/params/contents.html index 10115c8d..f89d27dd 100644 --- a/bin/report_modules/templates/params/contents.html +++ b/bin/report_modules/templates/params/contents.html @@ -4,6 +4,6 @@
Pipeline Parameters

Only displaying parameters that differ from the pipeline defaults.

- {{ all_stats_dicts['PARAMS_TABLE'] }} + {{ all_stats_dicts['PARAMS_SUMMARY_TABLE'] }} diff --git a/lib/WorkflowAssemblyqc.groovy b/lib/WorkflowAssemblyqc.groovy index e5b77980..c410665b 100755 --- a/lib/WorkflowAssemblyqc.groovy +++ b/lib/WorkflowAssemblyqc.groovy @@ -49,6 +49,10 @@ class WorkflowAssemblyqc { } public static String jsonifyParams(params) { + return JsonOutput.toJson(params).toString() + } + + public static String jsonifySummaryParams(params) { def summary = [:] for (group in params.keySet()) { diff --git a/modules/local/createreport.nf b/modules/local/createreport.nf index 29ea765c..820f106e 100644 --- a/modules/local/createreport.nf +++ b/modules/local/createreport.nf @@ -2,7 +2,7 @@ process CREATEREPORT { tag "AssemblyQC" label 'process_single' - // container "docker.io/gallvp/python3npkgs:v0.4" + container "docker.io/gallvp/python3npkgs:v0.6" input: path fastavalidator_logs, stageAs: 'fastavalidator_logs/*' @@ -19,19 +19,30 @@ process CREATEREPORT { path circos_outputs, stageAs: 'circos_outputs/*' path versions val params_json + val params_summary_json output: path 'report.html' , emit: html path 'report.json' , emit: json - path "versions.yml" , emit: versions + path 'versions.yml' , emit: versions when: task.ext.when == null || task.ext.when script: """ - echo -n '$params_json' > params_json.json - assemblyqc.py > report.html + echo \\ + -n \\ + '$params_json' \\ + > params_json.json + + echo \\ + -n \\ + '$params_summary_json' \\ + > params_summary_json.json + + assemblyqc.py \\ + > report.html cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/workflows/assemblyqc.nf b/workflows/assemblyqc.nf index 198e106a..17ca3f67 100644 --- a/workflows/assemblyqc.nf +++ b/workflows/assemblyqc.nf @@ -438,7 +438,8 @@ workflow ASSEMBLYQC { ch_hic_html .collect().ifEmpty([]), ch_synteny_plot .collect().ifEmpty([]), CUSTOM_DUMPSOFTWAREVERSIONS .out.yml, - Channel.of ( WorkflowAssemblyqc.jsonifyParams ( summary_params ) ) + Channel.of ( WorkflowAssemblyqc.jsonifyParams ( params ) ), + Channel.of ( WorkflowAssemblyqc.jsonifySummaryParams ( summary_params ) ) ) }