Skip to content

Instantly share code, notes, and snippets.

@pditommaso
Last active July 28, 2021 09:06
Show Gist options
  • Save pditommaso/a7fb853e2528158b885c to your computer and use it in GitHub Desktop.
Save pditommaso/a7fb853e2528158b885c to your computer and use it in GitHub Desktop.
Nextflow script showing how to repeat the execution of a process
#!/bin/env nextflow
Channel
.from('abc')
.map { tuple(0,it) }
.set { foo }
Channel.create().set { feedback }
index = 0
loop = feedback.take(3).map { tuple(index++,it) }
process bar {
input:
set val(index), file(x) from foo .mix(loop)
output:
file q
script:
if( index == 0 )
"""
rev $x > q
"""
else if( index >1 )
"""
rev $x > q
"""
}
process baz {
input:
file q from q
output:
file z into feedback
file z into result
"""
cat $q > z
echo 'hello' >> z
"""
}
result.last().println { it.text }
@tlamadon
Copy link

tlamadon commented Apr 1, 2021

This is a very useful example! Would this look similar in DSL2? I guess it could be used as a work around the fact that each process can only be called once?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment