Update UNTAR to account for file-only or multi-directory tar archives (#2055)

* Update main.nf

* Update meta.yml

* Re-add logos as not staged in a way that works with MultiQC config files

* Fix when only files or multiple directories

* Add test for only-files tar

* Fix bash check
This commit is contained in:
James A. Fellows Yates 2022-09-14 10:40:45 +02:00 committed by GitHub
parent c9b29c7686
commit 393dbd6dda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 10 deletions

View file

@ -25,12 +25,23 @@ process UNTAR {
""" """
mkdir output 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
if [[ \$(tar -tzf ${archive} | grep "/\$" | wc -l) -eq 1 ]]; then
tar \\ tar \\
-C output --strip-components 1 \\ -C output --strip-components 1 \\
-xzvf \\ -xzvf \\
$args \\ $args \\
$archive \\ $archive \\
$args2 $args2
else
tar \\
-C output \\
-xzvf \\
$args \\
$archive \\
$args2
fi
mv output ${untar} mv output ${untar}

View file

@ -26,9 +26,9 @@ output:
Groovy Map containing sample information Groovy Map containing sample information
e.g. [ id:'test', single_end:false ] e.g. [ id:'test', single_end:false ]
- untar: - untar:
type: file type: directory
description: description: Directory containing contents of archive
pattern: "*.*" pattern: "*/"
- versions: - versions:
type: file type: file
description: File containing software versions description: File containing software versions
@ -36,3 +36,5 @@ output:
authors: authors:
- "@joseespinosa" - "@joseespinosa"
- "@drpatelh" - "@drpatelh"
- "@matthdsm"
- "@jfy133"

View file

@ -446,6 +446,9 @@ params {
ipython_md = "${test_data_dir}/generic/notebooks/jupyter/ipython_notebook.md" ipython_md = "${test_data_dir}/generic/notebooks/jupyter/ipython_notebook.md"
ipython_ipynb = "${test_data_dir}/generic/notebooks/jupyter/ipython_notebook.ipynb" ipython_ipynb = "${test_data_dir}/generic/notebooks/jupyter/ipython_notebook.ipynb"
} }
'tar' {
tar_gz = "${test_data_dir}/generic/tar/hello.tar.gz"
}
'tsv' { 'tsv' {
test_tsv = "${test_data_dir}/generic/tsv/test.tsv" test_tsv = "${test_data_dir}/generic/tsv/test.tsv"
} }

View file

@ -22,3 +22,13 @@ workflow test_untar_different_output_path {
UNTAR ( input ) UNTAR ( input )
} }
workflow test_untar_onlyfiles {
input = [
[],
file(params.test_data['generic']['tar']['tar_gz'], checkIfExists: true)
]
UNTAR ( input )
}

View file

@ -15,5 +15,13 @@
tags: tags:
- untar - untar
files: files:
- path: output/untar/flowcell/RunInfo.xml - path: output/untar/flowcell/220422_M11111_0222_000000000-K9H97/RunInfo.xml
md5sum: 03038959f4dd181c86bc97ae71fe270a md5sum: 03038959f4dd181c86bc97ae71fe270a
- name: untar test_untar_onlyfiles
command: nextflow run ./tests/modules/untar -entry test_untar_onlyfiles -c ./tests/config/nextflow.config -c ./tests/modules/untar/nextflow.config
tags:
- untar
files:
- path: output/untar/hello/hello.txt
md5sum: e59ff97941044f85df5297e1c302d260