Skip to content

Commit

Permalink
Merge pull request #3 from mirpedrol/fix-linting
Browse files Browse the repository at this point in the history
fix nf-core linting
  • Loading branch information
mirpedrol authored Jul 5, 2024
2 parents 63fcee1 + 89a7426 commit 2844bf1
Show file tree
Hide file tree
Showing 19 changed files with 1,307 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
uses: nf-core/setup-nextflow@v2

- name: Install nf-core tools development version
run: python -m pip install --upgrade --force-reinstall git+https://github.com/nf-core/tools.git@dev
run: python -m pip install --upgrade --force-reinstall git+https://github.com/mirpedrol/tools.git@modules-yml-ontology

- name: Lint module ${{ matrix.tags }}
run: nf-core modules --git-remote https://github.com/mirpedrol/class-modules lint ${{ matrix.tags }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nf-test.log
.nf-test/
9 changes: 9 additions & 0 deletions modules/class-modules/pigz/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: "pigz_compress"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "pigz=2.8"
45 changes: 45 additions & 0 deletions modules/class-modules/pigz/compress/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
process PIGZ_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/pigz:2.8':
'biocontainers/pigz:2.8' }"

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

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

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

script:
def args = task.ext.args ?: ''
archive = raw_file.toString() + ".gz"
"""
# Note: needs --stdout for pigz to avoid the following issue:
# pigz: skipping: ${raw_file} is a symbolic link
pigz --processes $task.cpus --stdout --force ${args} ${raw_file} > ${archive}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
pigz:\$(echo \$(pigz --version 2>&1) | sed 's/^.*pigz\\w*//' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
archive = raw_file.toString() + ".gz"
"""
touch ${archive}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
pigz:\$(echo \$(pigz --version 2>&1) | sed 's/^.*pigz\\w*//' )
END_VERSIONS
"""
}
43 changes: 43 additions & 0 deletions modules/class-modules/pigz/compress/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/mirpedrol/class-modules/main/modules/yaml-schema.json
name: "pigz_compress"
description: Compresses files with pigz.
keywords:
- compress
- gzip
- parallelized
tools:
- "pigz":
description: "Parallel implementation of the gzip algorithm."
homepage: "https://zlib.net/pigz/"
documentation: "https://zlib.net/pigz/pigz.pdf"
identifier: ""
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- raw_file:
type: file
description: File to be compressed
pattern: "*.*"
output:
- archive:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- $archive:
type: file
description: The compressed file
pattern: "*.gz"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@leoisl"
maintainers:
- "@leoisl"
49 changes: 49 additions & 0 deletions modules/class-modules/pigz/compress/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
nextflow_process {
name "Test Process PIGZ_COMPRESS"
script "../main.nf"
process "PIGZ_COMPRESS"

tag "modules"
tag "modules_classmodules"
tag "pigz"
tag "pigz/compress"

test("sarscov2 - genome - fasta") {
when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}

test("sarscov2 - genome - fasta - stub") {
options "-stub-run"
when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.archive[0][1]).name).match() }
)
}
}
}
37 changes: 37 additions & 0 deletions modules/class-modules/pigz/compress/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"sarscov2 - genome - fasta": {
"content": [
{
"0": [
[
{
"id": "test"
},
"genome.fasta.gz:md5,6e9fe4042a72f2345f644f239272b7e6"
]
],
"1": [
"versions.yml:md5,ca30e9e1ffa1394ba7eefdac8cf3a3ad"
],
"archive": [
[
{
"id": "test"
},
"genome.fasta.gz:md5,6e9fe4042a72f2345f644f239272b7e6"
]
],
"versions": [
"versions.yml:md5,ca30e9e1ffa1394ba7eefdac8cf3a3ad"
]
}
],
"timestamp": "2023-12-11T22:39:53.350546"
},
"sarscov2 - genome - fasta - stub": {
"content": [
"genome.fasta.gz"
],
"timestamp": "2023-12-11T22:52:24.309192"
}
}
2 changes: 2 additions & 0 deletions modules/class-modules/pigz/compress/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pigz/compress:
- "modules/nf-core/pigz/compress/**"
10 changes: 5 additions & 5 deletions modules/class-modules/tcoffee/irmsd/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ process TCOFFEE_IRMSD {
'https://depot.galaxyproject.org/singularity/mulled-v2-a76a981c07359a31ff55b9dc13bd3da5ce1909c1:84c8f17f1259b49e2f7783b95b7a89c6f2cb199e-0':
'biocontainers/mulled-v2-a76a981c07359a31ff55b9dc13bd3da5ce1909c1:84c8f17f1259b49e2f7783b95b7a89c6f2cb199e-0' }"

input:
tuple val(meta), file (msa)
tuple val(meta2), file(template), file(structures)
input:
tuple val(meta), path(msa)
tuple val(meta2), path(template), path(structures)

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

when:
task.ext.when == null || task.ext.when
Expand Down
24 changes: 22 additions & 2 deletions modules/class-modules/tcoffee/irmsd/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ keywords:
- evaluation
tools:
- "tcoffee":
description: "A collection of tools for Multiple Alignments of DNA, RNA, Protein
Sequence"
description: "A collection of tools for Multiple Alignments of DNA, RNA, Protein\
\ Sequence"
homepage: "http://www.tcoffee.org/Projects/tcoffee/"
documentation: "https://tcoffee.readthedocs.io/en/latest/tcoffee_main_documentation.html"
tool_dev_url: "https://github.com/cbcrg/tcoffee"
Expand All @@ -25,7 +25,27 @@ input:
description: |
Groovy Map containing sample information
e.g. [ id:'test', ... ]
- msa:
type: file
description: fasta file containing the alignment to be evaluated. May be gzipped
or uncompressed.
pattern: "*.{aln,fa,fasta,fas}{.gz,}"
ontologies:
- edam: http://edamontology.org/format_1984
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', ... ]
- template:
type: file
description: T_coffee template file that maps sequences to the accessory information
files to be used.
- structures:
type: file
description: Structure file to be used in the alignment. For example, it could
be protein structures or secondary structures.

output:
- irmsd:
- meta:
Expand Down
9 changes: 6 additions & 3 deletions modules/class-modules/tcoffee/tcs/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
# yaml-language-server: $schema=https://raw.githubusercontent.com/mirpedrol/class-modules/main/modules/yaml-schema.json
name: "tcoffee_tcs"
description: Compute the TCS score for a MSA or for a MSA plus a library file. Outputs
the tcs as it is and a csv with just the total TCS score.
Expand Down Expand Up @@ -29,12 +29,15 @@ input:
e.g. [ id:'test', ... ]
- msa:
type: file
description: fasta file containing the alignment to be evaluated. May be gzipped
or uncompressed.
description: fasta file containing the alignment to be evaluated. May be gzipped or uncompressed.
pattern: "*.{aln,fa,fasta,fas}{.gz,}"
ontologies:
- edam: http://edamontology.org/format_1984
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', ... ]
- lib:
type: file
description: lib file containing the alignment library of the given msa.
Expand Down
11 changes: 11 additions & 0 deletions modules/class-modules/untar/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: untar

channels:
- conda-forge
- bioconda
- defaults

dependencies:
- conda-forge::grep=3.11
- conda-forge::sed=4.7
- conda-forge::tar=1.34
63 changes: 63 additions & 0 deletions modules/class-modules/untar/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
process UNTAR {
tag "$archive"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'nf-core/ubuntu:20.04' }"

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

output:
tuple val(meta), path("$prefix"), emit: untar
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: ''
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName.toString().replaceFirst(/\.tar$/, ""))

"""
mkdir $prefix
## Ensures --strip-components only applied when top level of tar contents is a directory
## If just files or multiple directories, place all in prefix
if [[ \$(tar -taf ${archive} | grep -o -P "^.*?\\/" | uniq | wc -l) -eq 1 ]]; then
tar \\
-C $prefix --strip-components 1 \\
-xavf \\
$args \\
$archive \\
$args2
else
tar \\
-C $prefix \\
-xavf \\
$args \\
$archive \\
$args2
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.toString().replaceFirst(/\.[^\.]+(.gz)?$/, ""))
"""
mkdir $prefix
touch ${prefix}/file.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
untar: \$(echo \$(tar --version 2>&1) | sed 's/^.*(GNU tar) //; s/ Copyright.*\$//')
END_VERSIONS
"""
}
Loading

0 comments on commit 2844bf1

Please sign in to comment.