process COLLAPSE_PRIMERS {
    tag "$bed"
    label 'process_medium'

    conda (params.enable_conda ? "conda-forge::python=3.9.5" : null)
    container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
        'https://depot.galaxyproject.org/singularity/python:3.9--1' :
        'quay.io/biocontainers/python:3.9--1' }"

    input:
    path bed
    val left_suffix
    val right_suffix

    output:
    path '*.bed'       , emit: bed
    path "versions.yml", emit: versions

    when:
    task.ext.when == null || task.ext.when

    script: // This script is bundled with the pipeline, in nf-core/viralrecon/bin/
    """
    collapse_primer_bed.py \\
        --left_primer_suffix $left_suffix \\
        --right_primer_suffix $right_suffix \\
        $bed \\
        ${bed.baseName}.collapsed.bed

    cat <<-END_VERSIONS > versions.yml
    "${task.process}":
        python: \$(python --version | sed 's/Python //g')
    END_VERSIONS
    """
}
