From 644d805c0f86608acfc495bf3737d33b61882927 Mon Sep 17 00:00:00 2001 From: sainsachiko Date: Mon, 26 Jan 2026 20:05:52 +0000 Subject: [PATCH] Fix file extension --- modules/nf-core/pbmarkdup/main.nf | 24 +++- modules/nf-core/pbmarkdup/tests/main.nf.test | 23 ++-- .../nf-core/pbmarkdup/tests/main.nf.test.snap | 128 ++++++++++-------- 3 files changed, 107 insertions(+), 68 deletions(-) diff --git a/modules/nf-core/pbmarkdup/main.nf b/modules/nf-core/pbmarkdup/main.nf index 20da004d21b5..b6e1317190a7 100644 --- a/modules/nf-core/pbmarkdup/main.nf +++ b/modules/nf-core/pbmarkdup/main.nf @@ -22,7 +22,16 @@ process PBMARKDUP { script: def args = task.ext.args ?: '' prefix = task.ext.prefix ?: "${meta.id}" - suffix = input[0].getExtension() // To allow multiple input types + // To allow multiple input types/files: (compressed) fasta, fastq, bam; Determine suffix from input file names + suffix = + input.find { + it.name ==~ /.*\.(fasta|fa|fna)(\.gz)?$/ }?.with { f -> + f.name.tokenize('.').takeRight(f.name.endsWith('.gz') ? 2 : 1).join('.') + } ?: + input.find { it.name ==~ /.*\.(fastq|fq)(\.gz)?$/ }?.with { f -> + f.name.tokenize('.').takeRight(f.name.endsWith('.gz') ? 2 : 1).join('.') + } ?: + input[0].extension dupfile_name = args.contains('--dup-file') ? (args =~ /--dup-file\s+(\S+)/)[0][1] : '' def log_args = args.contains('--log-level') ? " > ${prefix}.pbmarkdup.log" : '' def file_list = input.collect { it.getName() }.join(' ') @@ -58,7 +67,16 @@ process PBMARKDUP { stub: def args = task.ext.args ?: '' prefix = task.ext.prefix ?: "${meta.id}" - suffix = input[0].getExtension() // To allow multiple input types + // To allow multiple input types/files: (compressed) fasta, fastq, bam; Determine suffix from input file names + suffix = + input.find { + it.name ==~ /.*\.(fasta|fa|fna)(\.gz)?$/ }?.with { f -> + f.name.tokenize('.').takeRight(f.name.endsWith('.gz') ? 2 : 1).join('.') + } ?: + input.find { it.name ==~ /.*\.(fastq|fq)(\.gz)?$/ }?.with { f -> + f.name.tokenize('.').takeRight(f.name.endsWith('.gz') ? 2 : 1).join('.') + } ?: + input[0].extension dupfile_name = args.contains('--dup-file') ? (args =~ /--dup-file\s+(\S+)/)[0][1] : '' def log_args = args.contains('--log-level') ? " > ${prefix}.pbmarkdup.log" : '' def file_list = input.collect { it.getName() }.join(' ') @@ -70,4 +88,4 @@ process PBMARKDUP { pbmarkdup: \$(echo \$(pbmarkdup --version 2>&1) | awk 'BEFORE{FS=" "}{print \$2}') END_VERSIONS """ -} +} \ No newline at end of file diff --git a/modules/nf-core/pbmarkdup/tests/main.nf.test b/modules/nf-core/pbmarkdup/tests/main.nf.test index dbe78c3517cc..145da71b6c5d 100644 --- a/modules/nf-core/pbmarkdup/tests/main.nf.test +++ b/modules/nf-core/pbmarkdup/tests/main.nf.test @@ -40,7 +40,8 @@ nextflow_process { } - test("acropora cervicornis - bam - multiple tests with dupfile and log") { + test("acropora cervicornis - multiple input with dupfile logfile and remove duplicates") { + when { params { @@ -52,8 +53,9 @@ nextflow_process { input[0] = Channel.of( [ [ id:'test' ], // meta map - [ file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.1.bam', checkIfExists: true), - file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.2.bam', checkIfExists: true) + [ + file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.1.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.2.bam', checkIfExists: true) ] ] ) @@ -70,11 +72,10 @@ nextflow_process { } - test("acropora cervicornis - bam - multiple tests remove duplicates") { + test("homo sapiens - Multiple input types - with dupfile logfile and remove duplicates") { when { - params { - pbmarkdup_args = "--clobber --rmdup" + pbmarkdup_args = "--clobber --dup-file ${prefix}.dup.bam --log-level INFO" } process { @@ -82,22 +83,22 @@ nextflow_process { input[0] = Channel.of( [ [ id:'test' ], // meta map - [ file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.1.bam', checkIfExists: true), - file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.2.bam', checkIfExists: true) + [ + file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.1.fastq', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/eukaryotes/acropora_cervicornis/m84093_241116_151316_s2.hifi_reads.bc2028.subset.1.fasta', checkIfExists: true) ] ] ) """ } - } - + then { assertAll( { assert process.success }, { assert snapshot(process.out).match() } ) } - + } } test("deilephila porcellus - stub") { diff --git a/modules/nf-core/pbmarkdup/tests/main.nf.test.snap b/modules/nf-core/pbmarkdup/tests/main.nf.test.snap index 705b7dd4f2ac..c24cf42ce857 100644 --- a/modules/nf-core/pbmarkdup/tests/main.nf.test.snap +++ b/modules/nf-core/pbmarkdup/tests/main.nf.test.snap @@ -1,5 +1,5 @@ { - "acropora cervicornis - bam - multiple tests remove duplicates": { + "acropora cervicornis - multiple input with dupfile logfile and remove duplicates": { "content": [ { "0": [ @@ -11,19 +11,39 @@ ] ], "1": [ - + [ + { + "id": "test" + }, + "null.dup.bam:md5,3b74225ad5f7e9e1cbafc45132ad82fb" + ] ], "2": [ - + [ + { + "id": "test" + }, + "test.pbmarkdup.log:md5,99987a1331d01b59aa3b5ccd1c787906" + ] ], "3": [ "versions.yml:md5,832e36b56615fb29a94b16e4db32b8db" ], "dupfile": [ - + [ + { + "id": "test" + }, + "null.dup.bam:md5,3b74225ad5f7e9e1cbafc45132ad82fb" + ] ], "log": [ - + [ + { + "id": "test" + }, + "test.pbmarkdup.log:md5,99987a1331d01b59aa3b5ccd1c787906" + ] ], "markduped": [ [ @@ -39,12 +59,12 @@ } ], "meta": { - "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nf-test": "0.9.3", + "nextflow": "25.10.0" }, - "timestamp": "2025-11-27T22:25:53.428359" + "timestamp": "2026-01-26T16:07:38.506123115" }, - "acropora cervicornis - bam - multiple tests with dupfile and log": { + "deilephila porcellus - stub": { "content": [ { "0": [ @@ -52,50 +72,30 @@ { "id": "test" }, - "test.bam:md5,86e22a794d904cc48cb3758a03883ba1" + "test.fa:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "1": [ - [ - { - "id": "test" - }, - "null.dup.bam:md5,3b74225ad5f7e9e1cbafc45132ad82fb" - ] + ], "2": [ - [ - { - "id": "test" - }, - "test.pbmarkdup.log:md5,99987a1331d01b59aa3b5ccd1c787906" - ] + ], "3": [ "versions.yml:md5,832e36b56615fb29a94b16e4db32b8db" ], "dupfile": [ - [ - { - "id": "test" - }, - "null.dup.bam:md5,3b74225ad5f7e9e1cbafc45132ad82fb" - ] + ], "log": [ - [ - { - "id": "test" - }, - "test.pbmarkdup.log:md5,99987a1331d01b59aa3b5ccd1c787906" - ] + ], "markduped": [ [ { "id": "test" }, - "test.bam:md5,86e22a794d904cc48cb3758a03883ba1" + "test.fa:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "versions": [ @@ -104,12 +104,12 @@ } ], "meta": { - "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nf-test": "0.9.3", + "nextflow": "25.10.0" }, - "timestamp": "2025-11-27T22:25:23.374664" + "timestamp": "2026-01-26T16:17:29.606905496" }, - "deilephila porcellus - stub": { + "deilephila porcellus - fasta": { "content": [ { "0": [ @@ -117,7 +117,7 @@ { "id": "test" }, - "test.fa:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.fa:md5,087cee5291f8d728a62b91765b64af35" ] ], "1": [ @@ -140,7 +140,7 @@ { "id": "test" }, - "test.fa:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.fa:md5,087cee5291f8d728a62b91765b64af35" ] ], "versions": [ @@ -149,12 +149,12 @@ } ], "meta": { - "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nf-test": "0.9.3", + "nextflow": "25.10.0" }, - "timestamp": "2025-11-27T22:26:16.491708" + "timestamp": "2026-01-26T16:16:09.847582484" }, - "deilephila porcellus - fasta": { + "homo sapiens - Multiple input types - with dupfile logfile and remove duplicates": { "content": [ { "0": [ @@ -162,30 +162,50 @@ { "id": "test" }, - "test.fa:md5,087cee5291f8d728a62b91765b64af35" + "test.fasta:md5,c53086fa9bdb5cf0a4329da56c41b236" ] ], "1": [ - + [ + { + "id": "test" + }, + "null.dup.bam:md5,7a7bec54f6519fc282826ce9f86202d7" + ] ], "2": [ - + [ + { + "id": "test" + }, + "test.pbmarkdup.log:md5,0d14b38adfec8f46a47f954e15c88f7c" + ] ], "3": [ "versions.yml:md5,832e36b56615fb29a94b16e4db32b8db" ], "dupfile": [ - + [ + { + "id": "test" + }, + "null.dup.bam:md5,7a7bec54f6519fc282826ce9f86202d7" + ] ], "log": [ - + [ + { + "id": "test" + }, + "test.pbmarkdup.log:md5,0d14b38adfec8f46a47f954e15c88f7c" + ] ], "markduped": [ [ { "id": "test" }, - "test.fa:md5,087cee5291f8d728a62b91765b64af35" + "test.fasta:md5,c53086fa9bdb5cf0a4329da56c41b236" ] ], "versions": [ @@ -194,9 +214,9 @@ } ], "meta": { - "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nf-test": "0.9.3", + "nextflow": "25.10.0" }, - "timestamp": "2025-11-27T22:47:33.595865" + "timestamp": "2026-01-26T17:09:13.084330647" } } \ No newline at end of file