Created
January 23, 2019 15:44
-
-
Save idot/5ffa9aaf67399bd758bfbeecce77bb7a to your computer and use it in GitHub Desktop.
NextFlow results per item in set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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