/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    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            = Conditional clause
----------------------------------------------------------------------------------------
*/

//
// gcnvcaller calling options
//

process {

    if (!params.skip_germlinecnvcaller) {
        withName: ".*CALL_STRUCTURAL_VARIANTS:CALL_SV_GERMLINECNVCALLER.*" {
            publishDir = [
                enabled: false
            ]
            ext.when = !params.skip_germlinecnvcaller
        }

        withName: ".*CALL_STRUCTURAL_VARIANTS:CALL_SV_GERMLINECNVCALLER:GATK4_COLLECTREADCOUNTS" {
            ext.args = "--format TSV --interval-merging-rule OVERLAPPING_ONLY"
        }

        withName: ".*CALL_STRUCTURAL_VARIANTS:CALL_SV_GERMLINECNVCALLER:GATK4_DETERMINEGERMLINECONTIGPLOIDY" {
            ext.prefix = { "${meta.id}_ploidy" }
        }

        withName: ".*CALL_STRUCTURAL_VARIANTS:CALL_SV_GERMLINECNVCALLER:GATK4_GERMLINECNVCALLER" {
            ext.args = "--run-mode CASE"
            ext.prefix = { "${meta.id}_${model.simpleName}" }
        }

        withName: '.*CALL_STRUCTURAL_VARIANTS:CALL_SV_GERMLINECNVCALLER:BCFTOOLS_VIEW' {
            ext.prefix = { "${meta.id}_gatkcnv_segments_refiltered" }
            ext.args = { '--output-type z --exclude "N_ALT = 0" ' }
        }
    }
}
