2
$\begingroup$

Using DSL2.

I have processes A, B, C which I want to run in sequence - B waits for A to finish, C waits for B to finish.

They are not communicating via channels so I can't do A.out.collect().

I have tried making dummy channels but this is problematic and a hack. The onComplete subscription doesn't seem to let me trigger another process.

What is the correct way to run a sequence of processes which are not communicating or triggered by channels?

P.S. I am aware that this is not really the intended use case of Nextflow (which is oriented around channel communication/triggers... but... I just need to get this done.)

$\endgroup$
1
  • $\begingroup$ Could you please elaborate on how you tried to do dummy channels? Maybe by giving an example. I would suggest to use watchPath but using this type wouldn't allow your pipeline to finish. $\endgroup$
    – user324810
    Commented Jan 26, 2022 at 17:06

1 Answer 1

1
$\begingroup$

I would guess it is not possible without channels unless you are using beforeScript and afterScript. I came up with this solution:

#!/usr/bin/env nextflow

nextflow.enable.dsl=2

workflow {
  // C(B(A("")))

  next = ""
  next = A(next)
  next = B(next)
  next = C(next)
}


process A{
  echo true
  input: val _
  output: val ""

  """
  echo $task.process
  """
}

process B{
  echo true
  input: val _
  output: val ""

  """
  echo $task.process
  """
}

process C{
  echo true
  input: val _
  output: val ""

  """
  echo $task.process
  """
}

By using workflows you can change the execution order. But it is still a hack and I would prefer something like a next: keyword to specify the next process.


And for those not interested in DSL2:

process A {
  echo true

  output:
  val "" into B
  

  """
  echo "$task.process"
  """
}

process B {
  echo true

  input:
  val _ from B

  output:
  val "" into C

  """
  echo "$task.process"
  """
}

process C {
  echo true

  input:
  val _ from C

  """
  echo "$task.process"
  """
}

Also, I am quite curious to see other solutions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.