From b2dde772d5ac0920c98ebc74a85734630bcdef31 Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 11:04:11 +0200 Subject: [PATCH 1/8] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 502ca098c..7786c8260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [#1232](https://github.com/nf-core/sarek/pull/1232) - Fix Zenodo IDs in manifest +- [#1236](https://github.com/nf-core/sarek/pull/1236) - Fix annotation cache folder verification when no annotation ### Dependencies From 15206c98f0bbb42ec121a4beeec86cd8668b77f8 Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 11:05:44 +0200 Subject: [PATCH 2/8] fixing folder checks --- workflows/sarek.nf | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index eec7332c4..85b90720b 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -288,19 +288,20 @@ if ((params.download_cache) && (params.snpeff_cache || params.vep_cache)) { error("Please specify either `--download_cache` or `--snpeff_cache`, `--vep_cache`.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } -if ( params.vep_cache ) { +if (params.snpeff_cache && params.tools && params.tools.contains("snpeff")) { + def snpeff_cache_dir = file("$params.snpeff_cache", type: 'dir') / "${params.snpeff_genome}.${params.snpeff_db}" + if ( !snpeff_cache_dir.exists() || !snpeff_cache_dir.isDirectory() ) { + error("Files within --snpeff_cache invalid. Make sure there is a directory named ${params.snpeff_genome}.${params.snpeff_db} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") + } +} + +if (params.vep_cache && params.tools && params.tools.contains("vep")) { def vep_cache_dir = file("$params.vep_cache", type: 'dir') / "${params.vep_cache_version}_${params.vep_genome}" if ( !vep_cache_dir.exists() || !vep_cache_dir.isDirectory() ) { error("Files within --vep_cache invalid. Make sure there is a directory named ${params.vep_cache_version}_${params.vep_genome} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } } -if ( params.snpeff_cache ) { - def snpeff_cache_dir = file("$params.snpeff_cache", type: 'dir') / "${params.snpeff_genome}.${params.snpeff_db}" - if ( !snpeff_cache_dir.exists() || !snpeff_cache_dir.isDirectory() ) { - error("Files within --snpeff_cache invalid. Make sure there is a directory named ${params.snpeff_genome}.${params.snpeff_db} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") - } -} /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ IMPORT LOCAL MODULES/SUBWORKFLOWS From 841ed94bca67ab6b4d7e1adcf5d2832314d1c4ef Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 11:29:28 +0200 Subject: [PATCH 3/8] add meta map to channel --- workflows/sarek.nf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index 85b90720b..22b69f037 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -289,14 +289,18 @@ if ((params.download_cache) && (params.snpeff_cache || params.vep_cache)) { } if (params.snpeff_cache && params.tools && params.tools.contains("snpeff")) { - def snpeff_cache_dir = file("$params.snpeff_cache", type: 'dir') / "${params.snpeff_genome}.${params.snpeff_db}" + def snpeff_cache_dir = params.use_annotation_cache_keys ? + file("$params.snpeff_cache", type: 'dir') + "/${params.snpeff_genome}.${params.snpeff_db}/${params.snpeff_genome}.${params.snpeff_db}" : + file("$params.snpeff_cache", type: 'dir') + "/${params.snpeff_genome}.${params.snpeff_db}" if ( !snpeff_cache_dir.exists() || !snpeff_cache_dir.isDirectory() ) { error("Files within --snpeff_cache invalid. Make sure there is a directory named ${params.snpeff_genome}.${params.snpeff_db} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } } if (params.vep_cache && params.tools && params.tools.contains("vep")) { - def vep_cache_dir = file("$params.vep_cache", type: 'dir') / "${params.vep_cache_version}_${params.vep_genome}" + def vep_cache_dir = params.use_annotation_cache_keys ? + file("$params.vep_cache", type: 'dir') + "/${params.vep_cache_version}_${params.vep_genome}/${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" : + file("$params.vep_cache", type: 'dir') + "/${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" if ( !vep_cache_dir.exists() || !vep_cache_dir.isDirectory() ) { error("Files within --vep_cache invalid. Make sure there is a directory named ${params.vep_cache_version}_${params.vep_genome} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } @@ -338,6 +342,9 @@ vep_species = params.vep_species ?: Channel.empty() snpeff_cache = params.snpeff_cache ? params.use_annotation_cache_keys ? Channel.fromPath("${params.snpeff_cache}/${params.snpeff_genome}.${params.snpeff_db}", checkIfExists: true).collect() : Channel.fromPath(params.snpeff_cache).collect() : [] vep_cache = params.vep_cache ? params.use_annotation_cache_keys ? Channel.fromPath("${params.vep_cache}/${params.vep_cache_version}_${params.vep_genome}", checkIfExists: true).collect() : Channel.fromPath(params.vep_cache).collect() : [] +// Add meta map to channel +snpeff_cache = snpeff_cache.map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} + vep_extra_files = [] if (params.dbnsfp && params.dbnsfp_tbi) { From 09553a776ba6bd02fe2e8320f8eefea49060379e Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 11:40:44 +0200 Subject: [PATCH 4/8] more complete error message --- workflows/sarek.nf | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index 22b69f037..417e3d700 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -290,19 +290,21 @@ if ((params.download_cache) && (params.snpeff_cache || params.vep_cache)) { if (params.snpeff_cache && params.tools && params.tools.contains("snpeff")) { def snpeff_cache_dir = params.use_annotation_cache_keys ? - file("$params.snpeff_cache", type: 'dir') + "/${params.snpeff_genome}.${params.snpeff_db}/${params.snpeff_genome}.${params.snpeff_db}" : - file("$params.snpeff_cache", type: 'dir') + "/${params.snpeff_genome}.${params.snpeff_db}" - if ( !snpeff_cache_dir.exists() || !snpeff_cache_dir.isDirectory() ) { - error("Files within --snpeff_cache invalid. Make sure there is a directory named ${params.snpeff_genome}.${params.snpeff_db} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") + "${params.snpeff_genome}.${params.snpeff_db}/${params.snpeff_genome}.${params.snpeff_db}" : + "${params.snpeff_genome}.${params.snpeff_db}" + def snpeff_cache_path_full = file("$params.snpeff_cache", type: 'dir') / snpeff_cache_dir + if ( !snpeff_cache_path_full.exists() || !snpeff_cache_path_full.isDirectory() ) { + error("Files within --snpeff_cache invalid. Make sure there is a directory named ${snpeff_cache_dir} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } } if (params.vep_cache && params.tools && params.tools.contains("vep")) { def vep_cache_dir = params.use_annotation_cache_keys ? - file("$params.vep_cache", type: 'dir') + "/${params.vep_cache_version}_${params.vep_genome}/${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" : - file("$params.vep_cache", type: 'dir') + "/${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" - if ( !vep_cache_dir.exists() || !vep_cache_dir.isDirectory() ) { - error("Files within --vep_cache invalid. Make sure there is a directory named ${params.vep_cache_version}_${params.vep_genome} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") + "${params.vep_cache_version}_${params.vep_genome}/${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" : + "${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" + def vep_cache_path_full = file("$params.vep_cache", type: 'dir') / vep_cache_dir + if ( !vep_cache_path_full.exists() || !vep_cache_path_full.isDirectory() ) { + error("Files within --vep_cache invalid. Make sure there is a directory named ${vep_cache_dir} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } } From 9e27d771a1eed1bded88c43278694e46c9d7b5f9 Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 11:46:01 +0200 Subject: [PATCH 5/8] fix map --- workflows/sarek.nf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index 417e3d700..ac4f1780a 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -341,11 +341,13 @@ vep_genome = params.vep_genome ?: Channel.empty() vep_species = params.vep_species ?: Channel.empty() // Initialize files channels based on params, not defined within the params.genomes[params.genome] scope -snpeff_cache = params.snpeff_cache ? params.use_annotation_cache_keys ? Channel.fromPath("${params.snpeff_cache}/${params.snpeff_genome}.${params.snpeff_db}", checkIfExists: true).collect() : Channel.fromPath(params.snpeff_cache).collect() : [] -vep_cache = params.vep_cache ? params.use_annotation_cache_keys ? Channel.fromPath("${params.vep_cache}/${params.vep_cache_version}_${params.vep_genome}", checkIfExists: true).collect() : Channel.fromPath(params.vep_cache).collect() : [] +snpeff_cache = params.snpeff_cache ? params.use_annotation_cache_keys ? + Channel.fromPath("${params.snpeff_cache}/${params.snpeff_genome}.${params.snpeff_db}", checkIfExists: true).collect().map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} : + Channel.fromPath(params.snpeff_cache).collect().map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} : [] -// Add meta map to channel -snpeff_cache = snpeff_cache.map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} +vep_cache = params.vep_cache ? params.use_annotation_cache_keys ? + Channel.fromPath("${params.vep_cache}/${params.vep_cache_version}_${params.vep_genome}", checkIfExists: true).collect() : + Channel.fromPath(params.vep_cache).collect() : [] vep_extra_files = [] From 0918d31bd976d9900335b184b3e47f7fd7aa2590 Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 12:12:47 +0200 Subject: [PATCH 6/8] simplify logic --- workflows/sarek.nf | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index ac4f1780a..69b711601 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -288,26 +288,6 @@ if ((params.download_cache) && (params.snpeff_cache || params.vep_cache)) { error("Please specify either `--download_cache` or `--snpeff_cache`, `--vep_cache`.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } -if (params.snpeff_cache && params.tools && params.tools.contains("snpeff")) { - def snpeff_cache_dir = params.use_annotation_cache_keys ? - "${params.snpeff_genome}.${params.snpeff_db}/${params.snpeff_genome}.${params.snpeff_db}" : - "${params.snpeff_genome}.${params.snpeff_db}" - def snpeff_cache_path_full = file("$params.snpeff_cache", type: 'dir') / snpeff_cache_dir - if ( !snpeff_cache_path_full.exists() || !snpeff_cache_path_full.isDirectory() ) { - error("Files within --snpeff_cache invalid. Make sure there is a directory named ${snpeff_cache_dir} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") - } -} - -if (params.vep_cache && params.tools && params.tools.contains("vep")) { - def vep_cache_dir = params.use_annotation_cache_keys ? - "${params.vep_cache_version}_${params.vep_genome}/${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" : - "${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" - def vep_cache_path_full = file("$params.vep_cache", type: 'dir') / vep_cache_dir - if ( !vep_cache_path_full.exists() || !vep_cache_path_full.isDirectory() ) { - error("Files within --vep_cache invalid. Make sure there is a directory named ${vep_cache_dir} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") - } -} - /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ IMPORT LOCAL MODULES/SUBWORKFLOWS @@ -341,13 +321,25 @@ vep_genome = params.vep_genome ?: Channel.empty() vep_species = params.vep_species ?: Channel.empty() // Initialize files channels based on params, not defined within the params.genomes[params.genome] scope -snpeff_cache = params.snpeff_cache ? params.use_annotation_cache_keys ? - Channel.fromPath("${params.snpeff_cache}/${params.snpeff_genome}.${params.snpeff_db}", checkIfExists: true).collect().map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} : - Channel.fromPath(params.snpeff_cache).collect().map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} : [] +if (params.snpeff_cache && params.tools && params.tools.contains("snpeff")) { + def snpeff_annotation_cache_key = params.use_annotation_cache_keys ? "${params.snpeff_genome}.${params.snpeff_db}/" : "" + def snpeff_cache_dir = "${snpeff_annotation_cache_key}${params.snpeff_genome}.${params.snpeff_db}" + def snpeff_cache_path_full = file("$params.snpeff_cache", type: 'dir') / snpeff_cache_dir + if ( !snpeff_cache_path_full.exists() || !snpeff_cache_path_full.isDirectory() ) { + error("Files within --snpeff_cache invalid. Make sure there is a directory named ${snpeff_cache_dir} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") + } + snpeff_cache = Channel.fromPath("${params.snpeff_cache}/${snpeff_annotation_cache_key}", checkIfExists: true).collect().map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} +} else snpeff_cache = [] -vep_cache = params.vep_cache ? params.use_annotation_cache_keys ? - Channel.fromPath("${params.vep_cache}/${params.vep_cache_version}_${params.vep_genome}", checkIfExists: true).collect() : - Channel.fromPath(params.vep_cache).collect() : [] +if (params.vep_cache && params.tools && params.tools.contains("vep")) { + def vep_annotation_cache_key = params.use_annotation_cache_keys ? "${params.vep_cache_version}_${params.vep_genome}/" : "" + def vep_cache_dir = "${vep_annotation_cache_key}${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" + def vep_cache_path_full = file("$params.vep_cache", type: 'dir') / vep_cache_dir + if ( !vep_cache_path_full.exists() || !vep_cache_path_full.isDirectory() ) { + error("Files within --vep_cache invalid. Make sure there is a directory named ${vep_cache_dir} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") + } + vep_cache = Channel.fromPath("${params.vep_cache}/${vep_annotation_cache_key}", checkIfExists: true).collect() +} else vep_cache = [] vep_extra_files = [] From ed0e0528303525673b8728116e12f48876fbb1f0 Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 13:40:17 +0200 Subject: [PATCH 7/8] more safeguards --- workflows/sarek.nf | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index 69b711601..34dfcb803 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -50,14 +50,16 @@ def checkPathParamList = [ params.multiqc_config, params.pon, params.pon_tbi, - params.snpeff_cache, params.spliceai_indel, params.spliceai_indel_tbi, params.spliceai_snv, - params.spliceai_snv_tbi, - params.vep_cache + params.spliceai_snv_tbi ] +// only check if we are using the tools +if (params.tools && params.tools.contains("snpeff")) checkPathParamList.add(params.snpeff_cache) +if (params.tools && params.tools.contains("vep")) checkPathParamList.add(params.vep_cache) + // Validate input parameters WorkflowSarek.initialise(params, log) From e745db6e36399553098cd819a845a0d46d1a4cec Mon Sep 17 00:00:00 2001 From: maxulysse Date: Fri, 15 Sep 2023 13:52:13 +0200 Subject: [PATCH 8/8] code polish --- workflows/sarek.nf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/workflows/sarek.nf b/workflows/sarek.nf index 34dfcb803..13a2d8d73 100644 --- a/workflows/sarek.nf +++ b/workflows/sarek.nf @@ -326,21 +326,22 @@ vep_species = params.vep_species ?: Channel.empty() if (params.snpeff_cache && params.tools && params.tools.contains("snpeff")) { def snpeff_annotation_cache_key = params.use_annotation_cache_keys ? "${params.snpeff_genome}.${params.snpeff_db}/" : "" def snpeff_cache_dir = "${snpeff_annotation_cache_key}${params.snpeff_genome}.${params.snpeff_db}" - def snpeff_cache_path_full = file("$params.snpeff_cache", type: 'dir') / snpeff_cache_dir + def snpeff_cache_path_full = file("$params.snpeff_cache/$snpeff_cache_dir", type: 'dir') if ( !snpeff_cache_path_full.exists() || !snpeff_cache_path_full.isDirectory() ) { error("Files within --snpeff_cache invalid. Make sure there is a directory named ${snpeff_cache_dir} in ${params.snpeff_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } - snpeff_cache = Channel.fromPath("${params.snpeff_cache}/${snpeff_annotation_cache_key}", checkIfExists: true).collect().map{ cache -> [[id:"${params.snpeff_genome}.${params.snpeff_db}"], cache]} + snpeff_cache = Channel.fromPath(file("${params.snpeff_cache}/${snpeff_annotation_cache_key}"), checkIfExists: true).collect() + .map{ cache -> [ [ id:"${params.snpeff_genome}.${params.snpeff_db}" ], cache ] } } else snpeff_cache = [] if (params.vep_cache && params.tools && params.tools.contains("vep")) { def vep_annotation_cache_key = params.use_annotation_cache_keys ? "${params.vep_cache_version}_${params.vep_genome}/" : "" def vep_cache_dir = "${vep_annotation_cache_key}${params.vep_species}/${params.vep_cache_version}_${params.vep_genome}" - def vep_cache_path_full = file("$params.vep_cache", type: 'dir') / vep_cache_dir + def vep_cache_path_full = file("$params.vep_cache/$vep_cache_dir", type: 'dir') if ( !vep_cache_path_full.exists() || !vep_cache_path_full.isDirectory() ) { error("Files within --vep_cache invalid. Make sure there is a directory named ${vep_cache_dir} in ${params.vep_cache}.\nhttps://nf-co.re/sarek/dev/usage#how-to-customise-snpeff-and-vep-annotation") } - vep_cache = Channel.fromPath("${params.vep_cache}/${vep_annotation_cache_key}", checkIfExists: true).collect() + vep_cache = Channel.fromPath(file("${params.vep_cache}/${vep_annotation_cache_key}"), checkIfExists: true).collect() } else vep_cache = [] vep_extra_files = []