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

64 lines
1.8 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
2023-05-02 11:19:35 +00:00
conda "conda-forge::sed=4.7 bioconda::grep=3.4 conda-forge::tar=1.34"
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' :
2023-05-02 11:19:35 +00:00
'docker.io/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:
2023-05-02 11:19:35 +00:00
tuple val(meta), path("$prefix"), 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 ?: ''
2023-05-02 11:19:35 +00:00
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName.toString().replaceFirst(/\.tar$/, ""))
2022-09-08 06:08:36 +00:00
2022-03-21 14:07:59 +00:00
"""
2023-05-02 11:19:35 +00:00
mkdir $prefix
2022-09-08 06:08:36 +00:00
## Ensures --strip-components only applied when top level of tar contents is a directory
2023-05-02 11:19:35 +00:00
## If just files or multiple directories, place all in prefix
if [[ \$(tar -taf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then
tar \\
2023-05-02 11:19:35 +00:00
-C $prefix --strip-components 1 \\
-xavf \\
$args \\
$archive \\
$args2
else
tar \\
2023-05-02 11:19:35 +00:00
-C $prefix \\
-xavf \\
$args \\
$archive \\
$args2
fi
2022-09-08 06:08:36 +00:00
cat <<-END_VERSIONS > versions.yml
"${task.process}":
untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
stub:
2023-05-02 11:19:35 +00:00
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.toString().replaceFirst(/\.[^\.]+(.gz)?$/, ""))
2022-09-08 06:08:36 +00:00
"""
2023-05-02 11:19:35 +00:00
mkdir $prefix
touch ${prefix}/file.txt
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
"""
}