process {

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

    withName: BAMTOOLS_CONVERT_EXT_ERROR {
        ext.args = "-format vcf"
    }

    withName: BAMTOOLS_CONVERT_NOEXT_ERROR {
        ext.args = ""
    }

    withName: BAMTOOLS_CONVERT_BED {
        ext.args = "-format bed"
    }

    withName: BAMTOOLS_CONVERT_FASTA {
        ext.args = "-format fasta"
    }

    withName: BAMTOOLS_CONVERT_FASTQ {
        ext.args = "-format fastq"
    }

    withName: BAMTOOLS_CONVERT_JSON {
        ext.args = "-format json"
    }

    withName: BAMTOOLS_CONVERT_PILEUP {
        ext.args = "-format pileup"
    }

    withName: BAMTOOLS_CONVERT_SAM {
        ext.args = "-format sam"
    }

    withName: BAMTOOLS_CONVERT_YAML {
        ext.args = "-format yaml"
    }

}
