/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Config file for defining DSL2 per module options and publishing paths
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Available keys to override module options:
        ext.args   = Additional arguments appended to command in module.
        ext.args2  = Second set of arguments appended to command in module (multi-tool modules).
        ext.args3  = Third set of arguments appended to command in module (multi-tool modules).
        ext.prefix = File name prefix for output files.
        ext.when   = When to run the module.
----------------------------------------------------------------------------------------
*/

// POSTPROCESSING VCFS
// Like, for instance, concatenating the unannotated, germline vcf-files

process {

    withName: 'GERMLINE_VCFS_CONCAT'{
        ext.when         =  params.concatenate_vcfs
        publishDir       = [
            //specify to avoid publishing, overwritten otherwise
            enabled: false
        ]
    }

    withName: 'GERMLINE_VCFS_CONCAT_SORT'{
        ext.prefix       = { "${meta.id}.germline" }
        ext.when         =  params.concatenate_vcfs
        publishDir       = [
            mode: params.publish_dir_mode,
                path: { "${params.outdir}/variant_calling/concat/${meta.id}/" }
        ]
    }

    withName: 'TABIX_EXT_VCF' {
        ext.prefix       = { "${input.baseName}" }
        ext.when         =  params.concatenate_vcfs
    }

    withName: 'TABIX_GERMLINE_VCFS_CONCAT_SORT'{
        ext.prefix       = { "${meta.id}.germline" }
        ext.when         =  params.concatenate_vcfs
        publishDir       = [
            mode: params.publish_dir_mode,
                path: { "${params.outdir}/variant_calling/concat/${meta.id}/" }
        ]
    }
}
