process {

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

    withName: SAMTOOLS_BAM2FQ {
        ext.args = '-T RX'
    }

    withName: BWA_MEM {
        ext.args = '-p -C -M'
    }

    withName: BWAMEM2_MEM {
        ext.args = '-p -C -M'
    }

    withName: FGBIO_CALLMOLECULARCONSENSUSREADS {
        ext.args = '-M 1 -S Coordinate'
        ext.prefix = { "${meta.id}_umiconsensus" }
    }

    withName: SAMTOOLS_BAM2FQ {
        ext.args = '-T RX'
    }

    withName: SAMBLASTER {
        ext.args = '-M --addMateTags'
        ext.prefix = { "${meta.id}_processed" }
    }

}
