process {

    publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

    withName: PICARD_SORTSAM {
        ext.prefix = { "${meta.id}.sorted" }
    }

    withName: PICARD_FILTERSAMREADS {
        ext.prefix = { "${meta.id}.filtered" }
    }

}
