Multi-inputs to a Process

Overview

  • Tutorial: 15 min

    Objectives:
    • Learn how to manage multiple inputs to a process.

Most processes require multiple inputs. This section demonstrates how to handle them.

 1process collectGreetings {
 2
 3    publishDir 'results', mode: 'copy'
 4
 5    input:
 6        path input_files
 7        val batch_name
 8
 9    output:
10        path "COLLECTED-${batch_name}-output.txt"
11
12    script:
13        """
14        cat ${input_files} > 'COLLECTED-${batch_name}-output.txt'
15        """
16}
17
18
19workflow {
20
21    .....
22
23    // collect all the greetings into one file
24    collectGreetings(convertToUpper.out.collect(), params.batch)
25
26    .....
27}

Explanation

Inputs must be provided in the exact order they appear in the process’s input definition block.

Run the following workflow:

1nextflow run 13_multi_input.nf

Key Points

  1. A process in Nextflow can have multiple inputs.

  2. Inputs must be given in the same order as defined in the process’s input block.