Clinical-Genomics-Lund / SomaticPanelPipeline

0 stars 2 forks source link

Bug: Publishing Files Fails When Multiple Patterns Are Defined #39

Closed ramsainanduri closed 8 months ago

ramsainanduri commented 8 months ago

When defining multiple publishDir directives with different patterns in the configuration, files are not being published to their respective directories as expected. Instead, Nextflow considers only the last publishDir defined, leading to unintended behavior. This issue affects scenarios where multiple patterns are specified for different publish directories, and the desired outcome is for files to be correctly published according to their respective patterns and directories.

Example of the old code block in the config:

withName: '.*CNV_CALLING:MERGE_GENS' {
        container = "${params.container_dir}/SomaticPanelPipeline_2021-06-24.sif"

        # First publishDir definition
        publishDir = [ 
            path: "${params.outdir}/${params.subdir}/gens",
            mode: 'copy',
            overwrite: true,
            pattern: '*.bed.gz*'
        ]

        # Second publishDir definition
        publishDir = [ 
            path: "${params.outdir}/cron/gens",
            mode: 'copy',
            overwrite: true,
            pattern: '*.gens',
        ]

    }

Solution:

To address this issue, consider restructuring the publishDir definitions as nested lists within a single publishDir directive. This can be achieved by encapsulating each set of parameters for a specific directory as a nested list. Below is an example of how to modify the code:

withName: '.*CNV_CALLING:MERGE_GENS' {

    publishDir = [ 
        // First publishDir definition
        [
         path: "${params.outdir}/${params.subdir}/gens",
         mode: 'copy',
         overwrite: true,
         pattern: '*.bed.gz*'
        ],

        // Second publishDir definition
        [
         path: "${params.outdir}/cron/gens",
         mode: 'copy',
         overwrite: true,
         pattern: '*.gens'
        ]
    ]
}