diff --git a/modules/tabix/bgzip/main.nf b/modules/tabix/bgzip/main.nf index 394b6490..0c527d77 100644 --- a/modules/tabix/bgzip/main.nf +++ b/modules/tabix/bgzip/main.nf @@ -12,6 +12,7 @@ process TABIX_BGZIP { output: tuple val(meta), path("${prefix}*"), emit: output + tuple val(meta), path("*gzi") , emit: gzi, optional: true path "versions.yml" , emit: versions when: @@ -23,6 +24,10 @@ process TABIX_BGZIP { in_bgzip = input.toString().endsWith(".gz") command1 = in_bgzip ? '-d' : '-c' command2 = in_bgzip ? '' : " > ${prefix}.${input.getExtension()}.gz" + // Name the index according to $prefix, unless a name has been requested + if ((args.matches("(^| )-i\\b") || args.matches("(^| )--index(\$| )")) && !args.matches("(^| )-I\\b") && !args.matches("(^| )--index-name\\b")) { + args = args + " -I ${prefix}.${input.getExtension()}.gz.gzi" + } """ bgzip $command1 $args -@${task.cpus} $input $command2 diff --git a/modules/tabix/bgzip/meta.yml b/modules/tabix/bgzip/meta.yml index 50070175..72f0abcd 100644 --- a/modules/tabix/bgzip/meta.yml +++ b/modules/tabix/bgzip/meta.yml @@ -32,6 +32,10 @@ output: type: file description: Output compressed/decompressed file pattern: "*." + - gzi: + type: file + description: Optional gzip index file for compressed inputs + pattern: "*.gzi" - versions: type: file description: File containing software versions diff --git a/tests/modules/tabix/bgzip/main.nf b/tests/modules/tabix/bgzip/main.nf index 4e326d64..1be82fa5 100644 --- a/tests/modules/tabix/bgzip/main.nf +++ b/tests/modules/tabix/bgzip/main.nf @@ -3,6 +3,7 @@ nextflow.enable.dsl = 2 include { TABIX_BGZIP } from '../../../../modules/tabix/bgzip/main.nf' +include { TABIX_BGZIP as TABIX_BGZIP_WITH_GZI } from '../../../../modules/tabix/bgzip/main.nf' workflow test_tabix_bgzip_compress { input = [ [ id:'test' ], // meta map @@ -12,6 +13,14 @@ workflow test_tabix_bgzip_compress { TABIX_BGZIP ( input ) } +workflow test_tabix_bgzip_compress_gzi { + input = [ [ id:'test' ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true) ] + ] + + TABIX_BGZIP_WITH_GZI ( input ) +} + workflow test_tabix_bgzip_decompress { input = [ [ id:'test' ], // meta map [ file(params.test_data['sarscov2']['genome']['test_bed_gz'], checkIfExists: true) ] diff --git a/tests/modules/tabix/bgzip/nextflow.config b/tests/modules/tabix/bgzip/nextflow.config index 8730f1c4..f1592b7f 100644 --- a/tests/modules/tabix/bgzip/nextflow.config +++ b/tests/modules/tabix/bgzip/nextflow.config @@ -2,4 +2,7 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: TABIX_BGZIP_WITH_GZI { + ext.args = ' -i' + } } diff --git a/tests/modules/tabix/bgzip/test.yml b/tests/modules/tabix/bgzip/test.yml index 72819c90..53e00ccb 100644 --- a/tests/modules/tabix/bgzip/test.yml +++ b/tests/modules/tabix/bgzip/test.yml @@ -6,6 +6,18 @@ files: - path: ./output/tabix/test.vcf.gz md5sum: fc178eb342a91dc0d1d568601ad8f8e2 + - path: ./output/tabix/test.vcf.gz.gzi + should_exist: false +- name: tabix bgzip compress gzi + command: nextflow run ./tests/modules/tabix/bgzip -entry test_tabix_bgzip_compress_gzi -c ./tests/config/nextflow.config -c ./tests/modules/tabix/bgzip/nextflow.config + tags: + - tabix + - tabix/bgzip + files: + - path: ./output/tabix/test.vcf.gz + md5sum: fc178eb342a91dc0d1d568601ad8f8e2 + - path: ./output/tabix/test.vcf.gz.gzi + md5sum: 7dea362b3fac8e00956a4952a3d4f474 - name: tabix bgzip decompress command: nextflow run ./tests/modules/tabix/bgzip -entry test_tabix_bgzip_decompress -c ./tests/config/nextflow.config -c ./tests/modules/tabix/bgzip/nextflow.config tags: