add decompress possibilities to bgzip (#1540)

* add decompress possibilities to bgzip

* spacing
This commit is contained in:
Maxime U. Garcia 2022-04-20 16:26:56 +02:00 committed by GitHub
parent 6c45773c0b
commit 37bf3936f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 15 deletions

View file

@ -11,17 +11,20 @@ process TABIX_BGZIP {
tuple val(meta), path(input) tuple val(meta), path(input)
output: output:
tuple val(meta), path("*.gz"), emit: gz tuple val(meta), path("${prefix}*"), emit: output
path "versions.yml" , emit: versions path "versions.yml" , emit: versions
when: when:
task.ext.when == null || task.ext.when task.ext.when == null || task.ext.when
script: script:
def args = task.ext.args ?: '' def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}" prefix = task.ext.prefix ?: "${meta.id}"
in_bgzip = input.toString().endsWith(".gz")
command1 = in_bgzip ? '-d' : '-c'
command2 = in_bgzip ? '' : " > ${prefix}.${input.getExtension()}.gz"
""" """
bgzip -c $args $input > ${prefix}.${input.getExtension()}.gz bgzip $command1 $args -@${task.cpus} $input $command2
cat <<-END_VERSIONS > versions.yml cat <<-END_VERSIONS > versions.yml
"${task.process}": "${task.process}":

View file

@ -1,13 +1,14 @@
name: tabix_bgzip name: tabix_bgzip
description: Compresses files description: Compresses/decompresses files
keywords: keywords:
- compress - compress
- decompress
- bgzip - bgzip
- tabix - tabix
tools: tools:
- bgzip: - bgzip:
description: | description: |
Bgzip compresses files in a similar manner to, and compatible with, gzip. Bgzip compresses or decompresses files in a similar manner to, and compatible with, gzip.
homepage: https://www.htslib.org/doc/tabix.html homepage: https://www.htslib.org/doc/tabix.html
documentation: http://www.htslib.org/doc/bgzip.html documentation: http://www.htslib.org/doc/bgzip.html
doi: 10.1093/bioinformatics/btp352 doi: 10.1093/bioinformatics/btp352
@ -18,19 +19,19 @@ input:
description: | description: |
Groovy Map containing sample information Groovy Map containing sample information
e.g. [ id:'test', single_end:false ] e.g. [ id:'test', single_end:false ]
- file: - input:
type: file type: file
description: text file description: file to compress or to decompress
output: output:
- meta: - meta:
type: map type: map
description: | description: |
Groovy Map containing sample information Groovy Map containing sample information
e.g. [ id:'test', single_end:false ] e.g. [ id:'test', single_end:false ]
- file: - output:
type: file type: file
description: Output compressed file description: Output compressed/decompressed file
pattern: "*.{gz}" pattern: "*."
- versions: - versions:
type: file type: file
description: File containing software versions description: File containing software versions

View file

@ -397,7 +397,7 @@ params {
hello = "${test_data_dir}/generic/txt/hello.txt" hello = "${test_data_dir}/generic/txt/hello.txt"
} }
'cnn' { 'cnn' {
reference = "${test_data_dir}/generic/cnn/reference.cnn" reference = "${test_data_dir}/generic/cnn/reference.cnn"
} }
'cooler'{ 'cooler'{
test_pairix_pair_gz = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.GM12878-MboI.pairs.subsample.blksrt.txt.gz" test_pairix_pair_gz = "${test_data_dir}/genomics/homo_sapiens/cooler/cload/hg19/hg19.GM12878-MboI.pairs.subsample.blksrt.txt.gz"

View file

@ -4,10 +4,18 @@ nextflow.enable.dsl = 2
include { TABIX_BGZIP } from '../../../../modules/tabix/bgzip/main.nf' include { TABIX_BGZIP } from '../../../../modules/tabix/bgzip/main.nf'
workflow test_tabix_bgzip { workflow test_tabix_bgzip_compress {
input = [ [ id:'test' ], // meta map input = [ [ id:'test' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true) ] [ file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true) ]
] ]
TABIX_BGZIP ( input ) TABIX_BGZIP ( input )
} }
workflow test_tabix_bgzip_decompress {
input = [ [ id:'test' ], // meta map
[ file(params.test_data['sarscov2']['genome']['test_bed_gz'], checkIfExists: true) ]
]
TABIX_BGZIP ( input )
}

View file

@ -1,8 +1,16 @@
- name: tabix bgzip - name: tabix bgzip compress
command: nextflow run ./tests/modules/tabix/bgzip -entry test_tabix_bgzip -c ./tests/config/nextflow.config -c ./tests/modules/tabix/bgzip/nextflow.config command: nextflow run ./tests/modules/tabix/bgzip -entry test_tabix_bgzip_compress -c ./tests/config/nextflow.config -c ./tests/modules/tabix/bgzip/nextflow.config
tags: tags:
- tabix - tabix
- tabix/bgzip - tabix/bgzip
files: files:
- path: ./output/tabix/test.vcf.gz - path: ./output/tabix/test.vcf.gz
md5sum: fc178eb342a91dc0d1d568601ad8f8e2 md5sum: fc178eb342a91dc0d1d568601ad8f8e2
- 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:
- tabix
- tabix/bgzip
files:
- path: ./output/tabix/test.bed
md5sum: fe4053cf4de3aebbdfc3be2efb125a74