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

//
// Gens options
//

process {
    if (!params.skip_gens && params.analysis_type != "wes") {
        withName: '.*GENS:.*' {
            publishDir = [
                enabled: false
            ]
        }

        withName: '.*GENS:COLLECTREADCOUNTS' {
            ext.args = { [
                '--interval-merging-rule OVERLAPPING_ONLY',
                '--format HDF5'
                ].join(' ') }
        }

        withName: '.*GENS:GENS_GENERATE' {
            ext.prefix = { "${meta.id}_gens" }
            publishDir = [
                path: { "${params.outdir}/gens" },
                mode: params.publish_dir_mode,
                saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
            ]
        }
    }
}
