nextflow icon indicating copy to clipboard operation
nextflow copied to clipboard

Passing a quoted string starting with `-` to nextflow CLI has unexpected behaviour

Open cjw85 opened this issue 1 year ago • 1 comments

Bug report

Expected behavior and actual behavior

I would anticipate that passing arguments such as --minimap2_args '-k15' would result in the parameter minimap2_args being set to the string -k15. However, nextflow complains:

Unknown option: -k15 -- Check the available commands and options and syntax with 'help'

Note that the situation is different if the user provides --minimap2_args '-k 15'. The paramater is set to the string -k 15 as expected, so it is not simply that anything starting with '- is taken as an argument for nextflow itself.

Steps to reproduce the problem

nextflow run epi2me-labs/wf-transcriptomes \
        --de_analysis \
        --direct_rna \
        --fastq 'wf-transcriptomes-demo/differential_expression_fastq' \
        --minimap2_index_opts '-k15' \
        --ref_annotation 'wf-transcriptomes-demo/gencode.v22.annotation.chr20.gtf' \
        --ref_genome 'wf-transcriptomes-demo/hg38_chr20.fa' \
        --sample_sheet 'wf-transcriptomes-demo/sample_sheet.csv' \
        -profile standard

Program output

Unknown option: -k15 -- Check the available commands and options and syntax with 'help'

There's no nextflow.log produced.

Environment

  • Nextflow version: version 24.04.4 build 5917
  • Java version: OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (build 17.0.8.1+1, mixed mode)
  • Operating system: macOS
  • Bash version: zsh 5.9 (x86_64-apple-darwin23.0)

Additional context

There's a difference in behaviour compared to when the arguments are provided in a config file as:

params {
        de_analysis = true
        direct_rna = true
        fastq = 'wf-transcriptomes-demo/differential_expression_fastq'
        minimap2_index_opts = '-k15'
        ref_annotation = 'wf-transcriptomes-demo/gencode.v22.annotation.chr20.gtf'
        ref_genome = 'wf-transcriptomes-demo/hg38_chr20.fa'
        sample_sheet = 'wf-transcriptomes-demo/sample_sheet.csv'
}

Our users caught this as our documentation contains a CLI invocation built from the contents of the config file, we did not catch it in testing as our CI pipelines run nextflow -c config .... instead.

cjw85 avatar Oct 07 '24 10:10 cjw85

Looks like the underlying CLI library (JCommander) prefers to parse -k15 as a CLI option instead of a parameter value. I believe this problem is solved by #3600 which adds a new CLI based on picocli, but ideally i would want to refactor the existing CLI to also use picocli, which would solve the problem here.

bentsherman avatar Oct 07 '24 14:10 bentsherman

Hi @cjw85

As reported by you, I have seen this before err out.

nextflow run epi2me-labs/wf-transcriptomes \
        --de_analysis \
        --direct_rna \
        --fastq 'wf-transcriptomes-demo/differential_expression_fastq' \
        --minimap2_index_opts '-k15' \
        --ref_annotation 'wf-transcriptomes-demo/gencode.v22.annotation.chr20.gtf' \
        --ref_genome 'wf-transcriptomes-demo/hg38_chr20.fa' \
        --sample_sheet 'wf-transcriptomes-demo/sample_sheet.csv' \
        -profile standard

However, if you change -k15 to -k 15, it works correctly. So, this below works - would like to know if it works for you

nextflow run epi2me-labs/wf-transcriptomes \
        --de_analysis \
        --direct_rna \
        --fastq 'wf-transcriptomes-demo/differential_expression_fastq' \
        --minimap2_index_opts '-k 15' \
        --ref_annotation 'wf-transcriptomes-demo/gencode.v22.annotation.chr20.gtf' \
        --ref_genome 'wf-transcriptomes-demo/hg38_chr20.fa' \
        --sample_sheet 'wf-transcriptomes-demo/sample_sheet.csv' \
        -profile standard

tamuanand avatar Oct 22 '24 01:10 tamuanand

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 04:04 stale[bot]