diff --git a/modules/nf-core/sratools/fasterqdump/main.nf b/modules/nf-core/sratools/fasterqdump/main.nf index d4ddf26896c..d5b65bab270 100644 --- a/modules/nf-core/sratools/fasterqdump/main.nf +++ b/modules/nf-core/sratools/fasterqdump/main.nf @@ -23,7 +23,10 @@ process SRATOOLS_FASTERQDUMP { def args = task.ext.args ?: '' def args2 = task.ext.args2 ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def outfile = meta.single_end ? "${prefix}.fastq" : prefix + def outfile = "${prefix}.fastq" + def exclude_third = meta.single_end ? '' : "mv $outfile $prefix || echo 'No third file'" + // Excludes the "${prefix}.fastq" file from output `reads` channel for paired end cases and + // avoids the '.' in the path bug: https://github.com/ncbi/sra-tools/issues/865 def key_file = '' if (certificate.toString().endsWith('.jwt')) { key_file += " --perm ${certificate}" @@ -40,6 +43,51 @@ process SRATOOLS_FASTERQDUMP { ${key_file} \\ ${sra} + $exclude_third + + pigz \\ + $args2 \\ + --no-name \\ + --processes $task.cpus \\ + *.fastq + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sratools: \$(fasterq-dump --version 2>&1 | grep -Eo '[0-9.]+') + pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def args2 = task.ext.args2 ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def outfile = "${prefix}.fastq" + def exclude_third = meta.single_end ? '' : "mv $outfile $prefix || echo 'No third file'" + // Excludes the "${prefix}.fastq" file from output `reads` channel for paired end cases and + // avoids the '.' in the path bug: https://github.com/ncbi/sra-tools/issues/865 + def key_file = '' + if (certificate.toString().endsWith('.jwt')) { + key_file += " --perm ${certificate}" + } else if (certificate.toString().endsWith('.ngc')) { + key_file += " --ngc ${certificate}" + } + def touch_outfiles = meta.single_end ? "${prefix}.fastq" : "${prefix}_1.fastq ${prefix}_2.fastq" + """ + touch $touch_outfiles + + export NCBI_SETTINGS="\$PWD/${ncbi_settings}" + + echo \\ + "fasterq-dump \\ + $args \\ + --threads $task.cpus \\ + --outfile $outfile \\ + ${key_file} \\ + ${sra}" + + $exclude_third + pigz \\ $args2 \\ --no-name \\ diff --git a/modules/nf-core/sratools/fasterqdump/meta.yml b/modules/nf-core/sratools/fasterqdump/meta.yml index b5e0175a1cf..6a2151a87a2 100644 --- a/modules/nf-core/sratools/fasterqdump/meta.yml +++ b/modules/nf-core/sratools/fasterqdump/meta.yml @@ -51,3 +51,4 @@ authors: - "@Midnighter" maintainers: - "@Midnighter" + - "@gallvp" diff --git a/modules/nf-core/sratools/fasterqdump/tests/main.nf.test b/modules/nf-core/sratools/fasterqdump/tests/main.nf.test index cb81496f079..6996cd18a14 100644 --- a/modules/nf-core/sratools/fasterqdump/tests/main.nf.test +++ b/modules/nf-core/sratools/fasterqdump/tests/main.nf.test @@ -1,7 +1,6 @@ nextflow_process { name "Test Process SRATOOLS_FASTERQDUMP" script "../main.nf" - config "./nextflow.config" process "SRATOOLS_FASTERQDUMP" tag "modules" tag "modules_nfcore" @@ -70,4 +69,54 @@ nextflow_process { ) } } + + test("Single-end-stub") { + + options '-stub' + + when { + process { + """ + input[0] = [ + [ id:'test_single_end', single_end:true ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/sra/SRR13255544.tar.gz', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'generic/config/ncbi_user_settings.mkfg', checkIfExists: true) + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("Paired-end-stub") { + + options '-stub' + + when { + process { + """ + input[0] = [ + [ id:'test_paired_end', single_end:false ], + file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/sra/SRR11140744.tar.gz', checkIfExists: true) + ] + input[1] = file(params.modules_testdata_base_path + 'generic/config/ncbi_user_settings.mkfg', checkIfExists: true) + input[2] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } } diff --git a/modules/nf-core/sratools/fasterqdump/tests/main.nf.test.snap b/modules/nf-core/sratools/fasterqdump/tests/main.nf.test.snap index 14a6429df31..5d0c3e7c5a4 100644 --- a/modules/nf-core/sratools/fasterqdump/tests/main.nf.test.snap +++ b/modules/nf-core/sratools/fasterqdump/tests/main.nf.test.snap @@ -30,9 +30,44 @@ ], "meta": { "nf-test": "0.8.4", - "nextflow": "24.01.0" + "nextflow": "23.10.1" }, - "timestamp": "2024-02-28T15:25:52.837288" + "timestamp": "2024-05-17T22:01:43.486256" + }, + "Single-end-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test_single_end", + "single_end": true + }, + "test_single_end.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,a3d61a9761e1606ef8459f0b68821d7a" + ], + "reads": [ + [ + { + "id": "test_single_end", + "single_end": true + }, + "test_single_end.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,a3d61a9761e1606ef8459f0b68821d7a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-17T21:40:42.335786" }, "Paired-end": { "content": [ @@ -71,8 +106,49 @@ ], "meta": { "nf-test": "0.8.4", - "nextflow": "24.01.0" + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-17T22:09:55.6396" + }, + "Paired-end-stub": { + "content": [ + { + "0": [ + [ + { + "id": "test_paired_end", + "single_end": false + }, + [ + "test_paired_end_1.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e", + "test_paired_end_2.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + "versions.yml:md5,a3d61a9761e1606ef8459f0b68821d7a" + ], + "reads": [ + [ + { + "id": "test_paired_end", + "single_end": false + }, + [ + "test_paired_end_1.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e", + "test_paired_end_2.fastq.gz:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,a3d61a9761e1606ef8459f0b68821d7a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" }, - "timestamp": "2024-02-28T15:26:42.466223" + "timestamp": "2024-05-17T20:35:44.782058" } } \ No newline at end of file diff --git a/modules/nf-core/sratools/fasterqdump/tests/nextflow.config b/modules/nf-core/sratools/fasterqdump/tests/nextflow.config deleted file mode 100644 index 23e4100b8a0..00000000000 --- a/modules/nf-core/sratools/fasterqdump/tests/nextflow.config +++ /dev/null @@ -1,5 +0,0 @@ -process { - withName: SRATOOLS_FASTERQDUMP { - ext.args = '' - } -} \ No newline at end of file diff --git a/modules/nf-core/sratools/prefetch/main.nf b/modules/nf-core/sratools/prefetch/main.nf index 170f1753fba..46e7cb3faa1 100644 --- a/modules/nf-core/sratools/prefetch/main.nf +++ b/modules/nf-core/sratools/prefetch/main.nf @@ -32,4 +32,16 @@ process SRATOOLS_PREFETCH { } template 'retry_with_backoff.sh' + + stub: + """ + mkdir $id + touch $id/${id}.sra + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sratools: \$(prefetch --version 2>&1 | grep -Eo '[0-9.]+') + curl: \$(curl --version | head -n 1 | sed 's/^curl //; s/ .*\$//') + END_VERSIONS + """ } diff --git a/modules/nf-core/sratools/prefetch/meta.yml b/modules/nf-core/sratools/prefetch/meta.yml index ff54229f42c..7ed42d49983 100644 --- a/modules/nf-core/sratools/prefetch/meta.yml +++ b/modules/nf-core/sratools/prefetch/meta.yml @@ -54,3 +54,4 @@ authors: - "@Midnighter" maintainers: - "@Midnighter" + - "@gallvp" diff --git a/modules/nf-core/sratools/prefetch/tests/main.nf.test b/modules/nf-core/sratools/prefetch/tests/main.nf.test index f59de7cbbc4..92034d40fce 100644 --- a/modules/nf-core/sratools/prefetch/tests/main.nf.test +++ b/modules/nf-core/sratools/prefetch/tests/main.nf.test @@ -46,4 +46,26 @@ nextflow_process { ) } } + + test("sratools/prefetch/stub") { + + options '-stub' + + when { + process { + """ + input[0] = Channel.of([ [ id:'test', single_end:false ], 'DRR000774' ]) + input[1] = file(params.modules_testdata_base_path + 'generic/config/ncbi_user_settings.mkfg', checkIfExists: true) + input[2] = [] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } } diff --git a/modules/nf-core/sratools/prefetch/tests/main.nf.test.snap b/modules/nf-core/sratools/prefetch/tests/main.nf.test.snap index 67795ebbcd7..82a1969c41a 100644 --- a/modules/nf-core/sratools/prefetch/tests/main.nf.test.snap +++ b/modules/nf-core/sratools/prefetch/tests/main.nf.test.snap @@ -1,4 +1,43 @@ { + "sratools/prefetch/stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "DRR000774.sra:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + "versions.yml:md5,83d1b23f5ff5b2ad1b96d17d7d7594ee" + ], + "sra": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "DRR000774.sra:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions": [ + "versions.yml:md5,83d1b23f5ff5b2ad1b96d17d7d7594ee" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-05-17T20:07:31.627115" + }, "sratools/prefetch with sralite": { "content": [ { @@ -77,4 +116,4 @@ }, "timestamp": "2024-02-28T11:48:37.428307" } -} +} \ No newline at end of file