Skip to content

Instantly share code, notes, and snippets.

@idot
Created January 23, 2019 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idot/5ffa9aaf67399bd758bfbeecce77bb7a to your computer and use it in GitHub Desktop.
Save idot/5ffa9aaf67399bd758bfbeecce77bb7a to your computer and use it in GitHub Desktop.
NextFlow results per item in set
#!/usr/bin/env nextflow
//the problem is 1, then the channel gets file(*) => UnixPath; > 1, then channel gets ArrayList<UnixPath>
starts=Channel.from(1,2,3,4)
process first {
input:
val start from starts
output:
set val(start), file("result.*.txt") into (firstOutA,firstOutB)
shell:
'''
for i in {1..!{start}}
do
echo !{start} > result.${i}.txt
done
'''
}
perStart = firstOutB.flatMap{ f ->
s = f[0]
files = f[1]
if(files instanceof List){
files.collect{ r ->
tuple(s, r)
}
}else{
tuple(s, files)
}
}
process eachA {
input:
set val(start), file(result) from firstOutA
output:
stdout resultA
"""
echo $result $start
"""
}
process eachB {
input:
set val(start), file(result) from perStart
output:
stdout resultB
"""
echo $result $start
"""
}
resultA.subscribe {
println "A:"+it
}
resultB.subscribe{
println "B:"+it
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment