From 3a9f229f587fd07aebbaefeb4b5e97a9defa2846 Mon Sep 17 00:00:00 2001 From: JoseEspinosa Date: Wed, 20 Sep 2023 12:10:39 +0200 Subject: [PATCH 1/3] Dump pipeline parameters into a json file --- CHANGELOG.md | 1 + .../pipeline-template/lib/NfcoreTemplate.groovy | 16 ++++++++++++++++ nf_core/pipeline-template/workflows/pipeline.nf | 1 + 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ef51b9962..3affa1ce63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - ([#2415](https://github.com/nf-core/tools/pull/2415#issuecomment-1709847086)) Add autoMounts for apptainer. - Remove `igenomes_base` from the schema, so that nf-validation doesn't create a file path and throw errors offline for s3 objects. - Update Gitpod profile resources to reflect base environment settings. +- ([#747](https://github.com/nf-core/tools/issues/747)) Add to the template the code to dump the selected pipeline parameters into a json file. ### Download diff --git a/nf_core/pipeline-template/lib/NfcoreTemplate.groovy b/nf_core/pipeline-template/lib/NfcoreTemplate.groovy index a1a726d69f..c2cc36213d 100755 --- a/nf_core/pipeline-template/lib/NfcoreTemplate.groovy +++ b/nf_core/pipeline-template/lib/NfcoreTemplate.groovy @@ -3,6 +3,7 @@ // import org.yaml.snakeyaml.Yaml +import groovy.json.JsonOutput class NfcoreTemplate { @@ -222,6 +223,21 @@ class NfcoreTemplate { } } + // + // Dump pipeline parameters in a json file + // + public static void dump_parameters(params) { + def output_d = new File("${params.outdir}/pipeline_info/") + if (!output_d.exists()) { + output_d.mkdirs() + } + + def output_pf = new File(output_d, "params.json") + def jsonStr = "" + jsonStr = JsonOutput.toJson(params) + output_pf.text = JsonOutput.prettyPrint(jsonStr) + } + // // Print pipeline summary on completion // diff --git a/nf_core/pipeline-template/workflows/pipeline.nf b/nf_core/pipeline-template/workflows/pipeline.nf index 9dfb0155f1..9374185c4c 100644 --- a/nf_core/pipeline-template/workflows/pipeline.nf +++ b/nf_core/pipeline-template/workflows/pipeline.nf @@ -120,6 +120,7 @@ workflow.onComplete { if (params.email || params.email_on_fail) { NfcoreTemplate.email(workflow, params, summary_params, projectDir, log, multiqc_report) } + NfcoreTemplate.dump_parameters(params) NfcoreTemplate.summary(workflow, params, log) if (params.hook_url) { NfcoreTemplate.IM_notification(workflow, params, summary_params, projectDir, log) From 0a751ffc9794af7af327f92ee8d753d08cd937b3 Mon Sep 17 00:00:00 2001 From: JoseEspinosa Date: Thu, 21 Sep 2023 11:25:25 +0200 Subject: [PATCH 2/3] Apply review sugestions --- nf_core/pipeline-template/lib/NfcoreTemplate.groovy | 8 ++++---- nf_core/pipeline-template/workflows/pipeline.nf | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nf_core/pipeline-template/lib/NfcoreTemplate.groovy b/nf_core/pipeline-template/lib/NfcoreTemplate.groovy index c2cc36213d..ff05f37a5d 100755 --- a/nf_core/pipeline-template/lib/NfcoreTemplate.groovy +++ b/nf_core/pipeline-template/lib/NfcoreTemplate.groovy @@ -226,15 +226,15 @@ class NfcoreTemplate { // // Dump pipeline parameters in a json file // - public static void dump_parameters(params) { + public static void dump_parameters(workflow, params) { def output_d = new File("${params.outdir}/pipeline_info/") if (!output_d.exists()) { output_d.mkdirs() } - def output_pf = new File(output_d, "params.json") - def jsonStr = "" - jsonStr = JsonOutput.toJson(params) + def timestamp = new java.util.Date().format( 'yyyy-MM-dd_HH-mm-ss') + def output_pf = new File(output_d, "params_${timestamp}.json") + def jsonStr = JsonOutput.toJson(params) output_pf.text = JsonOutput.prettyPrint(jsonStr) } diff --git a/nf_core/pipeline-template/workflows/pipeline.nf b/nf_core/pipeline-template/workflows/pipeline.nf index 9374185c4c..558e9a1f9f 100644 --- a/nf_core/pipeline-template/workflows/pipeline.nf +++ b/nf_core/pipeline-template/workflows/pipeline.nf @@ -120,7 +120,7 @@ workflow.onComplete { if (params.email || params.email_on_fail) { NfcoreTemplate.email(workflow, params, summary_params, projectDir, log, multiqc_report) } - NfcoreTemplate.dump_parameters(params) + NfcoreTemplate.dump_parameters(workflow, params) NfcoreTemplate.summary(workflow, params, log) if (params.hook_url) { NfcoreTemplate.IM_notification(workflow, params, summary_params, projectDir, log) From d1d9f6033b3c2b34b61d4173919e902771be3890 Mon Sep 17 00:00:00 2001 From: JoseEspinosa Date: Thu, 21 Sep 2023 11:31:03 +0200 Subject: [PATCH 3/3] Update docs --- nf_core/pipeline-template/docs/output.md | 1 + 1 file changed, 1 insertion(+) diff --git a/nf_core/pipeline-template/docs/output.md b/nf_core/pipeline-template/docs/output.md index 8a8f48622d..53b0e242e5 100644 --- a/nf_core/pipeline-template/docs/output.md +++ b/nf_core/pipeline-template/docs/output.md @@ -64,6 +64,7 @@ Results generated by MultiQC collate pipeline QC from supported tools e.g. FastQ - Reports generated by Nextflow: `execution_report.html`, `execution_timeline.html`, `execution_trace.txt` and `pipeline_dag.dot`/`pipeline_dag.svg`. - Reports generated by the pipeline: `pipeline_report.html`, `pipeline_report.txt` and `software_versions.yml`. The `pipeline_report*` files will only be present if the `--email` / `--email_on_fail` parameter's are used when running the pipeline. - Reformatted samplesheet files used as input to the pipeline: `samplesheet.valid.csv`. + - Parameters used by the pipeline run: `params.json`.