From 59ede171ec5321d92aeff3987a92e49d43dc075d Mon Sep 17 00:00:00 2001 From: Jim Downie Date: Fri, 6 Dec 2024 11:10:29 +0000 Subject: [PATCH] Fix linting, fix dastool input bug --- modules.json | 2 +- modules/nf-core/gawk/main.nf | 6 ++ modules/nf-core/gawk/tests/main.nf.test | 77 +++++++++++++++++-- modules/nf-core/gawk/tests/main.nf.test.snap | 35 ++++++++- modules/nf-core/gawk/tests/nextflow.config | 4 +- .../tests/nextflow_with_program_file.config | 5 -- nextflow_schema.json | 17 ++-- workflows/longreadmag.nf | 2 +- 8 files changed, 123 insertions(+), 25 deletions(-) delete mode 100644 modules/nf-core/gawk/tests/nextflow_with_program_file.config diff --git a/modules.json b/modules.json index 8f9134b..81b5766 100644 --- a/modules.json +++ b/modules.json @@ -43,7 +43,7 @@ }, "gawk": { "branch": "master", - "git_sha": "97321eded31a12598837a476d3615300af413bb7", + "git_sha": "caab1314ca62679b629da4c79afa9a4cab2bb8ee", "installed_by": ["modules"] }, "gtdbtk/classifywf": { diff --git a/modules/nf-core/gawk/main.nf b/modules/nf-core/gawk/main.nf index 7514246..b9df2b8 100644 --- a/modules/nf-core/gawk/main.nf +++ b/modules/nf-core/gawk/main.nf @@ -28,6 +28,11 @@ process GAWK { lst_gz = input.collect{ it.getExtension().endsWith("gz") } unzip = lst_gz.contains(false) ? "" : "find ${input} -exec zcat {} \\; | \\" input_cmd = unzip ? "" : "${input}" + output_cmd = suffix.endsWith("gz") ? "| gzip" : "" + + input.collect{ + assert it.name != "${prefix}.${suffix}" : "Input and output names are the same, set prefix in module configuration to disambiguate!" + } """ ${unzip} @@ -35,6 +40,7 @@ process GAWK { ${args} \\ ${program} \\ ${input_cmd} \\ + ${output_cmd} \\ > ${prefix}.${suffix} cat <<-END_VERSIONS > versions.yml diff --git a/modules/nf-core/gawk/tests/main.nf.test b/modules/nf-core/gawk/tests/main.nf.test index 5952e9a..b3cde8b 100644 --- a/modules/nf-core/gawk/tests/main.nf.test +++ b/modules/nf-core/gawk/tests/main.nf.test @@ -8,10 +8,14 @@ nextflow_process { tag "modules_nfcore" tag "gawk" - test("Convert fasta to bed") { - config "./nextflow.config" + config "./nextflow.config" + test("Convert fasta to bed") { when { + params { + gawk_suffix = "bed" + gawk_args2 = '\'BEGIN {FS="\t"}; {print \$1 FS "0" FS \$2}\'' + } process { """ input[0] = [ @@ -32,9 +36,11 @@ nextflow_process { } test("Convert fasta to bed with program file") { - config "./nextflow_with_program_file.config" - when { + params { + gawk_suffix = "bed" + gawk_args2 = "" + } process { """ input[0] = [ @@ -55,9 +61,11 @@ nextflow_process { } test("Extract first column from multiple files") { - config "./nextflow_with_program_file.config" - tag "test" when { + params { + gawk_suffix = "bed" + gawk_args2 = "" + } process { """ input[0] = [ @@ -79,9 +87,11 @@ nextflow_process { } test("Unzip files before processing") { - config "./nextflow_with_program_file.config" - when { + params { + gawk_suffix = "bed" + gawk_args2 = "" + } process { """ input[0] = [ @@ -101,4 +111,55 @@ nextflow_process { ) } } + + test("Compress after processing") { + when { + params { + gawk_suffix = "txt.gz" + gawk_args2 = '\'BEGIN {FS="\t"}; {print \$1 FS "0" FS \$2}\'' + } + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists: true) + ] + input[1] = [] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("Input and output files are similar") { + when { + params { + gawk_suffix = "txt" + gawk_args2 = "" + } + process { + """ + input[0] = [ + [ id:'hello' ], // meta map + [file(params.modules_testdata_base_path + 'generic/txt/hello.txt', checkIfExists: true), + file(params.modules_testdata_base_path + 'generic/txt/species_names.txt', checkIfExists: true)] + ] + input[1] = Channel.of('BEGIN {FS=" "}; {print \$1}').collectFile(name:"program.txt") + """ + } + } + + then { + assertAll( + { assert process.failed }, + { assert process.errorReport.contains("Input and output names are the same, set prefix in module configuration to disambiguate!") } + ) + } + } } \ No newline at end of file diff --git a/modules/nf-core/gawk/tests/main.nf.test.snap b/modules/nf-core/gawk/tests/main.nf.test.snap index d396f73..1b3c2f7 100644 --- a/modules/nf-core/gawk/tests/main.nf.test.snap +++ b/modules/nf-core/gawk/tests/main.nf.test.snap @@ -1,4 +1,37 @@ { + "Compress after processing": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.txt.gz:md5,87a15eb9c2ff20ccd5cd8735a28708f7" + ] + ], + "1": [ + "versions.yml:md5,842acc9870dc8ac280954047cb2aa23a" + ], + "output": [ + [ + { + "id": "test" + }, + "test.txt.gz:md5,87a15eb9c2ff20ccd5cd8735a28708f7" + ] + ], + "versions": [ + "versions.yml:md5,842acc9870dc8ac280954047cb2aa23a" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.1" + }, + "timestamp": "2024-11-27T17:11:20.054143406" + }, "Convert fasta to bed": { "content": [ { @@ -131,4 +164,4 @@ }, "timestamp": "2024-10-19T22:08:19.533527657" } -} +} \ No newline at end of file diff --git a/modules/nf-core/gawk/tests/nextflow.config b/modules/nf-core/gawk/tests/nextflow.config index 6e5d43a..895709a 100644 --- a/modules/nf-core/gawk/tests/nextflow.config +++ b/modules/nf-core/gawk/tests/nextflow.config @@ -1,6 +1,6 @@ process { withName: GAWK { - ext.suffix = "bed" - ext.args2 = '\'BEGIN {FS="\t"}; {print \$1 FS "0" FS \$2}\'' + ext.suffix = params.gawk_suffix + ext.args2 = params.gawk_args2 } } diff --git a/modules/nf-core/gawk/tests/nextflow_with_program_file.config b/modules/nf-core/gawk/tests/nextflow_with_program_file.config deleted file mode 100644 index 693ad41..0000000 --- a/modules/nf-core/gawk/tests/nextflow_with_program_file.config +++ /dev/null @@ -1,5 +0,0 @@ -process { - withName: GAWK { - ext.suffix = "bed" - } -} diff --git a/nextflow_schema.json b/nextflow_schema.json index 24fbeae..db8e13f 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -105,8 +105,8 @@ } } }, - "new_group_2": { - "title": "New Group 2", + "pipeline_options": { + "title": "Pipeline options", "type": "object", "description": "", "default": "", @@ -140,8 +140,8 @@ } } }, - "new_group_1": { - "title": "New Group 1", + "bin_taxonomy_options": { + "title": "Bin taxonomy options", "type": "object", "description": "", "default": "", @@ -157,7 +157,10 @@ "gtdbtk_db": { "type": "string" }, - "gtdbtk_mash_db": { + "gtdb_bac120_metadata": { + "type": "string" + }, + "gtdb_ar53_metadata": { "type": "string" }, "gtdbtk_min_completeness": { @@ -303,13 +306,13 @@ "$ref": "#/$defs/bin_refinement_options" }, { - "$ref": "#/$defs/new_group_2" + "$ref": "#/$defs/pipeline_options" }, { "$ref": "#/$defs/bin_qc_options" }, { - "$ref": "#/$defs/new_group_1" + "$ref": "#/$defs/bin_taxonomy_options" }, { "$ref": "#/$defs/institutional_config_options" diff --git a/workflows/longreadmag.nf b/workflows/longreadmag.nf index 8ebeb06..d616ee9 100644 --- a/workflows/longreadmag.nf +++ b/workflows/longreadmag.nf @@ -62,7 +62,7 @@ workflow LONGREADMAG { BIN_REFINEMENT( ASSEMBLY.out.assemblies, ASSEMBLY.out.proteins, - BINNING.out.bins + BINNING.out.contig2bin ) }