process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } withName: 'test_samtools_view_convert:SAMTOOLS_VIEW' { ext.args = "--output-fmt bam" } withName: 'test_samtools_view_index:SAMTOOLS_VIEW' { ext.args = "--output-fmt bam --write-index" } }