My nextflow workflow uses a for loop in the scrip to run the same process for chromosomes 1 through n. Is there a more efficient/nextflow-like way to run this process which would also allow the output to be organized in directories by chromosome rather than id name?
process my_process {
// But want output to somehow be in folder by chromosome rather than id?
publishDir "${outdir}/$id
input:
tuple val(...), path(id)
output:
tuple val(id), path("${id}.chr{1,2,3,...n}.g.vcf"),
path("${id}.chr{1,2,3,...n}.g.vcf.idx")
script:
"""
for i in 1 2 3 ...n
do
gatk --java-options -I ...
done
"""
}
workflow {
Channel
.fromPath(params.input, checkIfExists: true)
.map {tuple( it.name.split('.sorted')[0], it )}
.set{input_ch}
my_process(input_ch)
}