1
0
Fork 0
mirror of https://github.com/MillironX/taxprofiler.git synced 2024-11-11 08:03:08 +00:00
taxprofiler/modules/nf-core/untar/main.nf

65 lines
1.7 KiB
Text
Raw Normal View History

2022-03-21 14:07:59 +00:00
process UNTAR {
tag "$archive"
2022-09-08 06:08:36 +00:00
label 'process_single'
2022-03-21 14:07:59 +00:00
2022-09-08 06:08:36 +00:00
conda (params.enable_conda ? "conda-forge::sed=4.7" : null)
2022-03-21 14:07:59 +00:00
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
2022-09-08 06:08:36 +00:00
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'ubuntu:20.04' }"
2022-03-21 14:07:59 +00:00
input:
2022-03-21 14:58:19 +00:00
tuple val(meta), path(archive)
2022-03-21 14:07:59 +00:00
output:
2022-03-21 14:58:19 +00:00
tuple val(meta), path("$untar"), emit: untar
path "versions.yml" , emit: versions
2022-03-21 14:07:59 +00:00
when:
task.ext.when == null || task.ext.when
script:
2022-03-21 14:58:19 +00:00
def args = task.ext.args ?: ''
2022-03-21 14:07:59 +00:00
def args2 = task.ext.args2 ?: ''
2022-03-21 14:58:19 +00:00
untar = archive.toString() - '.tar.gz'
2022-09-08 06:08:36 +00:00
2022-03-21 14:07:59 +00:00
"""
2022-09-08 06:08:36 +00:00
mkdir output
## Ensures --strip-components only applied when top level of tar contents is a directory
## If just files or multiple directories, place all in output
2022-10-05 10:24:18 +00:00
if [[ \$(tar -tzf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then
tar \\
-C output --strip-components 1 \\
-xzvf \\
$args \\
$archive \\
$args2
else
tar \\
-C output \\
-xzvf \\
$args \\
$archive \\
$args2
fi
2022-09-08 06:08:36 +00:00
mv output ${untar}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
stub:
untar = archive.toString() - '.tar.gz'
"""
touch $untar
2022-03-21 14:07:59 +00:00
cat <<-END_VERSIONS > versions.yml
"${task.process}":
untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
}