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

//
// Evaluate variants
//

process {
    withName: '.*VARIANT_EVALUATION.*' {
        ext.when = { params.run_rtgvcfeval }
    }

    withName: '.*VARIANT_EVALUATION:BCFTOOLS_REHEADER' {
        beforeScript = { "echo ${meta.samplename} > ${meta.samplename}.txt" }
        ext.args   = { "--samples ${meta.samplename}.txt" }
        ext.args2  = "--output-type z"
        ext.when   = { params.run_rtgvcfeval }
        ext.prefix = { "${meta.samplename}_truthvcf" }
    }

    withName: '.*VARIANT_EVALUATION:RTGTOOLS_VCFEVAL' {
        ext.args   = { "--sample ${meta.samplename} --output-mode=split" }
        ext.when   = { params.run_rtgvcfeval }
        ext.prefix = { "${meta.samplename}_vcfeval" }
        publishDir = [
            path: { "${params.outdir}/rtgvcfeval" },
            mode: params.publish_dir_mode,
            saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
        ]
    }

}
