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

//
// Structural variant annotation options
//

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

    withName: '.*ANNOTATE_STRUCTURAL_VARIANTS:SVDB_QUERY' {
        ext.prefix = { "${meta.id}_svdbquery" }
    }

    withName: '.*ANNOTATE_STRUCTURAL_VARIANTS:PICARD_SORTVCF' {
        ext.prefix = { "${meta.id}_sortvcf" }
    }

    withName: '.*ANNOTATE_STRUCTURAL_VARIANTS:BCFTOOLS_VIEW' {
        ext.prefix = { "${meta.id}_view" }
    }

    withName: '.*ANNOTATE_STRUCTURAL_VARIANTS:ENSEMBLVEP_SV' {
        ext.args   = [
            '--dir_cache vep_cache',
            '--dir_plugins vep_cache/Plugins',
            '--plugin pLI,vep_cache/pLI_values_107.txt',
            '--appris --biotype --buffer_size 100 --canonical --cache --ccds',
            '--compress_output bgzip --distance 5000 --domains',
            '--exclude_predicted --force_overwrite --format vcf',
            '--fork 4 --hgvs --humdiv --max_sv_size 248956422 --merged',
            '--no_progress --no_stats --numbers --per_gene --polyphen p',
            '--protein --offline --regulatory --sift p',
            '--symbol --tsl --uniprot --vcf'
        ].join(' ')
        ext.prefix = { "${meta.id}_svdbquery_vep" }
        publishDir = [
            path: { "${params.outdir}/annotate_sv" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }

    withName: '.*ANNOTATE_STRUCTURAL_VARIANTS:TABIX_VEP' {
        publishDir = [
            path: { "${params.outdir}/annotate_sv" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }
}
