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

// SENTIEON DNASCOPE JOINT_GERMLINE

process {

    // TO-DO: duplicate!!
    withName: 'SENTIEON_GVCFTYPER' {
        ext.args         = { '--allow-old-rms-mapping-quality-annotation-data' }
        ext.prefix       = { meta.intervals_name }
        publishDir       = [
            enabled: false
        ]
    }

    if (params.tools && params.tools.contains('sentieon_dnascope') && params.joint_germline) {
        withName: 'NFCORE_SAREK:SAREK:BAM_VARIANT_CALLING_GERMLINE_ALL:BAM_JOINT_CALLING_GERMLINE_SENTIEON:BCFTOOLS_SORT' {
            ext.prefix       = { vcf.baseName - ".vcf" + ".sort" }
            publishDir       = [
                enabled: false
            ]
        }

        withName: 'NFCORE_SAREK:SAREK:BAM_VARIANT_CALLING_GERMLINE_ALL:BAM_JOINT_CALLING_GERMLINE_SENTIEON:MERGE_GENOTYPEGVCFS' {
            ext.prefix       = { 'joint_germline' }
            publishDir       = [
                mode: params.publish_dir_mode,
                path: { "${params.outdir}/variant_calling/sentieon_dnascope/joint_variant_calling/" },
                pattern: "*{vcf.gz,vcf.gz.tbi}"
            ]
        }
    }
}
