2021-02-16 18:11:36 +00:00
|
|
|
process TABIX_BGZIP {
|
2021-01-30 10:22:25 +00:00
|
|
|
tag "$meta.id"
|
2022-09-07 08:33:05 +00:00
|
|
|
label 'process_single'
|
2021-01-30 10:22:25 +00:00
|
|
|
|
2021-07-28 08:10:44 +00:00
|
|
|
conda (params.enable_conda ? 'bioconda::tabix=1.11' : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
|
|
|
'https://depot.galaxyproject.org/singularity/tabix:1.11--hdfd78af_0' :
|
|
|
|
'quay.io/biocontainers/tabix:1.11--hdfd78af_0' }"
|
2021-01-30 10:22:25 +00:00
|
|
|
|
|
|
|
input:
|
2021-02-16 23:28:32 +00:00
|
|
|
tuple val(meta), path(input)
|
2021-01-30 10:22:25 +00:00
|
|
|
|
|
|
|
output:
|
2022-09-30 12:31:48 +00:00
|
|
|
tuple val(meta), path("${output}") , emit: output
|
|
|
|
tuple val(meta), path("${output}.gzi"), emit: gzi, optional: true
|
|
|
|
path "versions.yml" , emit: versions
|
2021-01-30 10:22:25 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-01-30 10:22:25 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2022-04-20 14:26:56 +00:00
|
|
|
prefix = task.ext.prefix ?: "${meta.id}"
|
2022-09-30 12:31:48 +00:00
|
|
|
in_bgzip = ["gz", "bgz", "bgzf"].contains(input.getExtension())
|
|
|
|
output = in_bgzip ? input.getBaseName() : "${prefix}.${input.getExtension()}.gz"
|
2022-04-20 14:26:56 +00:00
|
|
|
command1 = in_bgzip ? '-d' : '-c'
|
2022-09-30 12:31:48 +00:00
|
|
|
command2 = in_bgzip ? '' : " > ${output}"
|
2022-09-26 19:47:41 +00:00
|
|
|
// 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")) {
|
2022-09-30 12:31:48 +00:00
|
|
|
args = args + " -I ${output}.gzi"
|
2022-09-26 19:47:41 +00:00
|
|
|
}
|
2021-01-30 10:22:25 +00:00
|
|
|
"""
|
2022-04-20 14:26:56 +00:00
|
|
|
bgzip $command1 $args -@${task.cpus} $input $command2
|
2021-04-07 07:39:53 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
tabix: \$(echo \$(tabix -h 2>&1) | sed 's/^.*Version: //; s/ .*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-01-30 10:22:25 +00:00
|
|
|
"""
|
|
|
|
}
|