/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Nextflow config file for running minimal tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Defines input files and everything required to run a fast and simple pipeline test.

    Use as follows:
        nextflow run nf-core/demultiplex -profile test,<docker/singularity> --outdir <OUTDIR>

----------------------------------------------------------------------------------------
*/

params {
    config_profile_name        = 'Test bcl2fastq profile'
    config_profile_description = 'Minimal test dataset to check pipeline function with bcl2fastq'

    // Limit resources so that this can run on GitHub Actions
    max_cpus   = 2
    max_memory = '6.GB'
    max_time   = '6.h'

    // Input data
    input = "${projectDir}/assets/inputs/flowcell_input.csv"
    demultiplexer = 'bcl2fastq'

}

process {
    withName: BCL2FASTQ {
        ext.args = {[
            "--tiles s_1_1101",
        ].join(" ").trim()}
        publishDir = [
            [
                // Gather and write InterOp files
                path: { "${params.outdir}/${meta.id}/InterOp" },
                mode: params.publish_dir_mode,
                pattern: "**.bin",
                saveAs: {filename -> filename.split("/")[-1] }
            ],
            [
                // Fetch RunInfo.xml
                path: { "${params.outdir}/${meta.id}" },
                mode: params.publish_dir_mode,
                pattern: "RunInfo.xml",
                overwrite: true,
                saveAs: {filename -> filename.split("/")[-1] }
            ],
            [
                // Gather and write Reports and Stats
                path: { meta.lane ? "${params.outdir}/${meta.id}/L00${meta.lane}" : "${params.outdir}/${meta.id}" },
                mode: params.publish_dir_mode,
                pattern: "{Reports, Stats}",
                saveAs: {filename -> filename.split("/")[-1] }
            ],
            [
                path: { "${params.outdir}/${meta.id}" },
                pattern: "**.fastq.gz",
            ]
        ]
    }
}
