params {
    workflow_conceived_by = 'Kranti Konganti'
    workflow_built_by = 'Kranti Konganti'
    workflow_version = '1.0.0'
    bcs_root_dbdir = '/server/galaxy/tool-data/bettercallsal-db/PDG000000002.3082'
    bcs_db_mode = 'snp'
    bcs_db_mode_index = (params.bcs_db_mode ==~ /snp/ ? '_cluster' : '_serotype')
    bcs_thresholds = 'strict'
    filtlong_run = true
    filtlong_keep_perc = false
    filtlong_target_bases = false
    filtlong_min_length = 1000
    filtlong_max_length = 20000
    filtlong_min_mean_q = 75
    filtlong_min_window_q = 75
    filtlong_a = false
    filtlong_1 = false
    filtlong_2 = false
    filtlong_len_weight = false
    filtlong_mean_q_weight = 30
    filtlong_window_q_weight = 30
    filtlong_trim = false
    filtlong_split = false
    filtlong_window_size = 250
    mashscreen_run = true
    mash_sketch = (params.bcs_root_dbdir 
        + File.separator 
        + 'mash_sketch' 
        + File.separator 
        + 'msh.k21.1000h.' 
        + params.bcs_db_mode 
        + '.msh')
    mashscreen_w = false
    mashscreen_i = false
    mashscreen_v = false
    tuspy_run = true
    tuspy_s = false
    tuspy_m = false
    tuspy_ps = (params.bcs_root_dbdir 
        + File.separator 
        + 'index_metadata' 
        + File.separator 
        + 'per_' 
        + params.bcs_db_mode 
        + params.bcs_db_mode_index 
        + '.ACC2SERO.pickle')
    tuspy_gd = (params.bcs_root_dbdir 
        + File.separator 
        + 'scaffold_genomes')
    tuspy_gds = '_scaffolded_genomic.fna.gz'
    tuspy_n = 10
    tuspy_skip = 'PRJNA766315,PRJNA675435,PRJNA831577,PRJNA855361'
    sourmashsketch_run = true
    sourmashsketch_mode = 'dna'
    sourmashsketch_file = false
    sourmashsketch_f = false
    sourmashsketch_merge = false
    sourmashsketch_name = false
    sourmashsketch_p = 'abund,scaled=1000,k=51,k=61,k=71,k=81,k=91,k=101'
    sourmashsketch_singleton = true
    sourmashsketch_randomize = false
    sourmashgather_run = (params.sourmashsketch_run ?: false)
    sourmashgather_n = false
    sourmashgather_thr_bp = false
    sourmashgather_ignoreabn = false
    sourmashgather_prefetch = false
    sourmashgather_noprefetch = false
    sourmashgather_ani_ci = true
    sourmashgather_k = 81
    sourmashgather_protein = false
    sourmashgather_noprotein = false
    sourmashgather_dayhoff = false
    sourmashgather_nodayhoff = false
    sourmashgather_hp = false
    sourmashgather_nohp = false
    sourmashgather_dna = true
    sourmashgather_nodna = false
    sourmashgather_scaled = false
    sourmashgather_inc_pat = false
    sourmashgather_exc_pat = false
    sourmashsearch_run = (params.sourmashsketch_run && !params.sourmashgather_run ?: false)
    sourmashsearch_n = false
    sourmashsearch_thr = '0'
    sourmashsearch_contain = false
    sourmashsearch_maxcontain = true
    sourmashsearch_ignoreabn = true
    sourmashsearch_ani_ci = false
    sourmashsearch_k = 81
    sourmashsearch_protein = false
    sourmashsearch_noprotein = false
    sourmashsearch_dayhoff = false
    sourmashsearch_nodayhoff = false
    sourmashsearch_hp = false
    sourmashsearch_nohp = false
    sourmashsearch_dna = true
    sourmashsearch_nodna = false
    sourmashsearch_scaled = false
    sourmashsearch_inc_pat = false
    sourmashsearch_exc_pat = false
    sfhpy_run = true
    sfhpy_fcn = (params.sourmashsearch_run ? 'similarity' : 'f_match')
    sfhpy_fcv = (params.sourmashsearch_run ? 0.9 : 0.05)
    sfhpy_gt = true
    sfhpy_lt = false
    salmonalign_libtype = 'U'
    flye_run = true
    flye_pacbio_raw = false
    flye_pacbio_corr = false
    flye_pacbio_hifi = false
    flye_nano_raw = false
    flye_nano_corr = true
    flye_nano_hq = false
    flye_genome_size = false
    flye_polish_iter = '3'
    flye_min_overlap = false
    flye_scaffold = false
    flye_meta = true
    mm2_align_bam = true
    mm2_align_bam_sorted = false
    mm2_align_cigar_paf = false
    mm2_align_cigar_bam = false
    mlst_run = true
    mlst_scheme = 'senterica_achtman_2'
    mlst_legacy = true
    mlst_minid = 95
    mlst_mincov = 10
    mlst_minscore = 50
    abricate_run = true
    abricate_datadir = ("${projectDir}"
        + File.separator
        + 'assets'
        + File.separator
        + 'abricate_dbs')
    abricate_minid = 90
    abricate_mincov = 80
    abricate_summary_run = true
    gsrpy_run = true
    gsrpy_url = true
    gsrpy_snp_clus_metadata =  (params.bcs_root_dbdir
        + File.separator
        + 'download_pdg_metadata'
        + File.separator 
        + getPDGRelease(params.bcs_root_dbdir) 
        + File.separator
        + getPDGRelease(params.bcs_root_dbdir) 
        + '.reference_target.cluster_list.tsv')
    sourmashcompare_mode = 'ani,containment'
    fq_filter_by_len = 0
    fq_filename_delim_idx = 3
    fq_suffix = (params.fq_single_end ? '.fastq.gz' : '_R1_001.fastq.gz')
    fq2_suffix = '_R2_001.fastq.gz'
    multiqc_run = true
}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    METHOD TO GET PDG RELEASE AND SET REST OF THE METADATA FILES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

def getPDGRelease(db_path) {
	db_path_obj = new File( db_path )
	def pdg_release = []

	db_path_obj.eachDirRecurse {
		it.toString() =~ /PDG/ \
            ? pdg_release << it.toString().find(/PDG\d+\.\d+/) \
            : null
	}

	return pdg_release.unique().join('').toString()
}
