Answers.Body: <p>Nextflow uses <a href="https://www.nextflow.io/docs/latest/channel.html" rel="nofollow noreferrer"><em>channels</em></a> (asynchronous <a href="https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)" rel="nofollow noreferrer">FIFO</a> queues) to communicate between processes. The interaction between these processes, and ultimately the pipeline execution flow itself, is implicitly defined by these input and output declarations.</p>
  <p>The issue with your code, I think, is the use of <a href="https://www.nextflow.io/docs/latest/process.html#understand-how-multiple-input-channels-work" rel="nofollow noreferrer">multiple input channels</a>. Consider the following example that uses only a single <a href="https://www.nextflow.io/docs/latest/channel.html#queue-channel" rel="nofollow noreferrer"><em>queue</em></a> channel. To avoid declaring the inputs again in process A's output declaration, we can output a key to join on as the first element in the output tuple. In the case below, this is simply the 'some_name' variable. We can then join up the two channels using the <a href="https://www.nextflow.io/docs/latest/operator.html#join" rel="nofollow noreferrer">join operator</a> as follows:</p>
  <pre><code>Channel
      .fromFilePairs( './data/*.txt', size:1 )
      .map { group_key, files -&gt; tuple( group_key, *files ) }
      .into { input_ch_A; input_ch_B }
  
  
  process A {
  
      input:
      tuple val(some_name), path(some_path) from input_ch_A
  
      output:
      tuple val(some_name), val(&quot;procA_<span class="math-container">${some_name}"), path("procA_$</span>{some_name}&quot;) \
          into procA_results
  
      &quot;&quot;&quot;
      touch &quot;procA_${some_name}&quot;
      &quot;&quot;&quot;
  }
  
  process B {
  
      input:
      tuple val(some_name), path(some_path), val(some_other_val), path(some_other_path) \
          from input_ch_B.join(procA_results)
  
      &quot;&quot;&quot;
      true
      &quot;&quot;&quot;
  }
  <span class="math-container">```</span>
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-22T15:35:16.653Z
Answers.LastActivityDate: 2021-03-22T15:35:16.653Z
Answers.UserDisplayName: Steve
Body: <p>I need to build a pipeline where 2nd process starts after completion of the 1st process and the 3rd after 2nd. As I understand nextflow's processes run parallel. But I need it to run in a order 1st&gt;2nd&gt;3rd processes and so on. Because each process runs on an array and produce multiple outputs which are used by the next. If they run paralleled, the 2nd process may look for input 20 whereas the 1st process produced output 10 and then the process stops, because the command in the 2nd process does not find the input. Is there any way to accomplish this. I tried as follows:</p>
  <pre><code>process A{
  input:
  tuple val(some_name), path(some path) from some_channel
  output:
  tuple val(some val), path(some path) into A_some_ch
  tuple va(some other va), path(some other path) into A_some_other_ch
  val true into done_ch
  script:
  &quot;&quot;&quot;
  some command out some files
  some other command out some other files
  &quot;&quot;&quot;
  }
  process B {
  input:
  val flag from done_ch
  val (some val), path(some path) from A_some_ch
  val (some other val), path(some other path) from A_some_other_ch
  output:
  some val and path
  script:
  &quot;&quot;&quot;
  some commands out some files
  &quot;&quot;&quot;
  }
  </code></pre>
  <p>I got the idea using of flag from here: <a href="https://github.com/nextflow-io/patterns/blob/master/docs/mock-dependency.adoc" rel="nofollow noreferrer">https://github.com/nextflow-io/patterns/blob/master/docs/mock-dependency.adoc</a></p>
  <p>But if I use the flag, I got:</p>
  <pre><code>Operation 'set' does not allow more than one target name
  </code></pre>
  <p>Does it clarify the issue? Any Help?
  Best, Zillur</p>
  
Tags: <nextflow>
Title: Nextflow: ordering the execution of processes; outputs of process A are inputs of process B
ThreadText: # Nextflow: ordering the execution of processes; outputs of process A are inputs of process B
  
  (Asked by: username_0 on 2021-03-22)
  
  I need to build a pipeline where 2nd process starts after completion of the 1st process and the 3rd after 2nd. As I understand nextflow's processes run parallel. But I need it to run in a order 1st>2nd>3rd processes and so on. Because each process runs on an array and produce multiple outputs which are used by the next. If they run paralleled, the 2nd process may look for input 20 whereas the 1st process produced output 10 and then the process stops, because the command in the 2nd process does not find the input. Is there any way to accomplish this. I tried as follows:
  
  ```
  process A{
  input:
  tuple val(some_name), path(some path) from some_channel
  output:
  tuple val(some val), path(some path) into A_some_ch
  tuple va(some other va), path(some other path) into A_some_other_ch
  val true into done_ch
  script:
  """
  some command out some files
  some other command out some other files
  """
  }
  process B {
  input:
  val flag from done_ch
  val (some val), path(some path) from A_some_ch
  val (some other val), path(some other path) from A_some_other_ch
  output:
  some val and path
  script:
  """
  some commands out some files
  """
  }
  
  ```
  
  I got the idea using of flag from here: <https://github.com/nextflow-io/patterns/blob/master/docs/mock-dependency.adoc>
  
  But if I use the flag, I got:
  
  ```
  Operation 'set' does not allow more than one target name
  
  ```
  
  Does it clarify the issue? Any Help?
  Best, username_0
  
  **Tags:** nextflow
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-03-22. Score: 1 | Accepted answer
  
  Nextflow uses [*channels*](https://www.nextflow.io/docs/latest/channel.html) (asynchronous [FIFO](https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)) queues) to communicate between processes. The interaction between these processes, and ultimately the pipeline execution flow itself, is implicitly defined by these input and output declarations.
  
  The issue with your code, I think, is the use of [multiple input channels](https://www.nextflow.io/docs/latest/process.html#understand-how-multiple-input-channels-work). Consider the following example that uses only a single [*queue*](https://www.nextflow.io/docs/latest/channel.html#queue-channel) channel. To avoid declaring the inputs again in process A's output declaration, we can output a key to join on as the first element in the output tuple. In the case below, this is simply the 'some\_name' variable. We can then join up the two channels using the [join operator](https://www.nextflow.io/docs/latest/operator.html#join) as follows:
  
  ```
  Channel
      .fromFilePairs( './data/*.txt', size:1 )
      .map { group_key, files -> tuple( group_key, *files ) }
      .into { input_ch_A; input_ch_B }
  
  process A {
  
      input:
      tuple val(some_name), path(some_path) from input_ch_A
  
      output:
      tuple val(some_name), val("procA_${some_name}"), path("procA_${some_name}") \
          into procA_results
  
      """
      touch "procA_${some_name}"
      """
  }
  
  process B {
  
      input:
      tuple val(some_name), path(some_path), val(some_other_val), path(some_other_path) \
          from input_ch_B.join(procA_results)
  
      """
      true
      """
  }
  ```
  
  ```
  
  
  ---
  
  