Skip to content

Commit

Permalink
Adding sequali module to nf-core modules (#6896)
Browse files Browse the repository at this point in the history
* Adding sequali module

* Update modules/nf-core/sequali/environment.yml

typo fixed

Co-authored-by: Louis LE NEZET <[email protected]>

* Getting a snapsot for JSON file (without meta field)

* modifying main.nf.test

* Adding naming check for JSON file

---------

Co-authored-by: Eirini (Irene) Liampa <[email protected]>
Co-authored-by: Louis LE NEZET <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent 7f3ea5d commit 8a94826
Show file tree
Hide file tree
Showing 5 changed files with 541 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/nf-core/sequali/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::sequali=0.12.0
58 changes: 58 additions & 0 deletions modules/nf-core/sequali/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
process SEQUALI {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'oras://community.wave.seqera.io/library/sequali:0.12.0--c288fa2befb47d0f':
'community.wave.seqera.io/library/sequali:0.12.0--07485bec824d914a' }"

input:

tuple val(meta), path(reads)

output:

tuple val(meta), path("*.html"), emit: html
tuple val(meta), path("*.json"), emit: json
path "versions.yml" , emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def read_1_bam = reads.size() == 1 ? reads : reads[0]
def read_2 = reads.size() == 2 ? reads[1]: ""

"""
sequali \\
$args \\
-t $task.cpus \\
--html ${prefix}.html \\
--json ${prefix}.json \\
$read_1_bam \\
$read_2
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sequali: \$(sequali --version |& sed '1!d ; s/sequali //')
END_VERSIONS
"""

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

"""
touch ${prefix}.html
touch ${prefix}.json
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sequali: \$(sequali --version |& sed '1!d ; s/sequali //')
END_VERSIONS
"""
}

60 changes: 60 additions & 0 deletions modules/nf-core/sequali/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: sequali
description: Sequence quality metrics for FASTQ and uBAM files.
keywords:
- quality_control
- qc
- preprocessing
tools:
- sequali:
description: Fast sequencing quality metrics
homepage: "https://github.com/rhpvorderman/sequali"
documentation: "https://sequali.readthedocs.io/en/latest/"
tool_dev_url: "https://github.com/rhpvorderman/sequali"
doi: "10.5281/zenodo.10854010"
licence: ["AGPL v3-or-later"]

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- reads:
type: file
description: Input FASTQ(s) or uBAM file. The format is autodetected and compressed formats are supported.
pattern: "*.{fastq,fq,fastq.gz,fq.gz,bam}"
output:
- json:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.json":
type: file
description: JSON output file.
pattern: "*.{json}"
- html:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- "*.html":
type: file
description: HTML output file.
pattern: "*.{html}"

- versions:
- "versions.yml":
type: file
description: File containing software versions.
pattern: "versions.yml"
authors:
- "@irliampa"
- "@DarkoCucin"
maintainers:
- "@irliampa"
- "@DarkoCucin"
171 changes: 171 additions & 0 deletions modules/nf-core/sequali/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "sequali"

test("sarscov2 - fastq single-end [sequali]") {

when {
process {
"""
input[0] = Channel.of([
[ id:'test', single_end:true ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)])
"""
}
}
then {
assertAll(
{ assert snapshot(
path(process.out.html[0][1]).getFileName().toString(),
path(process.out.json[0][1]).getFileName().toString(),
path(process.out.json[0][1]).json.remove('summary'),
process.out.versions
).match() }
)
}

}
test("sarscov2 - fastq paired-end [sequali]") {

when {
process {
"""
input[0] = Channel.of([
[id: 'test', single_end: false], // meta map
[ 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) ]
])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.html[0][1]).getFileName().toString(),
path(process.out.json[0][1]).getFileName().toString(),
path(process.out.json[0][1]).json.remove('summary'),
process.out.versions
).match() }
)
}

}

test("sarscov2 - unaligned bam [sequali]") {

when {
process {
"""
input[0] = Channel.of([
[id: 'test', single_end: true], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.unaligned.bam', checkIfExists: true)])
"""
}
}

then {
def json_file = path(process.out.json[0][1]).json.get('summary')
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.html[0][1]).getFileName().toString(),
path(process.out.json[0][1]).getFileName().toString(),
path(process.out.json[0][1]).json.remove('summary'),
process.out.versions
).match() }
)
}

}

test("sarscov2 - fastq single-end - stub[sequali]") {

options "-stub"

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

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.html[0][1]).getFileName().toString(),
path(process.out.json[0][1]).getFileName().toString(),
process.out
).match() }
)
}

}
test("sarscov2 - fastq paired-end - stub[sequali]") {

options "-stub"

when {
process {
"""
input[0] = Channel.of([
[id: 'test', single_end: false], // meta map
[ 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) ]
])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.html[0][1]).getFileName().toString(),
path(process.out.json[0][1]).getFileName().toString(),
process.out
).match() }
)
}

}

test("sarscov2 - unaligned bam - stub[sequali]") {

options "-stub"

when {
process {
"""
input[0] = Channel.of([
[id: 'test', single_end: true], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.unaligned.bam', checkIfExists: true)])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.html[0][1]).getFileName().toString(),
path(process.out.json[0][1]).getFileName().toString(),
process.out
).match() }
)
}

}

}
Loading

0 comments on commit 8a94826

Please sign in to comment.