Skip to content

Commit

Permalink
new module: crabz (#5351)
Browse files Browse the repository at this point in the history
* feat: add crabz skeleton

* feat: update `environment.yml`

* feat: add crabz version

* feat: add `crabz` to `container`

* fix: update label

* feat: update `CRABZ_COMPRESS` process

* WIP: add `CRABZ_DECOMPRESS` process

* fix: stub run

* fix: update file paths

* fix: update snapshot

* fix: tool name

* fix: remove unused `--quiet` flag
  • Loading branch information
camlloyd authored Mar 28, 2024
1 parent a389307 commit 0494c99
Show file tree
Hide file tree
Showing 12 changed files with 477 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/crabz/compress/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "crabz_compress"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- conda-forge::crabz=0.9.0
49 changes: 49 additions & 0 deletions modules/nf-core/crabz/compress/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
process CRABZ_COMPRESS {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/crabz:0.9.0':
'biocontainers/crabz:0.9.0' }"

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

output:
tuple val(meta), path("*.gz"), emit: archive
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${file}"
"""
crabz \\
$args \\
-p $task.cpus \\
-o ${prefix}.gz \\
$file
cat <<-END_VERSIONS > versions.yml
"${task.process}":
crabz: \$(crabz --version |& sed 's/[^:]*://')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${file}"
"""
echo "" | gzip > ${prefix}.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
crabz: \$(crabz --version |& sed 's/[^:]*://')
END_VERSIONS
"""
}
50 changes: 50 additions & 0 deletions modules/nf-core/crabz/compress/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "crabz_compress"
description: Compress files with crabz
keywords:
- compression
- gzip
- zlib
tools:
- crabz:
description: "Like pigz, but rust"
homepage: "https://github.com/sstadick/crabz"
documentation: "https://github.com/sstadick/crabz"
tool_dev_url: "https://github.com/sstadick/crabz"
licence: ["MIT"]

input:
# Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- file:
type: file
description: File to be compressed
pattern: "*.*"

output:
#Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- archive:
type: file
description: The compressed file
pattern: "*.gz"

authors:
- "@camlloyd"
maintainers:
- "@camlloyd"
61 changes: 61 additions & 0 deletions modules/nf-core/crabz/compress/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
nextflow_process {

name "Test Process CRABZ_COMPRESS"
script "../main.nf"
process "CRABZ_COMPRESS"

tag "modules"
tag "modules_nfcore"
tag "crabz"
tag "crabz/compress"

test("sarscov2 - genome - fasta") {


when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
"""
}
}

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

}

test("sarscov2 - genome - fasta - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
]
"""
}
}

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

}

}
68 changes: 68 additions & 0 deletions modules/nf-core/crabz/compress/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions modules/nf-core/crabz/compress/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
crabz/compress:
- "modules/nf-core/crabz/compress/**"
9 changes: 9 additions & 0 deletions modules/nf-core/crabz/decompress/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "crabz_decompress"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- conda-forge::crabz=0.9.0
47 changes: 47 additions & 0 deletions modules/nf-core/crabz/decompress/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
process CRABZ_DECOMPRESS {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/crabz:0.9.0':
'biocontainers/crabz:0.9.0' }"

input:
tuple val(meta), path(archive)

output:
tuple val(meta), path("*.*"), emit: file
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${archive}"
"""
crabz \\
$args \\
-p $task.cpus \\
-o ${prefix} \\
$archive
cat <<-END_VERSIONS > versions.yml
"${task.process}":
crabz: \$(crabz --version |& sed 's/[^:]*://')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${archive}"
"""
touch ${prefix}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
crabz: \$(crabz --version |& sed 's/[^:]*://')
END_VERSIONS
"""
}
50 changes: 50 additions & 0 deletions modules/nf-core/crabz/decompress/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "crabz_decompress"
description: Decompress files with crabz
keywords:
- decompression
- gzip
- zlib
tools:
- crabz:
description: "Like pigz, but rust"
homepage: "https://github.com/sstadick/crabz"
documentation: "https://github.com/sstadick/crabz"
tool_dev_url: "https://github.com/sstadick/crabz"
licence: ["MIT"]

input:
# Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- archive:
type: file
description: File to be decompressed
pattern: "*.gz"

output:
#Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- file:
type: file
description: The decompressed file
pattern: "*.*"

authors:
- "@camlloyd"
maintainers:
- "@camlloyd"
Loading

0 comments on commit 0494c99

Please sign in to comment.