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

Update md5sum module to be able to take multiple files #3610

Merged
merged 23 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e70d080
Fix version string spurious text in singularity tests
SPPearce Nov 14, 2022
8e7a7a8
Merge branch 'nf-core:master' into master
SPPearce Nov 14, 2022
c63c3ca
Merge branch 'nf-core:master' into master
SPPearce Mar 7, 2023
aec8f2c
update to main nf-core
SPPearce Mar 25, 2023
ea42b9d
Merge branch 'nf-core:master' into master
SPPearce Mar 30, 2023
2ad2dbf
Merge branch 'nf-core:master' into master
SPPearce Apr 25, 2023
1ca507d
Merge branch 'nf-core:master' into ngscheckmate_workflow
SPPearce May 2, 2023
ad13c7a
Add config for subworkflow
SPPearce May 2, 2023
b090eb7
Merge branch 'ngscheckmate_workflow' of https://github.com/SPPearce/m…
SPPearce May 2, 2023
97be67e
Merge branch 'nf-core:master' into ngscheckmate_workflow
SPPearce Jun 6, 2023
a613cec
Merge branch 'nf-core:master' into ngscheckmate_workflow
SPPearce Jun 9, 2023
49b90cd
Merge branch 'nf-core:master' into ngscheckmate_workflow
SPPearce Jun 12, 2023
adf50fd
Update md5sum module to work with multiple files
SPPearce Jul 7, 2023
467b2ad
Merge branch 'master' into md5sum
SPPearce Jul 7, 2023
6ff4b9c
linting
SPPearce Jul 7, 2023
8866e27
Merge branch 'md5sum' of https://github.com/SPPearce/modules into md5sum
SPPearce Jul 7, 2023
15b2c5a
Resolve merge
SPPearce Jun 22, 2024
309793a
Fix stub
SPPearce Jun 22, 2024
9cf3b18
Merge branch 'master' into md5sum
SPPearce Jun 28, 2024
6c9733d
Add option to generate single file
SPPearce Jul 1, 2024
ab09666
Merge branch 'master' into md5sum
SPPearce Jul 1, 2024
e3758d7
Update modules/nf-core/md5sum/main.nf
SPPearce Jul 1, 2024
25ef266
Simplify versions processing
SPPearce Jul 1, 2024
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
67 changes: 47 additions & 20 deletions modules/nf-core/md5sum/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ process MD5SUM {
'nf-core/ubuntu:20.04' }"

input:
tuple val(meta), path(file)
tuple val(meta), path(files)
val as_separate_files

output:
tuple val(meta), path("*.md5"), emit: checksum
Expand All @@ -19,29 +20,55 @@ process MD5SUM {

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def prefix = task.ext.prefix ?: "${meta.id}" // will only use when as_separate_files = false
if ( as_separate_files ) {
"""
find -L * -type f \\
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
! -name '*.md5' \\
-exec sh -c 'md5sum $args "\$1" > "\$1.md5"' _ "{}" \\;

"""
md5sum \\
$args \\
${file} \\
> ${file}.md5
cat <<-END_VERSIONS > versions.yml
"${task.process}":
md5sum: \$(echo \$(md5sum --version 2>&1 | head -n 1| sed 's/^.*) //;' ))
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
END_VERSIONS
"""
} else {
"""
find -L * -type f \\
! -name '*.md5' \\
-exec md5sum $args "{}" + \\
> ${prefix}.md5

cat <<-END_VERSIONS > versions.yml
"${task.process}":
md5sum: \$(echo \$(md5sum --version 2>&1 | head -n 1| sed 's/^.*) //;' ))
END_VERSIONS
"""
cat <<-END_VERSIONS > versions.yml
"${task.process}":
md5sum: \$(echo \$(md5sum --version 2>&1 | head -n 1| sed 's/^.*) //;' ))
END_VERSIONS
"""
}

stub:
def args = task.ext.args ?: ''
"""
touch ${file}.md5

cat <<-END_VERSIONS > versions.yml
"${task.process}":
md5sum: \$(echo \$(md5sum --version 2>&1 | head -n 1| sed 's/^.*) //;' ))
END_VERSIONS
"""
def prefix = task.ext.prefix ?: "${meta.id}"
if ( as_separate_files ) {
"""
find -L * -type f \\
! -name '*.md5' \\
-exec sh -c 'touch "\$1.md5"' _ "{}" \\;

cat <<-END_VERSIONS > versions.yml
"${task.process}":
md5sum: \$(echo \$(md5sum --version 2>&1 | head -n 1| sed 's/^.*) //;' ))
END_VERSIONS
"""
} else {
"""
touch ${prefix}.md5

cat <<-END_VERSIONS > versions.yml
"${task.process}":
md5sum: \$(echo \$(md5sum --version 2>&1 | head -n 1| sed 's/^.*) //;' ))
END_VERSIONS
"""
}

}
8 changes: 4 additions & 4 deletions modules/nf-core/md5sum/meta.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "md5sum"
description: Create an MD5 (128-bit) checksum
description: Create MD5 (128-bit) checksums
keywords:
- checksum
- MD5
- 128 bit
tools:
- "md5sum":
description: Create an MD5 (128-bit) checksum
description: Create MD5 (128-bit) checksums for each file
homepage: "https://www.gnu.org"
documentation: "https://man7.org/linux/man-pages/man1/md5sum.1.html"
licence: ["GPL-3.0-or-later"]
Expand All @@ -16,9 +16,9 @@ input:
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- file:
- files:
type: file
description: Any file
description: Any number of files. One md5sum file will be generated for each.
pattern: "*.*"
output:
- meta:
Expand Down
127 changes: 126 additions & 1 deletion modules/nf-core/md5sum/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nextflow_process {
[ id: 'hello' ],
[ file(params.modules_testdata_base_path + 'generic/txt/hello.txt', checkIfExists: true) ]
]
input[1] = true
"""
}
}
Expand All @@ -40,6 +41,7 @@ nextflow_process {
[ id: 'hello' ],
[ file(params.modules_testdata_base_path + 'generic/txt/hello.txt', checkIfExists: true) ]
]
input[1] = true
"""
}
}
Expand All @@ -51,5 +53,128 @@ nextflow_process {
}
}
}


test("md5sum on hello.txt - stub") {
options "-stub"
when {
process {
"""
input[0] = [
[ id: 'hello' ],
[ file(params.modules_testdata_base_path + 'generic/txt/hello.txt', checkIfExists: true) ]
]
input[1] = true
"""
}
}

then {
assertAll {
{ assert process.success }
{ assert snapshot(process.out).match() }
}
}
}

test("md5sum on paired fastq, combined") {

when {
process {
"""
input[0] = [
[ id: 'test' ],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = false
"""
}
}

then {
assertAll {
{ assert process.success }
{ assert snapshot(process.out).match() }
}
}
}

test("md5sum on paired fastq, combined - stub") {
options "-stub"
when {
process {
"""
input[0] = [
[ id: 'test' ],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = false
"""
}
}

then {
assertAll {
{ assert process.success }
{ assert snapshot(process.out).match() }
}
}
}


test("md5sum on paired fastq, separate") {

when {
process {
"""
input[0] = [
[ id: 'test' ],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = true
"""
}
}

then {
assertAll {
{ assert process.success }
{ assert snapshot(process.out).match() }
}
}
}

test("md5sum on paired fastq, separate - stub") {
options "-stub"
when {
process {
"""
input[0] = [
[ id: 'test' ],
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = true
"""
}
}

then {
assertAll {
{ assert process.success }
{ assert snapshot(process.out).match() }
}
}
}

}
Loading
Loading