// Define the Scratch directory
def scratch_dir = System.getenv("USER_SCRATCH") ?: "/tmp"

params {
    config_profile_name = 'cheaha'
    config_profile_description = 'University of Alabama at Birmingham Cheaha HPC'
    config_profile_contact = 'Lara Ianov (lianov@uab.edu) or Austyn Trull (atrull@uab.edu)'
    config_profile_url = 'https://www.uab.edu/cores/ircp/bds'
}

env {
    TMPDIR="$scratch_dir"
    SINGULARITY_TMPDIR="$scratch_dir"
}

singularity {
    enabled = true
    autoMounts = true
    runOptions = "--contain --workdir $scratch_dir"
}

//NOTE: modified queue below to not go into largemem-long due to reduced resources currently at our cluster
process {
    executor = 'slurm'
    queue = {(task.time <= 2.h ? 'express' : task.time <= 12.h ? 'short' : task.time <= 50.h ? 'medium' : 'long')}
    maxRetries = 3
    beforeScript = 'module load Singularity/3.5.2-GCC-5.4.0-2.26'
    queueSize = 25
    submitRateLimit = '10sec'
}

params {
    max_memory = 750.GB
    max_cpus = 128
    max_time = 150.h
}

process
{
    withName: '.*:.*FASTQC.*'
    {
        cpus = 20
    }
}

process
{
    withName: '.*:SAMTOOLS_SORT'
    {
        cpus = 20
    }
}


process
{
    withName: '.*:BLAZE'
    {
        cpus = 35
    }
}

process
{
    withName: '.*:TAG_BARCODES'
    {
        memory = '60.GB'
    }
}

process
{
    withName: '.*:PREEXTRACT_FASTQ'
    {
        cpus = 1
    }
}

process
{
    withName: '.*:PIGZ'
    {
        cpus = 20
    }
}

process
{
    withName: '.*:MINIMAP2_ALIGN'
    {
        cpus = 20
    }
}

process
{
    withName: '.*:ISOQUANT'
    {
        cpus = 40
        memory = '95.GB'
        time = '150.h'
    }
}
