/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    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/sarek -profile test,<extra_test_profile>,<docker/singularity> --outdir <OUTDIR>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

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

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

    // Base directory for nf-core/modules test data
    modules_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/modules/'

    // Input data
    input = "${projectDir}/tests/csv/3.0/fastq_single.csv"

    // small genome on igenomes
    igenomes_base   = 's3://ngi-igenomes/testdata/nf-core/modules'
    genome          = 'testdata.nf-core.sarek'

    // Small reference genome
    bcftools_annotations     = "${params.modules_testdata_base_path}/genomics/sarscov2/illumina/vcf/test2.vcf.gz"
    bcftools_annotations_tbi = "${params.modules_testdata_base_path}/genomics/sarscov2/illumina/vcf/test2.vcf.gz.tbi"
    bcftools_header_lines    = "${projectDir}/tests/config/bcfann_test_header.txt"
    snpeff_cache             = null
    vep_cache                = null

    // Sentieon
    sentieon_dnascope_model    = "s3://ngi-igenomes/igenomes/Homo_sapiens/GATK/GRCh38/Annotation/Sentieon/SentieonDNAscopeModel1.1.model"

    // default params
    split_fastq = 0         // no FASTQ splitting
    tools       = 'strelka' // Variant calling with Strelka

    // Ignore params that will throw warning through params validation
    validationSchemaIgnoreParams = 'genomes'
}

process {

    withName:'.*:FREEC_SOMATIC'{
        ext.args = {
            [
                "sample":[
                    inputformat: "pileup",
                    mateorientation: "FR"
                ],
                "general":[
                    bedgraphoutput: "TRUE",
                    noisydata: "TRUE",
                    minexpectedgc: "0",
                    readcountthreshold: "1",
                    sex: meta.sex,
                    window: "10",
                    ],
                "control":[
                    inputformat: "pileup",
                    mateorientation: "FR"
                ]
            ]
        }
    }

    withName: '.*:MUTECT2_PAIRED'{
        //sample name from when the test data was generated
        ext.args = { "--f1r2-tar-gz ${task.ext.prefix}.f1r2.tar.gz --normal-sample normal" }
    }

    withName: '.*:FILTERVARIANTTRANCHES'{
        ext.args = { "--info-key CNN_1D --indel-tranche 0" }
    }
}


// Enable container engines/virtualisation envs for CI testing
// only works when specified with the profile ENV
// otherwise tests can be done with the regular provided profiles
if (System.getenv('PROFILE')) {
    if ("$PROFILE" == "conda") {
        conda.createTimeout                      = "120 min"
        conda.enabled                            = true
        charliecloud.enabled                     = false
        docker.enabled                           = false
        podman.enabled                           = false
        shifter.enabled                          = false
        singularity.enabled                      = false
    } else if ("$PROFILE" == "docker") {
        conda.enabled                            = false
        docker.enabled                           = true
        docker.runOptions                        = '-u $(id -u):$(id -g)'
        charliecloud.enabled                     = false
        podman.enabled                           = false
        shifter.enabled                          = false
        singularity.enabled                      = false
    } else if ("$PROFILE" == "singularity") {
        conda.enabled                            = false
        singularity.autoMounts                   = true
        singularity.enabled                      = true
        charliecloud.enabled                     = false
        docker.enabled                           = false
        podman.enabled                           = false
        shifter.enabled                          = false
    }
}
