diff --git a/subworkflows/nf-core/initialise/main.nf b/subworkflows/nf-core/initialise/main.nf index 85b6cd8e79a..0cbd37993b2 100644 --- a/subworkflows/nf-core/initialise/main.nf +++ b/subworkflows/nf-core/initialise/main.nf @@ -2,54 +2,67 @@ // The role of this subworkflow is to check the input parameters and print help messages // Use this to start your nf-core pipeline -include { paramsHelp; paramsSummaryLog; validateParameters } from 'plugin/nf-validation' +include { paramsHelp; paramsSummaryLog; paramsSummaryMap; validateParameters } from 'plugin/nf-validation' workflow INITIALISE { - // Print workflow version and exit on --version - if (params.version) { - String version_string = "" + take: + version // bool + help // bool + validate_params // bool - if (workflow.manifest.version) { - def prefix_v = workflow.manifest.version[0] != 'v' ? 'v' : '' - version_string += "${prefix_v}${workflow.manifest.version}" + main: + + // Print workflow version and exit on --version + if (version) { + String version_string = "" + + if (workflow.manifest.version) { + def prefix_v = workflow.manifest.version[0] != 'v' ? 'v' : '' + version_string += "${prefix_v}${workflow.manifest.version}" + } + + if (workflow.commitId) { + def git_shortsha = workflow.commitId.substring(0, 7) + version_string += "-g${git_shortsha}" + } + log.info "${workflow.manifest.name} ${version_string}" + System.exit(0) + } + + // Print citation for nf-core + def citation = "If you use ${workflow.manifest.name} for your analysis please cite:\n\n" + + "* The nf-core framework\n" + + " https://doi.org/10.1038/s41587-020-0439-x\n\n" + + "* Software dependencies\n" + + " ${workflow.manifest.homePage}/blob/master/CITATIONS.md" + log.info citation + + // Print help message if needed + if (params.help) { + def String command = "nextflow run ${workflow.manifest.name} --input samplesheet.csv -profile docker" + log.info paramsHelp(command) + System.exit(0) } - if (workflow.commitId) { - def git_shortsha = workflow.commitId.substring(0, 7) - version_string += "-g${git_shortsha}" + if ( params.validate_params != false ){ + validateParameters() } - log.info "${workflow.manifest.name} ${version_string}" - System.exit(0) - } - - // Print citation for nf-core - def citation = "If you use ${workflow.manifest.name} for your analysis please cite:\n\n" + - "* The nf-core framework\n" + - " https://doi.org/10.1038/s41587-020-0439-x\n\n" + - "* Software dependencies\n" + - " ${workflow.manifest.homePage}/blob/master/CITATIONS.md" - log.info citation - - // Print help message if needed - if (params.help) { - def String command = "nextflow run ${workflow.manifest.name} --input samplesheet.csv -profile docker" - log.info paramsHelp(command) - System.exit(0) - } - - if ( params.validate_parameters != false ){ - validateParameters() - } - - if (workflow.profile == 'standard' && workflow.configFiles.size() <= 1) { - log.warn "[$workflow.manifest.name] You are attempting to run the pipeline without any custom configuration!\n\n" + - "This will be dependent on your local compute environment but can be achieved via one or more of the following:\n" + - " (1) Using an existing pipeline profile e.g. `-profile docker` or `-profile singularity`\n" + - " (2) Using an existing nf-core/configs for your Institution e.g. `-profile crick` or `-profile uppmax`\n" + - " (3) Using your own local custom config e.g. `-c /path/to/your/custom.config`\n\n" + - "Please refer to the quick start section and usage docs for the pipeline.\n " - } - - log.info paramsSummaryLog(workflow) + + if (workflow.profile == 'standard' && workflow.configFiles.size() <= 1) { + log.warn "[$workflow.manifest.name] You are attempting to run the pipeline without any custom configuration!\n\n" + + "This will be dependent on your local compute environment but can be achieved via one or more of the following:\n" + + " (1) Using an existing pipeline profile e.g. `-profile docker` or `-profile singularity`\n" + + " (2) Using an existing nf-core/configs for your Institution e.g. `-profile crick` or `-profile uppmax`\n" + + " (3) Using your own local custom config e.g. `-c /path/to/your/custom.config`\n\n" + + "Please refer to the quick start section and usage docs for the pipeline.\n " + } + + log.info paramsSummaryLog(workflow) + + summary_params = paramsSummaryMap(workflow) + + emit: + summary_params + } diff --git a/subworkflows/nf-core/initialise/meta.yml b/subworkflows/nf-core/initialise/meta.yml index b1ee015df8b..69596bb53c8 100644 --- a/subworkflows/nf-core/initialise/meta.yml +++ b/subworkflows/nf-core/initialise/meta.yml @@ -8,6 +8,26 @@ keywords: - version modules: input: + - version: + type: boolean + description: | + Structure: val(version) + Boolean to show the pipeline version and exit. + - help: + type: boolean + description: | + Structure: val(help) + Boolean to show the pipeline help message and exit. + - validate_params: + type: boolean + description: | + Structure: val(validate_params) + Whether to validate the parameters prior to starting the pipeline. output: + - summary_params: + type: value + description: | + Structure: val(summary_params) + A map of the parameters used in the pipeline. authors: - "@adamrtalbot" diff --git a/tests/subworkflows/nf-core/initialise/main.nf b/tests/subworkflows/nf-core/initialise/main.nf index e572d179188..3807a6e58bf 100644 --- a/tests/subworkflows/nf-core/initialise/main.nf +++ b/tests/subworkflows/nf-core/initialise/main.nf @@ -5,5 +5,9 @@ nextflow.enable.dsl = 2 include { INITIALISE } from '../../../../subworkflows/nf-core/initialise/main.nf' workflow test_initialise { - INITIALISE ( ) + INITIALISE ( + params.version, + params.help, + params.validate_params + ) } diff --git a/tests/subworkflows/nf-core/initialise/nextflow.config b/tests/subworkflows/nf-core/initialise/nextflow.config index a40b644707f..b10a6b5c956 100644 --- a/tests/subworkflows/nf-core/initialise/nextflow.config +++ b/tests/subworkflows/nf-core/initialise/nextflow.config @@ -1,7 +1,7 @@ params { help = false version = false - validate_parameters = false + validate_params = false test_data = null monochrome_logs = true } diff --git a/tests/subworkflows/nf-core/initialise/nextflow_schema.json b/tests/subworkflows/nf-core/initialise/nextflow_schema.json index c84270bfc45..8b5468afae1 100644 --- a/tests/subworkflows/nf-core/initialise/nextflow_schema.json +++ b/tests/subworkflows/nf-core/initialise/nextflow_schema.json @@ -12,7 +12,7 @@ "description": "Define where the pipeline should find input data and save output data.", "required": ["outdir"], "properties": { - "validate_parameters": { + "validate_params": { "type": "boolean", "description": "Validate parameters?", "default": true,