diff --git a/modules/nf-core/gzrt/environment.yml b/modules/nf-core/gzrt/environment.yml index 7ce5686f8dc..92cec669a77 100644 --- a/modules/nf-core/gzrt/environment.yml +++ b/modules/nf-core/gzrt/environment.yml @@ -3,4 +3,4 @@ channels: - conda-forge - bioconda dependencies: - - "bioconda::gzrt=0.8" + - "bioconda::gzrt=0.9.1" diff --git a/modules/nf-core/gzrt/main.nf b/modules/nf-core/gzrt/main.nf index 3d72f9ad05a..a8c398ec652 100644 --- a/modules/nf-core/gzrt/main.nf +++ b/modules/nf-core/gzrt/main.nf @@ -4,28 +4,52 @@ process GZRT { conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/gzrt:0.8--he4a0461_0': - 'biocontainers/gzrt:0.8--he4a0461_0' }" + 'https://depot.galaxyproject.org/singularity/gzrt:0.9.1--h577a1d6_1': + 'biocontainers/gzrt:0.9.1--h577a1d6_1' }" input: tuple val(meta), path(fastqgz) output: - tuple val(meta), path("*_recovered.fastq.gz"), emit: fastqrecovered - path "versions.yml" , emit: versions + tuple val(meta), path("${prefix}*.fastq.gz"), emit: recovered + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when script: - if (fastqgz.extension != "gz") { - error "GZRT works with .gz files only." + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}_recovered" + fastqgz.each { file -> + if (file.extension != "gz") { + error "GZRT works with .gz files only. Offending file: ${file}" + } + + if ((meta.single_end && "${file}" == "${prefix}.fastq.gz") || + (!meta.single_end && ("${file}" == "${prefix}_1.fastq.gz" || "${file}" == "${prefix}_2.fastq.gz"))) { + error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + } } - def prefix = task.ext.prefix ?: "${meta.id}" """ - gzrecover -o ${prefix}_recovered.fastq ${fastqgz} - gzip ${prefix}_recovered.fastq + if [ "$meta.single_end" == true ]; then + gzrecover ${args} -p ${fastqgz} | gzip > ${prefix}.fastq.gz + + if [ -e "${prefix}.fastq.gz" ] && [ ! -s "${prefix}.fastq.gz" ]; then + echo "" | gzip > ${prefix}.fastq.gz + fi + else + gzrecover ${args} -p ${fastqgz[0]} | gzip > ${prefix}_1.fastq.gz + gzrecover ${args} -p ${fastqgz[1]} | gzip > ${prefix}_2.fastq.gz + + if [ -e "${prefix}_1.fastq.gz" ] && [ ! -s "${prefix}_1.fastq.gz" ]; then + echo "" | gzip > ${prefix}_1.fastq.gz + fi + + if [ -e "${prefix}_2.fastq.gz" ] && [ ! -s "${prefix}_2.fastq.gz" ]; then + echo "" | gzip > ${prefix}_2.fastq.gz + fi + fi soft_line="${task.process}" ver_line="gzrt: \$(gzrecover -V |& sed '1!d ; s/gzrecover //')" @@ -36,13 +60,27 @@ process GZRT { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" + prefix = task.ext.prefix ?: "${meta.id}_recovered" + fastqgz.each { file -> + if (file.extension != "gz") { + error "GZRT works with .gz files only. Offending file: ${file}" + } + + if ((meta.single_end && "${file}" == "${prefix}.fastq.gz") || + (!meta.single_end && ("${file}" == "${prefix}_1.fastq.gz" || "${file}" == "${prefix}_2.fastq.gz"))) { + error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + } + } """ - echo "" | gzip > ${prefix}_recovered.fastq.gz + if [ "$meta.single_end" == true ]; then + echo "" | gzip > ${prefix}.fastq.gz + else + echo "" | gzip > ${prefix}_1.fastq.gz + echo "" | gzip > ${prefix}_2.fastq.gz + fi soft_line="${task.process}" ver_line="gzrt: \$(gzrecover -V |& sed '1!d ; s/gzrecover //')" - cat <<-END_VERSIONS > versions.yml "\${soft_line}": \${ver_line} diff --git a/modules/nf-core/gzrt/meta.yml b/modules/nf-core/gzrt/meta.yml index 9c9da273823..5bc42cf44b0 100644 --- a/modules/nf-core/gzrt/meta.yml +++ b/modules/nf-core/gzrt/meta.yml @@ -23,21 +23,21 @@ input: - fastqgz: type: file - description: FASTQ.gz file + description: FASTQ.gz files pattern: "*.{gz}" ontologies: - edam: "http://edamontology.org/format_3989" output: - - fastqrecovered: + - recovered: - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'sample1', single_end:false ]` - - "*_recovered.fastq.gz": + - "${prefix}*.fastq.gz": type: file - description: Recovered FASTQ.gz file + description: Recovered FASTQ.gz files pattern: "*.{gz}" ontologies: - edam: "http://edamontology.org/format_3989" diff --git a/modules/nf-core/gzrt/tests/main.nf.test b/modules/nf-core/gzrt/tests/main.nf.test index bd4bbb95825..71a2a9ae03b 100644 --- a/modules/nf-core/gzrt/tests/main.nf.test +++ b/modules/nf-core/gzrt/tests/main.nf.test @@ -8,42 +8,87 @@ nextflow_process { tag "modules_nfcore" tag "gzrt" - test("Run gzrt on 30 paired-end reads - fastq.gz") { - + test("Run gzrt on test2_1_corrupted single-end - fastq.gz") { when { process { """ - input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test_corrupted_30reads_R1.fastq.gz', checkIfExists: true) + input[0] = + [ + [ id:'test-single', single_end:true ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test2_1_corrupted_10kb.fastq.gz', checkIfExists: true) ] """ } } - then { assertAll( { assert process.success }, { assert snapshot(process.out).match() } ) } + } + test("Run gzrt on test2_1_corrupted and test2_2 paired-end - fastq.gz") { + when { + process { + """ + input[0] = + [ + [ id:'test-paired', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test2_1_corrupted_10kb.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test2_2.fastq.gz', checkIfExists: true) + ] + ] + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } } - test("Run gzrt on 30 paired-end reads - fastq.gz - stub") { + test("Run gzrt on test2_1_corrupted single-end - fastq.gz - stub") { options "-stub" when { process { """ input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test_corrupted_30reads_R1.fastq.gz', checkIfExists: true) + [ id:'test-single-stub', single_end:true ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test2_1_corrupted_10kb.fastq.gz', checkIfExists: true) ] """ } } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("Run gzrt on test2_1_corrupted and test2_2 paired-end - fastq.gz - stub") { + options "-stub" + when { + process { + """ + input[0] = + [ + [ id:'test-paired-stub', single_end:false ], // meta map + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test2_1_corrupted_10kb.fastq.gz', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test2_2.fastq.gz', checkIfExists: true) + ] + ] + """ + } + } then { assertAll( { assert process.success }, diff --git a/modules/nf-core/gzrt/tests/main.nf.test.snap b/modules/nf-core/gzrt/tests/main.nf.test.snap index 2d57f1983c3..cd4c1c225d1 100644 --- a/modules/nf-core/gzrt/tests/main.nf.test.snap +++ b/modules/nf-core/gzrt/tests/main.nf.test.snap @@ -1,72 +1,154 @@ { - "Run gzrt on 30 paired-end reads - fastq.gz": { + "Run gzrt on test2_1_corrupted single-end - fastq.gz": { "content": [ { "0": [ [ { - "id": "test", + "id": "test-single", + "single_end": true + }, + "test-single_recovered.fastq.gz:md5,6bc7d0b6304039eadba7321d21e7b2c9" + ] + ], + "1": [ + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" + ], + "recovered": [ + [ + { + "id": "test-single", + "single_end": true + }, + "test-single_recovered.fastq.gz:md5,6bc7d0b6304039eadba7321d21e7b2c9" + ] + ], + "versions": [ + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-24T11:23:22.53088" + }, + "Run gzrt on test2_1_corrupted single-end - fastq.gz - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test-single-stub", + "single_end": true + }, + "test-single-stub_recovered.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "1": [ + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" + ], + "recovered": [ + [ + { + "id": "test-single-stub", + "single_end": true + }, + "test-single-stub_recovered.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions": [ + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-24T11:24:13.88887" + }, + "Run gzrt on test2_1_corrupted and test2_2 paired-end - fastq.gz - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test-paired-stub", "single_end": false }, - "test_recovered.fastq.gz:md5,5eca10f954656478b5af96868222eec4" + [ + "test-paired-stub_recovered_1.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test-paired-stub_recovered_2.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] ] ], "1": [ - "versions.yml:md5,b9467d4cb860eb2941a2078a3dd3cf41" + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" ], - "fastqrecovered": [ + "recovered": [ [ { - "id": "test", + "id": "test-paired-stub", "single_end": false }, - "test_recovered.fastq.gz:md5,5eca10f954656478b5af96868222eec4" + [ + "test-paired-stub_recovered_1.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940", + "test-paired-stub_recovered_2.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] ] ], "versions": [ - "versions.yml:md5,b9467d4cb860eb2941a2078a3dd3cf41" + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" ] } ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.1" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-15T13:49:10.174131" + "timestamp": "2024-12-24T11:24:58.632197" }, - "Run gzrt on 30 paired-end reads - fastq.gz - stub": { + "Run gzrt on test2_1_corrupted and test2_2 paired-end - fastq.gz": { "content": [ { "0": [ [ { - "id": "test", + "id": "test-paired", "single_end": false }, - "test_recovered.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + [ + "test-paired_recovered_1.fastq.gz:md5,6bc7d0b6304039eadba7321d21e7b2c9", + "test-paired_recovered_2.fastq.gz:md5,641919946a0e572ca7483f6e54476f3b" + ] ] ], "1": [ - "versions.yml:md5,b9467d4cb860eb2941a2078a3dd3cf41" + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" ], - "fastqrecovered": [ + "recovered": [ [ { - "id": "test", + "id": "test-paired", "single_end": false }, - "test_recovered.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + [ + "test-paired_recovered_1.fastq.gz:md5,6bc7d0b6304039eadba7321d21e7b2c9", + "test-paired_recovered_2.fastq.gz:md5,641919946a0e572ca7483f6e54476f3b" + ] ] ], "versions": [ - "versions.yml:md5,b9467d4cb860eb2941a2078a3dd3cf41" + "versions.yml:md5,6d1e28b8a8043e3cba67606c7acdc676" ] } ], "meta": { "nf-test": "0.9.2", - "nextflow": "24.10.1" + "nextflow": "24.10.3" }, - "timestamp": "2024-12-15T13:49:20.410351" + "timestamp": "2024-12-24T11:23:40.906933" } } \ No newline at end of file