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


process {
    withName: '.*ANN_CSQ_PLI_SV:.*' {
        ext.when = !params.skip_sv_annotation
        publishDir = [
            enabled: false
        ]
    }

    withName: '.*ANN_CSQ_PLI_SV:ADD_MOST_SEVERE_CSQ' {
        ext.prefix = { "${meta.id}_vep_csq" }
    }

    withName: '.*ANN_CSQ_PLI_SV:ADD_MOST_SEVERE_PLI' {
        ext.prefix = { "${meta.id}_vep_csq_pli" }
    }

    withName: '.*ANN_CSQ_PLI_SV:TABIX_BGZIPTABIX' {
        ext.prefix = { "${meta.id}_vep_csq_pli" }
        publishDir = [
            path: { "${params.outdir}/annotate_sv" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }

}

process {
    withName: '.*ANN_CSQ_PLI_SNV:.*' {
        ext.when = !params.skip_snv_annotation
        publishDir = [
            enabled: false
        ]
    }

    withName: '.*ANN_CSQ_PLI_SNV:ADD_MOST_SEVERE_CSQ' {
        ext.prefix = { "${meta.id}_vep_csq" }
    }

    withName: '.*ANN_CSQ_PLI_SNV:ADD_MOST_SEVERE_PLI' {
        ext.prefix = { "${meta.id}_vep_csq_pli" }
    }

    withName: '.*ANN_CSQ_PLI_SNV:TABIX_BGZIPTABIX' {
        ext.prefix = { "${meta.id}_vep_csq_pli" }
        publishDir = [
            path: { "${params.outdir}/annotate_snv" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }
}
