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

//
// Sentieon SNV calling options
//

process {

    if(params.variant_caller.equals("sentieon")) {
        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:SENTIEON_DNASCOPE' {
            ext.prefix = { "${meta.id}_dnascope" }
            ext.args2  = {
                params.variant_type ? "--var_type ${params.variant_type}"  : ''
            }
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:SENTIEON_DNAMODELAPPLY' {
            ext.prefix = { "${meta.id}_dnamodelapply" }
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:BCF_FILTER_ONE' {
            ext.args = "-s 'ML_FAIL' -i 'INFO/ML_PROB <= 0.95' -m x -Oz"
            ext.prefix = { "${meta.id}_mlfiltered_0.95" }
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:BCF_FILTER_TWO' {
            ext.args = "-i FILTER='\"PASS\"' -m x -Oz"
            ext.prefix = { "${meta.id}_passed" }
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:SPLIT_MULTIALLELICS_SEN' {
            ext.args = '--output-type z --multiallelics -both'
            ext.prefix = { "${meta.id}_split" }
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:REMOVE_DUPLICATES_SEN' {
            ext.args = '--output-type z --rm-dup none'
            ext.prefix = { "${meta.id}_split_rmdup" }
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:ADD_VARCALLER_TO_BED' {
            ext.args2   = '-s 1 -b 2 -e 3'
        }

        withName: '.*CALL_SNV:CALL_SNV_SENTIEON:BCFTOOLS_ANNOTATE' {
            ext.args = "-c CHROM,FROM,TO,FOUND_IN --output-type z"
            ext.prefix = { "${meta.id}_split_rmdup_info" }
        }
    }
}
