From aa064a3762fa8658f198e6e5c8074968e23b906f Mon Sep 17 00:00:00 2001 From: zxBIB Schcolnicov Date: Mon, 30 Sep 2024 19:30:51 +0200 Subject: [PATCH 1/3] Removed untar, updated bowtie_channel --- CHANGELOG.md | 1 + modules.json | 2 +- .../{untarfiles => untar}/environment.yml | 3 +- modules/nf-core/untar/main.nf | 84 +++++ .../nf-core/{untarfiles => untar}/meta.yml | 16 +- modules/nf-core/untar/tests/main.nf.test | 85 +++++ modules/nf-core/untar/tests/main.nf.test.snap | 158 ++++++++ modules/nf-core/untar/tests/tags.yml | 2 + modules/nf-core/untarfiles/main.nf | 60 --- modules/nf-core/untarfiles/tests/main.nf.test | 104 ----- .../untarfiles/tests/main.nf.test.snap | 356 ------------------ subworkflows/local/genome_quant.nf | 2 +- subworkflows/local/prepare_genome/main.nf | 50 ++- 13 files changed, 382 insertions(+), 541 deletions(-) rename modules/nf-core/{untarfiles => untar}/environment.yml (79%) create mode 100644 modules/nf-core/untar/main.nf rename modules/nf-core/{untarfiles => untar}/meta.yml (81%) create mode 100644 modules/nf-core/untar/tests/main.nf.test create mode 100644 modules/nf-core/untar/tests/main.nf.test.snap create mode 100644 modules/nf-core/untar/tests/tags.yml delete mode 100644 modules/nf-core/untarfiles/main.nf delete mode 100644 modules/nf-core/untarfiles/tests/main.nf.test delete mode 100644 modules/nf-core/untarfiles/tests/main.nf.test.snap diff --git a/CHANGELOG.md b/CHANGELOG.md index 40475721..ff0bc3cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [[#443]](https://github.com/nf-core/smrnaseq/pull/443) - Migrate [mirna and genome_quant bowtie to nf-core](https://github.com/nf-core/smrnaseq/issues/436) - Replace local processes with `BOWTIE_ALIGN`. - [[#447]](https://github.com/nf-core/smrnaseq/pull/447) - Fix [Minor fixes and general pipeline cleanup](https://github.com/nf-core/smrnaseq/issues/400) - Update variable and processes names, update channel comments, remove unused modules and params. - [[#448]](https://github.com/nf-core/smrnaseq/pull/448) - Migrate local mirdeep to [nf-core mirdeep2 modules and subworkflow](https://github.com/nf-core/smrnaseq/issues/443) and generate [test profile for mirdeep2](https://github.com/nf-core/smrnaseq/issues/399). +- [[#449]](https://github.com/nf-core/smrnaseq/pull/449) - Fix [Fix ch_bowtie_index channel structure](https://github.com/nf-core/smrnaseq/issues/451) and replace untarfiles with untar [replace untarfiles with untar](https://github.com/nf-core/smrnaseq/issues/449). ## v2.3.1 - 2024-04-18 - Gray Zinc Dalmation Patch diff --git a/modules.json b/modules.json index 5cde8272..cf1fb409 100644 --- a/modules.json +++ b/modules.json @@ -157,7 +157,7 @@ "git_sha": "06c8865e36741e05ad32ef70ab3fac127486af48", "installed_by": ["fastq_fastqc_umitools_fastp", "modules"] }, - "untarfiles": { + "untar": { "branch": "master", "git_sha": "666652151335353eef2fcd58880bcef5bc2928e1", "installed_by": ["modules"] diff --git a/modules/nf-core/untarfiles/environment.yml b/modules/nf-core/untar/environment.yml similarity index 79% rename from modules/nf-core/untarfiles/environment.yml rename to modules/nf-core/untar/environment.yml index 9ed33552..c7794856 100644 --- a/modules/nf-core/untarfiles/environment.yml +++ b/modules/nf-core/untar/environment.yml @@ -1,8 +1,7 @@ channels: - conda-forge - bioconda - dependencies: - - bioconda::grep=3.4 + - conda-forge::grep=3.11 - conda-forge::sed=4.8 - conda-forge::tar=1.34 diff --git a/modules/nf-core/untar/main.nf b/modules/nf-core/untar/main.nf new file mode 100644 index 00000000..9bd8f554 --- /dev/null +++ b/modules/nf-core/untar/main.nf @@ -0,0 +1,84 @@ +process UNTAR { + tag "$archive" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/ubuntu:22.04' : + 'nf-core/ubuntu:22.04' }" + + input: + tuple val(meta), path(archive) + + output: + tuple val(meta), path("$prefix"), emit: untar + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def args2 = task.ext.args2 ?: '' + prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName.toString().replaceFirst(/\.tar$/, "")) + + """ + mkdir $prefix + + ## Ensures --strip-components only applied when top level of tar contents is a directory + ## If just files or multiple directories, place all in prefix + if [[ \$(tar -taf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then + tar \\ + -C $prefix --strip-components 1 \\ + -xavf \\ + $args \\ + $archive \\ + $args2 + else + tar \\ + -C $prefix \\ + -xavf \\ + $args \\ + $archive \\ + $args2 + fi + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//') + END_VERSIONS + """ + + stub: + prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.toString().replaceFirst(/\.[^\.]+(.gz)?$/, "")) + """ + mkdir ${prefix} + ## Dry-run untaring the archive to get the files and place all in prefix + if [[ \$(tar -taf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then + for i in `tar -tf ${archive}`; + do + if [[ \$(echo "\${i}" | grep -E "/\$") == "" ]]; + then + touch \${i} + else + mkdir -p \${i} + fi + done + else + for i in `tar -tf ${archive}`; + do + if [[ \$(echo "\${i}" | grep -E "/\$") == "" ]]; + then + touch ${prefix}/\${i} + else + mkdir -p ${prefix}/\${i} + fi + done + fi + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//') + END_VERSIONS + """ +} diff --git a/modules/nf-core/untarfiles/meta.yml b/modules/nf-core/untar/meta.yml similarity index 81% rename from modules/nf-core/untarfiles/meta.yml rename to modules/nf-core/untar/meta.yml index 1d23eb25..290346b3 100644 --- a/modules/nf-core/untarfiles/meta.yml +++ b/modules/nf-core/untar/meta.yml @@ -1,9 +1,9 @@ -name: untarfiles +name: untar description: Extract files. keywords: - untar - uncompress - - files + - extract tools: - untar: description: | @@ -22,16 +22,16 @@ input: description: File to be untar pattern: "*.{tar}.{gz}" output: - - files: + - untar: - meta: type: map description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - ${prefix}/**: - type: string - description: A list containing references to individual archive files - pattern: "*/**" + - $prefix: + type: directory + description: Directory containing contents of archive + pattern: "*/" - versions: - versions.yml: type: file @@ -42,10 +42,8 @@ authors: - "@drpatelh" - "@matthdsm" - "@jfy133" - - "@pinin4fjords" maintainers: - "@joseespinosa" - "@drpatelh" - "@matthdsm" - "@jfy133" - - "@pinin4fjords" diff --git a/modules/nf-core/untar/tests/main.nf.test b/modules/nf-core/untar/tests/main.nf.test new file mode 100644 index 00000000..c957517a --- /dev/null +++ b/modules/nf-core/untar/tests/main.nf.test @@ -0,0 +1,85 @@ +nextflow_process { + + name "Test Process UNTAR" + script "../main.nf" + process "UNTAR" + tag "modules" + tag "modules_nfcore" + tag "untar" + + test("test_untar") { + + when { + process { + """ + input[0] = [ [], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/kraken2.tar.gz', checkIfExists: true) ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("test_untar_onlyfiles") { + + when { + process { + """ + input[0] = [ [], file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true) ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("test_untar - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ [], file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/kraken2.tar.gz', checkIfExists: true) ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("test_untar_onlyfiles - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ [], file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true) ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } +} diff --git a/modules/nf-core/untar/tests/main.nf.test.snap b/modules/nf-core/untar/tests/main.nf.test.snap new file mode 100644 index 00000000..ceb91b79 --- /dev/null +++ b/modules/nf-core/untar/tests/main.nf.test.snap @@ -0,0 +1,158 @@ +{ + "test_untar_onlyfiles": { + "content": [ + { + "0": [ + [ + [ + + ], + [ + "hello.txt:md5,e59ff97941044f85df5297e1c302d260" + ] + ] + ], + "1": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ], + "untar": [ + [ + [ + + ], + [ + "hello.txt:md5,e59ff97941044f85df5297e1c302d260" + ] + ] + ], + "versions": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-10T12:04:28.231047" + }, + "test_untar_onlyfiles - stub": { + "content": [ + { + "0": [ + [ + [ + + ], + [ + "hello.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ], + "untar": [ + [ + [ + + ], + [ + "hello.txt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-10T12:04:45.773103" + }, + "test_untar - stub": { + "content": [ + { + "0": [ + [ + [ + + ], + [ + "hash.k2d:md5,d41d8cd98f00b204e9800998ecf8427e", + "opts.k2d:md5,d41d8cd98f00b204e9800998ecf8427e", + "taxo.k2d:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ], + "untar": [ + [ + [ + + ], + [ + "hash.k2d:md5,d41d8cd98f00b204e9800998ecf8427e", + "opts.k2d:md5,d41d8cd98f00b204e9800998ecf8427e", + "taxo.k2d:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-10T12:04:36.777441" + }, + "test_untar": { + "content": [ + { + "0": [ + [ + [ + + ], + [ + "hash.k2d:md5,8b8598468f54a7087c203ad0190555d9", + "opts.k2d:md5,a033d00cf6759407010b21700938f543", + "taxo.k2d:md5,094d5891cdccf2f1468088855c214b2c" + ] + ] + ], + "1": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ], + "untar": [ + [ + [ + + ], + [ + "hash.k2d:md5,8b8598468f54a7087c203ad0190555d9", + "opts.k2d:md5,a033d00cf6759407010b21700938f543", + "taxo.k2d:md5,094d5891cdccf2f1468088855c214b2c" + ] + ] + ], + "versions": [ + "versions.yml:md5,6063247258c56fd271d076bb04dd7536" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-10T12:04:19.377674" + } +} \ No newline at end of file diff --git a/modules/nf-core/untar/tests/tags.yml b/modules/nf-core/untar/tests/tags.yml new file mode 100644 index 00000000..feb6f15c --- /dev/null +++ b/modules/nf-core/untar/tests/tags.yml @@ -0,0 +1,2 @@ +untar: + - modules/nf-core/untar/** diff --git a/modules/nf-core/untarfiles/main.nf b/modules/nf-core/untarfiles/main.nf deleted file mode 100644 index bae7838c..00000000 --- a/modules/nf-core/untarfiles/main.nf +++ /dev/null @@ -1,60 +0,0 @@ -def deprecation_message = """ -WARNING: This module has been deprecated. - -Reason: -This module is no longer recommended for use. It is recommended to use nf-core/modules/untar -""" -process UNTARFILES { - tag "$archive" - label 'process_single' - - conda "${moduleDir}/environment.yml" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'oras://community.wave.seqera.io/library/grep_sed_tar:40b34489f8e82876' : - 'community.wave.seqera.io/library/grep_sed_tar:16f6591cd62505b3' }" - - input: - tuple val(meta), path(archive) - - output: - tuple val(meta), path("${prefix}/**") , emit: files - path "versions.yml" , emit: versions - - when: - task.ext.when == null || task.ext.when - - script: - assert true: deprecation_message - def args = task.ext.args ?: '' - def args2 = task.ext.args2 ?: '' - prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName.toString().replaceFirst(/\.tar$/, "")) - - """ - mkdir $prefix - - tar \\ - -C $prefix \\ - -xavf \\ - $args \\ - $archive \\ - $args2 - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//') - END_VERSIONS - """ - - stub: - assert true: deprecation_message - prefix = task.ext.prefix ?: "${meta.id}" - """ - mkdir $prefix - touch ${prefix}/file.txt - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//') - END_VERSIONS - """ -} diff --git a/modules/nf-core/untarfiles/tests/main.nf.test b/modules/nf-core/untarfiles/tests/main.nf.test deleted file mode 100644 index 4e3acf5b..00000000 --- a/modules/nf-core/untarfiles/tests/main.nf.test +++ /dev/null @@ -1,104 +0,0 @@ - -nextflow_process { - - name "Test Process UNTARFILES" - script "../main.nf" - process "UNTARFILES" - - tag "modules" - tag "modules_nfcore" - tag "untarfiles" - - test("test-untarfiles") { - - when { - process { - """ - input[0] = [ - [id: 'test'], - file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/kraken2.tar.gz', checkIfExists: true) - ] - - """ - } - } - - then { - assertAll( - { assert process.success }, - { assert snapshot(process.out).match() } - ) - } - } - - test("test-untarfiles-subdirectories") { - - when { - process { - """ - input[0] = [ - [id: 'test'], - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bcl/flowcell.tar.gz', checkIfExists: true) - ] - - """ - } - } - - then { - assertAll( - { assert process.success }, - { assert snapshot( - process.out.files[0][1].collect { file(it).name }.toSorted(), - process.out.versions - ).match() - } - ) - } - } - - test("test-untarfiles-onlyfiles") { - - when { - process { - """ - input[0] = [ - [id: 'test'], - file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true) - ] - - """ - } - } - - then { - assertAll( - { assert process.success }, - { assert snapshot(process.out).match() } - ) - } - } - - test("test-untarfiles-onlyfiles-stub") { - options '-stub' - when { - process { - """ - input[0] = [ - [id: 'test'], - file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true) - ] - - """ - } - } - - then { - assertAll( - { assert process.success }, - { assert snapshot(process.out).match() } - ) - } - } - -} \ No newline at end of file diff --git a/modules/nf-core/untarfiles/tests/main.nf.test.snap b/modules/nf-core/untarfiles/tests/main.nf.test.snap deleted file mode 100644 index 33452a08..00000000 --- a/modules/nf-core/untarfiles/tests/main.nf.test.snap +++ /dev/null @@ -1,356 +0,0 @@ -{ - "test-untarfiles-onlyfiles-stub": { - "content": [ - { - "0": [ - [ - { - "id": "test" - }, - "file.txt:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "1": [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ], - "files": [ - [ - { - "id": "test" - }, - "file.txt:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "versions": [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ] - } - ], - "meta": { - "nf-test": "0.8.4", - "nextflow": "24.04.4" - }, - "timestamp": "2024-08-29T12:22:11.239416" - }, - "test-untarfiles-subdirectories": { - "content": [ - [ - "ControlMetricsOut.bin", - "CorrectedIntMetricsOut.bin", - "ErrorMetricsOut.bin", - "ExtractionMetricsOut.bin", - "IndexMetricsOut.bin", - "QMetricsOut.bin", - "RTAConfiguration.xml", - "RunInfo.xml", - "TileMetricsOut.bin", - "config.xml", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.bcl", - "s_1_1101.control", - "s_1_1101.filter", - "s_1_1101.locs", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats", - "s_1_1101.stats" - ], - [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ] - ], - "meta": { - "nf-test": "0.9.0", - "nextflow": "24.04.4" - }, - "timestamp": "2024-09-05T15:40:04.563426" - }, - "test-untarfiles": { - "content": [ - { - "0": [ - [ - { - "id": "test" - }, - [ - "hash.k2d:md5,8b8598468f54a7087c203ad0190555d9", - "opts.k2d:md5,a033d00cf6759407010b21700938f543", - "taxo.k2d:md5,094d5891cdccf2f1468088855c214b2c" - ] - ] - ], - "1": [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ], - "files": [ - [ - { - "id": "test" - }, - [ - "hash.k2d:md5,8b8598468f54a7087c203ad0190555d9", - "opts.k2d:md5,a033d00cf6759407010b21700938f543", - "taxo.k2d:md5,094d5891cdccf2f1468088855c214b2c" - ] - ] - ], - "versions": [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ] - } - ], - "meta": { - "nf-test": "0.8.4", - "nextflow": "24.04.4" - }, - "timestamp": "2024-08-29T12:21:44.153411" - }, - "test-untarfiles-onlyfiles": { - "content": [ - { - "0": [ - [ - { - "id": "test" - }, - "hello.txt:md5,e59ff97941044f85df5297e1c302d260" - ] - ], - "1": [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ], - "files": [ - [ - { - "id": "test" - }, - "hello.txt:md5,e59ff97941044f85df5297e1c302d260" - ] - ], - "versions": [ - "versions.yml:md5,4414b00143ed6076881ba7c68ed8b6cf" - ] - } - ], - "meta": { - "nf-test": "0.8.4", - "nextflow": "24.04.4" - }, - "timestamp": "2024-08-29T12:22:06.329486" - } -} diff --git a/subworkflows/local/genome_quant.nf b/subworkflows/local/genome_quant.nf index 93666a2d..4e5181a4 100644 --- a/subworkflows/local/genome_quant.nf +++ b/subworkflows/local/genome_quant.nf @@ -7,7 +7,7 @@ include { BOWTIE_ALIGN as BOWTIE_MAP_GENOME } from '../../modules/nf-core/bowtie workflow GENOME_QUANT { take: - ch_bowtie_index // channel: [ val(meta), [ path(directory_index) ] ] + ch_bowtie_index // channel: [ val(meta), path(directory_index) ] ch_fasta // channel: [ val(meta), path(fasta) ] ch_reads // channel: [ val(meta), [ reads ] ] diff --git a/subworkflows/local/prepare_genome/main.nf b/subworkflows/local/prepare_genome/main.nf index c752a79b..be6d75b5 100644 --- a/subworkflows/local/prepare_genome/main.nf +++ b/subworkflows/local/prepare_genome/main.nf @@ -3,10 +3,37 @@ // // nf-core modules -include { UNTARFILES as UNTAR_BOWTIE_INDEX } from '../../../modules/nf-core/untarfiles' +include { UNTAR as UNTAR_BOWTIE_INDEX } from '../../../modules/nf-core/untar' include { BOWTIE_BUILD as INDEX_GENOME } from '../../../modules/nf-core/bowtie/build/main' include { BIOAWK as CLEAN_FASTA } from '../../../modules/nf-core/bioawk/main' +/* +======================================================================================== + FUNCTIONS +======================================================================================== +*/ +// +// Extract prefix from bowtie index files +// +def extractFirstIndexPrefix(files_path) { + def files = files_path.listFiles() + if (files == null || files.length == 0) { + throw new Exception("The provided bowtie_index path doesn't contain any files.") + } + def index_prefix = '' + for (file_path in files) { + def file_name = file_path.getName() + if (file_name.endsWith(".1.ebwt") && !file_name.endsWith(".rev.1.ebwt")) { + index_prefix = file_name.substring(0, file_name.lastIndexOf(".1.ebwt")) + break + } + } + if (index_prefix == '') { + throw new Exception("Unable to extract the prefix from the Bowtie index files. No file with the '.1.ebwt' extension was found. Please ensure that the correct files are in the specified path.") + } + return index_prefix +} + workflow PREPARE_GENOME { take: @@ -26,8 +53,8 @@ workflow PREPARE_GENOME { ch_versions = Channel.empty() // Parameter channel handling - ch_fasta = val_fasta ? Channel.fromPath(val_fasta, checkIfExists: true).map{ it -> [ [id:it.baseName], it ] }.collect() : Channel.empty() - ch_bowtie_index = val_bowtie_index ? Channel.fromPath(val_bowtie_index, checkIfExists: true).map{ it -> [ [], it ] }.collect() : Channel.empty() + ch_fasta = val_fasta ? Channel.fromPath(val_fasta, checkIfExists: true).map{ it -> [ [id:it.baseName], it ] }.collect() : Channel.empty() + ch_bowtie_index = val_bowtie_index ? Channel.fromPath(val_bowtie_index, checkIfExists: true).map{ it -> [ [id:""], it ] }.collect() : Channel.empty() bool_mirtrace_species = val_mirtrace_species ? true : false bool_has_fasta = val_fasta ? true : false @@ -52,13 +79,20 @@ workflow PREPARE_GENOME { if(val_bowtie_index) { if (val_bowtie_index.endsWith(".tar.gz")) { UNTAR_BOWTIE_INDEX ( ch_bowtie_index ) - ch_bowtie_index = UNTAR_BOWTIE_INDEX.out.files + ch_bowtie_index = UNTAR_BOWTIE_INDEX.out.untar + .map{ meta, index_dir -> + def index_prefix = extractFirstIndexPrefix(index_dir) + [[id:index_prefix], index_dir] + } ch_versions = ch_versions.mix(UNTAR_BOWTIE_INDEX.out.versions) } else { - ch_bowtie_index = Channel.fromPath("${val_bowtie_index}**ebwt", checkIfExists: true).map{it -> [ [id:it.baseName], it ] }.collect() - .ifEmpty{ error "Bowtie1 index directory not found: ${val_bowtie_index}" } - .filter { it != null } + ch_bowtie_index = Channel.fromPath(val_bowtie_index, checkIfExists: true) + .map{it -> + def index_prefix = extractFirstIndexPrefix(it) + [[id:index_prefix], it] + } } + } else { // Clean fasta (replace non-ATCGs with Ns, remove whitespaces from headers) CLEAN_FASTA ( ch_fasta ) @@ -96,7 +130,7 @@ workflow PREPARE_GENOME { emit: fasta = ch_fasta // channel: [ val(meta), path(fasta) ] has_fasta = bool_has_fasta // boolean - bowtie_index = ch_bowtie_index // channel: [ val(meta), [ path(directory_index) ] ] + bowtie_index = ch_bowtie_index // channel: [ val(meta), path(directory_index) ] versions = ch_versions // channel: [ versions.yml ] mirtrace_species = ch_mirtrace_species // channel: [ val(string) ] has_mirtrace_species = bool_mirtrace_species // boolean From ff8e2af3d022093f7e3e52b1a8d15897cc01f904 Mon Sep 17 00:00:00 2001 From: nschcolnicov Date: Tue, 1 Oct 2024 11:19:40 +0000 Subject: [PATCH 2/3] Update untar module config --- conf/modules.config | 2 +- subworkflows/local/prepare_genome/main.nf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index d092448c..7c3ecd98 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -42,7 +42,7 @@ process { ] } - withName: 'UNTAR' { + withName: '.*:PREPARE_GENOME:UNTAR_BOWTIE_INDEX' { publishDir = [ mode: params.publish_dir_mode, enabled: params.save_intermediates, diff --git a/subworkflows/local/prepare_genome/main.nf b/subworkflows/local/prepare_genome/main.nf index be6d75b5..9dc2be02 100644 --- a/subworkflows/local/prepare_genome/main.nf +++ b/subworkflows/local/prepare_genome/main.nf @@ -80,7 +80,7 @@ workflow PREPARE_GENOME { if (val_bowtie_index.endsWith(".tar.gz")) { UNTAR_BOWTIE_INDEX ( ch_bowtie_index ) ch_bowtie_index = UNTAR_BOWTIE_INDEX.out.untar - .map{ meta, index_dir -> + .map{ meta, index_dir -> def index_prefix = extractFirstIndexPrefix(index_dir) [[id:index_prefix], index_dir] } From b79dccb5f4b3a0563756f707b2e7766f09c3c6b1 Mon Sep 17 00:00:00 2001 From: nschcolnicov Date: Tue, 1 Oct 2024 11:47:42 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0bc3cd..71891856 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [[#443]](https://github.com/nf-core/smrnaseq/pull/443) - Migrate [mirna and genome_quant bowtie to nf-core](https://github.com/nf-core/smrnaseq/issues/436) - Replace local processes with `BOWTIE_ALIGN`. - [[#447]](https://github.com/nf-core/smrnaseq/pull/447) - Fix [Minor fixes and general pipeline cleanup](https://github.com/nf-core/smrnaseq/issues/400) - Update variable and processes names, update channel comments, remove unused modules and params. - [[#448]](https://github.com/nf-core/smrnaseq/pull/448) - Migrate local mirdeep to [nf-core mirdeep2 modules and subworkflow](https://github.com/nf-core/smrnaseq/issues/443) and generate [test profile for mirdeep2](https://github.com/nf-core/smrnaseq/issues/399). -- [[#449]](https://github.com/nf-core/smrnaseq/pull/449) - Fix [Fix ch_bowtie_index channel structure](https://github.com/nf-core/smrnaseq/issues/451) and replace untarfiles with untar [replace untarfiles with untar](https://github.com/nf-core/smrnaseq/issues/449). +- [[#452]](https://github.com/nf-core/smrnaseq/pull/452) - Fix [Fix ch_bowtie_index channel structure](https://github.com/nf-core/smrnaseq/issues/451) and replace untarfiles with untar [replace untarfiles with untar](https://github.com/nf-core/smrnaseq/issues/449). ## v2.3.1 - 2024-04-18 - Gray Zinc Dalmation Patch