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

//
// rhocall viz options
//

process {

    withName: '.*ANNOTATE_GENOME_SNVS:ANNOTATE_RHOCALLVIZ:BCFTOOLS_VIEW' {
        ext.prefix = { "${meta.sample}" }
        ext.args   = { "--output-type z --min-ac 1 --samples ${meta.sample}" }
    }

    withName: '.*ANNOTATE_GENOME_SNVS:ANNOTATE_RHOCALLVIZ:BCFTOOLS_ROH' {
        ext.prefix = { "${meta.sample}" }
        ext.args   = { "--AF-tag GNOMADAF --skip-indels" }
    }

    withName: '.*ANNOTATE_GENOME_SNVS:ANNOTATE_RHOCALLVIZ:BCFTOOLS_VIEW_UNCOMPRESS' {
        ext.prefix = { "${meta.sample}" }
        ext.args   = { "--output-type v" }
    }

    withName: '.*ANNOTATE_GENOME_SNVS:ANNOTATE_RHOCALLVIZ:RHOCALL_VIZ' {
        ext.prefix = { "${meta.sample}_rhocallviz" }
        ext.args   = { "--aftag GNOMADAF --wig" }
        publishDir = [
            path: { "${params.outdir}/annotate_snv/genome" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }

    withName: '.*ANNOTATE_GENOME_SNVS:ANNOTATE_RHOCALLVIZ:CHROMOGRAPH_AUTOZYG' {
        ext.prefix = { "${autozyg.simpleName}_autozyg_chromograph" }
        ext.args = { "--euploid" }
        ext.when = { !(workflow.profile.tokenize(',').intersect(['test', 'test_one_sample']).size() >= 1) || workflow.stubRun }
        publishDir = [
            path: { "${params.outdir}/annotate_snv/genome/" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }

    withName: '.*ANNOTATE_GENOME_SNVS:ANNOTATE_RHOCALLVIZ:UCSC_WIGTOBIGWIG' {
        ext.prefix = { "${meta.sample}_rhocallviz" }
        ext.args   = { "-clip" }
        publishDir = [
            path: { "${params.outdir}/annotate_snv/genome/${meta.sample}_rhocallviz" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }
}
