Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template: add function to check -profile is well formatted #2678

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- switch to new image syntax in readme ([#2645](https://github.com/nf-core/tools/pull/2645))
- Add conda channel order to nextflow.config ([#2094](https://github.com/nf-core/tools/pull/2094))
- Fix tyop in pipeline nextflow.config ([#2664](https://github.com/nf-core/tools/pull/2664))
- add function to check `-profile` is well formatted ([#2678](https://github.com/nf-core/tools/pull/2678))

### Download

Expand Down
16 changes: 15 additions & 1 deletion nf_core/pipeline-template/lib/WorkflowMain.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WorkflowMain {
//
// Validate parameters and print summary to screen
//
public static void initialise(workflow, params, log) {
public static void initialise(workflow, params, log, args) {

// Print workflow version and exit on --version
if (params.version) {
Expand All @@ -35,6 +35,8 @@ class WorkflowMain {

// Check that a -profile or Nextflow config has been provided to run the pipeline
NfcoreTemplate.checkConfigProvided(workflow, log)
// Check that the profile doesn't contain spaces and doesn't end with a trailing comma
checkProfile(workflow.profile, args, log)

// Check that conda channels are set-up correctly
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
Expand Down Expand Up @@ -63,4 +65,16 @@ class WorkflowMain {
return null
}
{%- endif %}

//
// Exit pipeline if --profile contains spaces
//
private static void checkProfile(profile, args, log) {
if (profile.endsWith(',')) {
Nextflow.error "Profile cannot end with a trailing comma. Please remove the comma from the end of the profile string.\nHint: A common mistake is to provide multiple values to `-profile` separated by spaces. Please use commas to separate profiles instead,e.g., `-profile docker,test`."
}
if (args[0]) {
log.warn "nf-core pipelines do not accept positional arguments. The positional argument `${args[0]}` has been detected.\n Hint: A common mistake is to provide multiple values to `-profile` separated by spaces. Please use commas to separate profiles instead,e.g., `-profile docker,test`."
}
}
}
2 changes: 1 addition & 1 deletion nf_core/pipeline-template/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if (params.validate_params) {
validateParameters()
}

WorkflowMain.initialise(workflow, params, log)
WorkflowMain.initialise(workflow, params, log, args)

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Loading