From 9fd06ddff3326eb1cd4e61db88c92feca95df106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Vitor?= Date: Tue, 23 Jan 2024 15:56:05 -0300 Subject: [PATCH] refactor: Remove old unused nf-core functions (#182) * refactor: Remove unused nf-core functions Signed-off-by: jvfe * fix: Remove missing functions in RGI module Signed-off-by: jvfe --------- Signed-off-by: jvfe --- modules.json | 94 +++++++++++++++++++------- modules/local/functions.nf | 68 ------------------- modules/local/get_minikraken.nf | 30 -------- modules/local/get_software_versions.nf | 9 --- modules/local/mobsuite.nf | 4 +- modules/local/rgi.nf | 15 +--- modules/local/samplesheet_check.nf | 17 +---- 7 files changed, 76 insertions(+), 161 deletions(-) delete mode 100644 modules/local/functions.nf diff --git a/modules.json b/modules.json index 2dc4a937..1f54e6ae 100644 --- a/modules.json +++ b/modules.json @@ -8,137 +8,183 @@ "bakta/bakta": { "branch": "master", "git_sha": "280c5c86b3da7dfcc92ebd5420584dd6ff26c4a8", - "installed_by": ["modules"] + "installed_by": [ + "modules" + ] }, "bakta/baktadbdownload": { "branch": "master", "git_sha": "280c5c86b3da7dfcc92ebd5420584dd6ff26c4a8", - "installed_by": ["modules"] + "installed_by": [ + "modules" + ] }, "blast/blastn": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/blast/blastn/blast-blastn.diff" }, "blast/makeblastdb": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/blast/makeblastdb/blast-makeblastdb.diff" }, "checkm/lineagewf": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/checkm/lineagewf/checkm-lineagewf.diff" }, "custom/dumpsoftwareversions": { "branch": "master", "git_sha": "05c280924b6c768d484c7c443dad5e605c4ff4b4", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/custom/dumpsoftwareversions/custom-dumpsoftwareversions.diff" }, "diamond/blastp": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/diamond/blastp/diamond-blastp.diff" }, "diamond/blastx": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/diamond/blastx/diamond-blastx.diff" }, "diamond/makedb": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/diamond/makedb/diamond-makedb.diff" }, "fastp": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/fastp/fastp.diff" }, "fastqc": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/fastqc/fastqc.diff" }, "fasttree": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/fasttree/fasttree.diff" }, "gubbins": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/gubbins/gubbins.diff" }, "iqtree": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/iqtree/iqtree.diff" }, "kraken2/kraken2": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/kraken2/kraken2/kraken2-kraken2.diff" }, "mafft": { "branch": "master", "git_sha": "b265b4ff6a35b133b963b4eaddfca0ffb3395236", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/mafft/mafft.diff" }, "multiqc": { "branch": "master", "git_sha": "ee80d14721e76e2e079103b8dcd5d57129e584ba", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/multiqc/multiqc.diff" }, "panaroo/run": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/panaroo/run/panaroo-run.diff" }, "phispy": { "branch": "master", "git_sha": "a60792caf1782dd570ad7a091b61806c592734d7", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/phispy/phispy.diff" }, "prokka": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/prokka/prokka.diff" }, "quast": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/quast/quast.diff" }, "snpsites": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/snpsites/snpsites.diff" }, "unicycler": { "branch": "master", "git_sha": "c8e35eb2055c099720a75538d1b8adb3fb5a464c", - "installed_by": ["modules"], + "installed_by": [ + "modules" + ], "patch": "modules/nf-core/unicycler/unicycler.diff" } } @@ -148,4 +194,4 @@ } } } -} +} \ No newline at end of file diff --git a/modules/local/functions.nf b/modules/local/functions.nf deleted file mode 100644 index da9da093..00000000 --- a/modules/local/functions.nf +++ /dev/null @@ -1,68 +0,0 @@ -// -// Utility functions used in nf-core DSL2 module files -// - -// -// Extract name of software tool from process name using $task.process -// -def getSoftwareName(task_process) { - return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase() -} - -// -// Function to initialise default values and to generate a Groovy Map of available options for nf-core modules -// -def initOptions(Map args) { - def Map options = [:] - options.args = args.args ?: '' - options.args2 = args.args2 ?: '' - options.args3 = args.args3 ?: '' - options.publish_by_meta = args.publish_by_meta ?: [] - options.publish_dir = args.publish_dir ?: '' - options.publish_files = args.publish_files - options.suffix = args.suffix ?: '' - return options -} - -// -// Tidy up and join elements of a list to return a path string -// -def getPathFromList(path_list) { - def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries - paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes - return paths.join('/') -} - -// -// Function to save/publish module results -// -def saveFiles(Map args) { - if (!args.filename.endsWith('.version.txt')) { - def ioptions = initOptions(args.options) - def path_list = [ ioptions.publish_dir ?: args.publish_dir ] - if (ioptions.publish_by_meta) { - def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta - for (key in key_list) { - if (args.meta && key instanceof String) { - def path = key - if (args.meta.containsKey(key)) { - path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key] - } - path = path instanceof String ? path : '' - path_list.add(path) - } - } - } - if (ioptions.publish_files instanceof Map) { - for (ext in ioptions.publish_files) { - if (args.filename.endsWith(ext.key)) { - def ext_list = path_list.collect() - ext_list.add(ext.value) - return "${getPathFromList(ext_list)}/$args.filename" - } - } - } else if (ioptions.publish_files == null) { - return "${getPathFromList(path_list)}/$args.filename" - } - } -} diff --git a/modules/local/get_minikraken.nf b/modules/local/get_minikraken.nf index cd2d5466..23a6cc7f 100644 --- a/modules/local/get_minikraken.nf +++ b/modules/local/get_minikraken.nf @@ -1,12 +1,4 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -params.options = [:] -options = initOptions(params.options) - process KRAKEN2_DB { - //publishDir 'dbcache/', mode:'copy' - tag "minikraken" label 'process_medium' label 'error_retry_delay' @@ -19,26 +11,4 @@ process KRAKEN2_DB { mkdir -p k2_standard_8gb_20201202 tar xvf k2_standard_8gb_20201202.tar.gz -C k2_standard_8gb_20201202 """ - // stub: - /* - minikraken = file("./dbcache/k2_standard_8gb_20201202") - if (!minikraken.exists()){ - println "FARRRRT" - """ - curl https://genome-idx.s3.amazonaws.com/kraken/k2_standard_8gb_20201202.tar.gz --output k2_standard_8gb_20201202.tar.gz - mkdir -p k2_standard_8gb_20201202 - tar xvf k2_standard_8gb_20201202.tar.gz -C k2_standard_8gb_20201202 - """ - } - else{ - """ - echo "database is cached" - """ - } - */ - // else{ - // """ - // ln -s ${minikraken} . - // """ - // } } diff --git a/modules/local/get_software_versions.nf b/modules/local/get_software_versions.nf index d7a22f2f..2a1f003e 100644 --- a/modules/local/get_software_versions.nf +++ b/modules/local/get_software_versions.nf @@ -1,13 +1,4 @@ -// Import generic module functions -include { saveFiles } from './functions' - -params.options = [:] - process GET_SOFTWARE_VERSIONS { - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'pipeline_info', meta:[:], publish_by_meta:[]) } - conda (params.enable_conda ? "conda-forge::python=3.8.3" : null) if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { container "https://depot.galaxyproject.org/singularity/python:3.8.3" diff --git a/modules/local/mobsuite.nf b/modules/local/mobsuite.nf index 5275b6c9..0301cd13 100644 --- a/modules/local/mobsuite.nf +++ b/modules/local/mobsuite.nf @@ -1,4 +1,3 @@ -// Import generic module functions process MOB_RECON { tag "$meta.id" label 'process_low' @@ -12,7 +11,6 @@ process MOB_RECON { input: tuple val(meta), path(fasta) - //path mob_db output: tuple val(meta), path("${meta.id}_mob_recon") , emit: mob_predictions @@ -33,7 +31,7 @@ process MOB_RECON { mobsuite: \$(echo \$(mob_recon --version 2>&1) | sed 's/^.*mob_recon //; s/ .*\$//') END_VERSIONS """ - //--database_directory $mob_db \\ + stub: """ mkdir ${meta.id}_mob_recon diff --git a/modules/local/rgi.nf b/modules/local/rgi.nf index ca17ac93..8f23c6e4 100755 --- a/modules/local/rgi.nf +++ b/modules/local/rgi.nf @@ -1,9 +1,3 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -params.options = [:] -options = initOptions(params.options) - process UPDATE_RGI_DB { tag "CARD" label 'process_low' @@ -36,9 +30,6 @@ process UPDATE_RGI_DB { process RGI { tag "$meta.id" label 'process_low' - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) } conda (params.enable_conda ? "bioconda::rgi=6.0.2" : null) if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { @@ -57,8 +48,7 @@ process RGI { path "versions.yml", emit: version script: - def software = getSoftwareName(task.process) - def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + def prefix = task.ext.prefix ? "${meta.id}${options.suffix}" : "${meta.id}" """ rgi load -i $card_db --local @@ -70,8 +60,7 @@ process RGI { END_VERSIONS """ stub: - def software = getSoftwareName(task.process) - def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + def prefix = task.ext.prefix ? "${meta.id}${options.suffix}" : "${meta.id}" """ touch ${prefix}_rgi.txt cat <<-END_VERSIONS > versions.yml diff --git a/modules/local/samplesheet_check.nf b/modules/local/samplesheet_check.nf index 61885101..20542d9d 100644 --- a/modules/local/samplesheet_check.nf +++ b/modules/local/samplesheet_check.nf @@ -1,13 +1,5 @@ -// Import generic module functions -include { saveFiles } from './functions' - -params.options = [:] - process SAMPLESHEET_CHECK { tag "$samplesheet" - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'pipeline_info', meta:[:], publish_by_meta:[]) } conda (params.enable_conda ? "conda-forge::python=3.8.3" : null) if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { @@ -22,7 +14,7 @@ process SAMPLESHEET_CHECK { output: path '*.csv' - script: // This script is bundled with the pipeline, in nf-core/arete/bin/ + script: """ check_samplesheet.py \\ $samplesheet \\ @@ -32,9 +24,6 @@ process SAMPLESHEET_CHECK { process ASSEMBLYSHEET_CHECK { tag "$assemblysheet" - publishDir "${params.outdir}", - mode: params.publish_dir_mode, - saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'pipeline_info', publish_id:'') } conda (params.enable_conda ? "conda-forge::python=3.8.3" : null) if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { @@ -49,7 +38,7 @@ process ASSEMBLYSHEET_CHECK { output: path '*.csv' - script: // This script is bundled with the pipeline, in arete/bin/ + script: """ check_assembly_samplesheet.py $assemblysheet assemblysheet.valid.csv """ @@ -74,7 +63,7 @@ process PHYLOSHEET_CHECK { output: path '*.csv' - script: // This script is bundled with the pipeline, in arete/bin/ + script: """ check_phylo_samplesheet.py $phylosheet phylosheet.valid.csv """