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

Multiple optional inputs #48

Open
shihabdider opened this issue Nov 20, 2023 · 1 comment
Open

Multiple optional inputs #48

shihabdider opened this issue Nov 20, 2023 · 1 comment

Comments

@shihabdider
Copy link

shihabdider commented Nov 20, 2023

The optional input pattern does not seem to work if a process has more than one optional input.

For example, the following test:

params.inputs = "$projectDir/data/sites.txt"
params.filter = "$projectDir/assets/NO_FILE"

process foo {
  debug true
  input:
  path seq
  path(opt)
  path(opt2)

  script:
  def filter = opt.name != 'NO_FILE' ? "--filter $opt" : ''
  def filter2 = opt2.name != 'NO_FILE' ? "--filter $opt" : ''
  """
  echo your_command --input $seq $filter $filter2
  """
}

workflow {
  prots_ch = Channel.fromPath(params.inputs, checkIfExists:true)
  opt_file = file(params.filter, checkIfExists:true)
  opt2_file = file(params.filter, checkIfExists:true)

  foo(prots_ch, opt_file, opt2_file)
}

Returns a collision error:

ERROR ~ Error executing process > 'foo (1)'
ERROR ~ Error executing process > 'foo (1)'

Caused by:                                                                                                             Process `foo` input file name collision -- There are multiple input files for each of the following file names: NO_FILE


Tip: view the complete command output by changing to the process work dir and entering the command `cat .command.out`

 -- Check '.nextflow.log' file for details

How should one generalize this pattern to handle multiple optional inputs?

@cschu
Copy link

cschu commented Nov 20, 2023

I'd try making a second NO_FILE-file, e.g. NO_FILE2, use that as second input for the process and compare against it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants