Skip to content

Commit

Permalink
Add module nanofilt (nf-core#5290)
Browse files Browse the repository at this point in the history
* Add module nanofilt

* Add module nanofilt with corrections in meta.yaml and main.nf

* Add reviewer suggestions

* Add last changes of review
  • Loading branch information
lfreitasl authored and tucano committed Mar 20, 2024
1 parent 1e4c5eb commit cc16942
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/nanofilt/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: "nanofilt"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::nanofilt=2.8.0"
53 changes: 53 additions & 0 deletions modules/nf-core/nanofilt/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
process NANOFILT {
tag "$meta.id"
label 'process_single'

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

input:
tuple val(meta), path(reads)
path summary_file

output:
tuple val(meta), path("*.fastq.gz"), emit: filtreads
path "*.log" , optional: true, emit: log_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 ?: "filtered_${meta.id}"
def sum = summary_file ? "--summary ${summary_file}" : ''
"""
gunzip \\
-c $reads \\
| NanoFilt \\
$sum \\
$args \\
| gzip > ${prefix}.fastq.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
nanofilt: \$(NanoFilt -v | sed 's/NanoFilt //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "filtered_${meta.id}"
def sum = summary_file ? "--summary ${summary_file}" : ''
"""
touch ${prefix}.fastq.gz
touch ${prefix}.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
nanofilt: \$(NanoFilt -v | sed 's/NanoFilt //')
END_VERSIONS
"""
}
59 changes: 59 additions & 0 deletions modules/nf-core/nanofilt/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "nanofilt"
description: Filtering and trimming of Oxford Nanopore Sequencing data
keywords:
- nanopore
- filtering
- QC
tools:
- "nanofilt":
description: "Filtering and trimming of Oxford Nanopore Sequencing data"
homepage: "https://github.com/wdecoster/nanofilt"
documentation: "https://github.com/wdecoster/nanofilt"
tool_dev_url: "https://github.com/wdecoster/nanofilt"
doi: "10.1093/bioinformatics/bty149"
licence: ["GLP-3.0"]

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- reads:
type: file
description: Gunziped fastq files from Oxford Nanopore sequencing.
pattern: "*.fastq.gz"

- summary_file:
type: file
description: Optional - Albacore or guppy summary file for quality scores

output:
- 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"

- filtreads:
type: file
description: Gunziped fastq files after filtering.
pattern: "*.fastq.gz"

- log_file:
type: file
description: Log file generated by --logfile option in NanoFilt, the file must end with .log extension.
pattern: "*.log"

authors:
- "@lfreitasl"
maintainers:
- "@lfreitasl"
63 changes: 63 additions & 0 deletions modules/nf-core/nanofilt/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "nanofilt"

test("sarscov2 - fastq") {


when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.test_data['sarscov2']['nanopore']['test_fastq_gz'], checkIfExists: true)
]
input[1] = []
"""
}
}

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

)
}

}


test("sarscov2 - fastq - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.test_data['sarscov2']['nanopore']['test_fastq_gz'], checkIfExists: true)
]
input[1] = []
"""
}
}

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

}

}
26 changes: 26 additions & 0 deletions modules/nf-core/nanofilt/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/nanofilt/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nanofilt:
- "modules/nf-core/nanofilt/**"

0 comments on commit cc16942

Please sign in to comment.