/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    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   = When to run the module.
----------------------------------------------------------------------------------------
*/

// STRELKA

process {

    withName: 'STRELKA_.*' {
        ext.prefix       = { meta.num_intervals <= 1 ? "${meta.id}.strelka" : "${meta.id}.strelka.${target_bed.simpleName}" }
        ext.args         = { params.wes ? "--exome" : "" }
        ext.when         = { params.tools && params.tools.split(',').contains('strelka') }
        publishDir       = [
            mode: params.publish_dir_mode,
            path: { "${params.outdir}/variant_calling/" },
            pattern: "*{vcf.gz,vcf.gz.tbi}",
            saveAs: { meta.num_intervals > 1 ? null : "strelka/${meta.id}/${it}" }
        ]
    }

    withName: 'MERGE_STRELKA.*' {
        publishDir       = [
            mode: params.publish_dir_mode,
            path: { "${params.outdir}/variant_calling/strelka/${meta.id}/" },
            pattern: "*{vcf.gz,vcf.gz.tbi}"
        ]
    }

    withName: 'MERGE_STRELKA' {
        ext.prefix       = {"${meta.id}.strelka.variants"}
    }

    withName: 'MERGE_STRELKA_GENOME' {
        ext.prefix       = {"${meta.id}.strelka.genome"}
    }

    // PAIR_VARIANT_CALLING
    withName: 'MERGE_STRELKA_INDELS' {
        ext.prefix       = {"${meta.id}.strelka.somatic_indels"}
    }
    withName: 'MERGE_STRELKA_SNVS' {
        ext.prefix       = {"${meta.id}.strelka.somatic_snvs"}
    }
}
