/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    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.
----------------------------------------------------------------------------------------
*/

// TIDDIT

process {

    withName: 'TIDDIT_SV' {
        ext.args   = { bwa_index ? '' : '--skip_assembly' }
        ext.prefix = { "${meta.id}.tiddit" }
        ext.when   = { params.tools && params.tools.split(',').contains('tiddit') }
        publishDir = [
            mode: params.publish_dir_mode,
            path: { "${params.outdir}/variant_calling/tiddit/${meta.id}/" },
            pattern: "*tab"
        ]
    }

    withName : 'TABIX_BGZIP_TIDDIT_SV' {
        ext.prefix = { "${meta.id}.tiddit" }
        publishDir = [
            mode: params.publish_dir_mode,
            path: { "${params.outdir}/variant_calling/tiddit/${meta.id}/" },
            pattern: "*{vcf.gz,vcf.gz.tbi}"
        ]
    }

    // PAIR_VARIANT_CALLING
    if (params.tools && params.tools.split(',').contains('tiddit')) {
        withName: 'NFCORE_SAREK:SAREK:BAM_VARIANT_CALLING_SOMATIC_ALL:BAM_VARIANT_CALLING_SOMATIC_TIDDIT:TIDDIT_NORMAL:TABIX_BGZIP_TIDDIT_SV' {
            ext.prefix = {"${meta.id}.tiddit.normal"}
        }

        withName: 'NFCORE_SAREK:SAREK:BAM_VARIANT_CALLING_SOMATIC_ALL:BAM_VARIANT_CALLING_SOMATIC_TIDDIT:TIDDIT_TUMOR:TABIX_BGZIP_TIDDIT_SV' {
            ext.prefix = {"${meta.id}.tiddit.tumor"}
        }

        // SVDB
        withName: 'NFCORE_SAREK:SAREK:BAM_VARIANT_CALLING_SOMATIC_ALL:BAM_VARIANT_CALLING_SOMATIC_TIDDIT:SVDB_MERGE' {
            ext.args2  = { '--output-type z' }
            ext.prefix = { "${meta.id}.tiddit_sv_merge" }
            publishDir = [
                mode: params.publish_dir_mode,
                path: { "${params.outdir}/variant_calling/tiddit/${meta.id}/" },
                pattern: "*vcf.gz"
            ]
        }
    }
}
