Skip to content

Commit

Permalink
add module: Add fastx/collapser (nf-core#5250)
Browse files Browse the repository at this point in the history
* Add fastx_collapser module

* docs: Specify it's a decompressed file

* Update modules/nf-core/fastx/collapser/meta.yml

Co-authored-by: Friederike Hanssen <Friederike.hanssen@qbic.uni-tuebingen.de>

---------

Co-authored-by: Friederike Hanssen <Friederike.hanssen@qbic.uni-tuebingen.de>
  • Loading branch information
2 people authored and LE BARS Victor committed Mar 20, 2024
1 parent 3cf1e42 commit 322fa94
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/fastx/collapser/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: "fastx_collapser"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::fastx_toolkit=0.0.14"
46 changes: 46 additions & 0 deletions modules/nf-core/fastx/collapser/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
process FASTX_COLLAPSER {
tag "$meta.id"
label 'process_medium'

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

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

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

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

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
fastx_collapser \\
$args \\
-i $fastx \\
-o ${prefix}.fasta
cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastx: \$(echo \$(fastx_collapser -h) | sed -nE 's/.*([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/p' ))
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.fasta
cat <<-END_VERSIONS > versions.yml
"${task.process}":
fastx: \$(echo \$(fastx_collapser -h) | sed -nE 's/.*([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/p' ))
END_VERSIONS
"""
}
51 changes: 51 additions & 0 deletions modules/nf-core/fastx/collapser/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "fastx_collapser"
description: Collapses identical sequences in a FASTQ/A file into a single sequence (while maintaining reads counts)
keywords:
- collapse
- genomics
- fasta
- fastq
tools:
- "fastx":
description: "A collection of command line tools for Short-Reads FASTA/FASTQ files preprocessing"
homepage: "http://hannonlab.cshl.edu/fastx_toolkit/"
documentation: "http://hannonlab.cshl.edu/fastx_toolkit/commandline.html"
tool_dev_url: "https://github.com/agordon/fastx_toolkit"
licence: ["AGPL"]

input:
# Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- fastx:
type: file
description: Decompressed FASTA/FASTQ input file
pattern: "*.{fastq,fasta}"

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"

- fasta:
type: file
description: Collapsed FASTA file
pattern: "*.fasta"

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

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

tag "modules"
tag "modules_nfcore"
tag "fastx"
tag "fastx/collapser"

test("homo_sapiens - fasta") {

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.test_data['homo_sapiens']['pacbio']['ccs_fa'], checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.fasta[0][1]).text.contains(">1-1") },
{ assert process.out.fasta[0][1] ==~ ".*/test.fasta" },
{ assert snapshot(process.out).match() }
)
}

}

test("homo_sapiens - fasta - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'], // meta map
file(params.test_data['homo_sapiens']['pacbio']['ccs_fa'], checkIfExists: true)
]
"""
}
}

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

}

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

0 comments on commit 322fa94

Please sign in to comment.