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

//
// SNV calling options - deepvariant
//

process {

    withName: '.*CALL_SNV_DEEPVARIANT:.*' {
        ext.when = params.variant_caller.equals("deepvariant")
    }

    withName: '.*CALL_SNV_DEEPVARIANT:DEEPVARIANT' {
        ext.args = { "--model_type=${params.analysis_type.toUpperCase()}" }
        ext.prefix = { "${meta.id}_deepvar" }
    }

    withName: '.*CALL_SNV_DEEPVARIANT:GLNEXUS' {
        ext.args = '--config DeepVariant_unfiltered'
    }

    withName: '.*CALL_SNV_DEEPVARIANT:SPLIT_MULTIALLELICS_GL' {
        ext.args = '--output-type z --multiallelics -both'
    }

    withName: '.*CALL_SNV_DEEPVARIANT:REMOVE_DUPLICATES_GL' {
        ext.args = '--output-type z --rm-dup none'
        ext.prefix = { "${meta.id}_split_rmdup" }
        publishDir = [
            enabled: params.skip_mt_analysis,
            path: { "${params.outdir}/call_snv" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }

    withName: '.*CALL_SNV_DEEPVARIANT:TABIX_GL' {
        publishDir = [
            enabled: params.skip_mt_analysis,
            path: { "${params.outdir}/call_snv" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }
}
