Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dereplicate #6234

Merged
merged 7 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/nf-core/vsearch/dereplicate/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "vsearch_dereplicate"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::vsearch=2.28.1"
52 changes: 52 additions & 0 deletions modules/nf-core/vsearch/dereplicate/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
process VSEARCH_DEREPLICATE {
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/vsearch:2.28.1--h6a68c12_1':
'biocontainers/vsearch:2.28.1--h6a68c12_1' }"

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

output:
tuple val(meta), path('*.derep.fasta') , emit: fasta
tuple val(meta), path('*.derep.uc') , emit: clustering
path "*.derep.log" , emit: log
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}"
"""
vsearch \\
--derep_fulllength ${fasta} \\
$args \\
--relabel "${prefix}." \\
--uc ${prefix}.derep.uc \\
--output ${prefix}.derep.fasta 2>&1 | tee ${prefix}.derep.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
vsearch: \$(vsearch --version 2>&1 | head -n 1 | sed 's/vsearch //g' | sed 's/,.*//g' | sed 's/^v//' | sed 's/_.*//')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.derep.fasta
touch ${prefix}.derep.uc
touch myfile.derep.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
vsearch: \$(vsearch --version 2>&1 | head -n 1 | sed 's/vsearch //g' | sed 's/,.*//g' | sed 's/^v//' | sed 's/_.*//')
END_VERSIONS
"""
}
50 changes: 50 additions & 0 deletions modules/nf-core/vsearch/dereplicate/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "vsearch_dereplicate"
description: Merge strictly identical sequences contained in filename. Identical sequences are defined as having the same length and the same string of nucleotides (case insensitive, T and U are considered the same).
keywords:
- vsearch/dereplicate
- vsearch
- dereplicate
- amplicon sequences
- metagenomics
- genomics
- population genetics
tools:
- "vsearch":
description: "A versatile open source tool for metagenomics (USEARCH alternative)"
homepage: https://github.com/torognes/vsearch
documentation: https://github.com/torognes/vsearch/releases/download/v2.21.1/vsearch_manual.pdf
tool_dev_url: https://github.com/torognes/vsearch
doi: 10.7717/peerj.2584
licence: ["GPL v3-or-later OR BSD-2-clause"]
input:
- meta:
type: map
description: Groovy Map containing sample information e.g. [ id:'test' ]
- fasta:
type: file
description: Sequences to be sorted in FASTA format
pattern: "*.{fasta,fa,fasta.gz,fa.gz,.fna,.fna.gz}"
output:
- meta:
type: map
description: Groovy Map containing sample information e.g. [ id:'test' ]`
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- fasta:
type: file
description: dereplicated fasta
pattern: "*.fasta"
- clustering:
type: file
description: dereplicated derep.uc file
pattern: "*.uc"
- log:
type: file
description: a log file of the run
pattern: "*.derep.log"
authors:
- "@chriswyatt1"
maintainers:
- "@chriswyatt1"
58 changes: 58 additions & 0 deletions modules/nf-core/vsearch/dereplicate/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "vsearch"
tag "vsearch/dereplicate"

test("phyloplace - fasta") {

when {
process {
"""
input[0] = [
[ "id": "ERR2537816", "single_end": false ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/phyloplace/testdata/cyn_syn.fna", checkIfExists: true)
]
"""
}
}

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

}

test("phyloplace -fasta - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ "id": "ERR2537816", "single_end": false ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/phyloplace/testdata/cyn_syn.fna", checkIfExists: true)
]
"""
}
}

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

}

}
120 changes: 120 additions & 0 deletions modules/nf-core/vsearch/dereplicate/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"pollon -fasta - stub": {
"content": [
{
"0": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.fasta:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.uc:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
"myfile.derep.log:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"3": [
"versions.yml:md5,b00eb984d2fdee20b07a68bfc9fa08cb"
],
"clustering": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.uc:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"fasta": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.fasta:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"log": [
"myfile.derep.log:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,b00eb984d2fdee20b07a68bfc9fa08cb"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-24T06:58:16.351579571"
},
"pollon - fasta": {
"content": [
{
"0": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.fasta:md5,04313957d264c2fd5cc067920af51b08"
]
],
"1": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.uc:md5,99b94a34c5e2ba5fd37bff7c4b46aca8"
]
],
"2": [
"ERR2537816.derep.log:md5,fe97ec773766190003f0e53cda8a90f9"
],
"3": [
"versions.yml:md5,b00eb984d2fdee20b07a68bfc9fa08cb"
],
"clustering": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.uc:md5,99b94a34c5e2ba5fd37bff7c4b46aca8"
]
],
"fasta": [
[
{
"id": "ERR2537816",
"single_end": false
},
"ERR2537816.derep.fasta:md5,04313957d264c2fd5cc067920af51b08"
]
],
"log": [
"ERR2537816.derep.log:md5,fe97ec773766190003f0e53cda8a90f9"
],
"versions": [
"versions.yml:md5,b00eb984d2fdee20b07a68bfc9fa08cb"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-08-24T06:58:07.324653651"
}
}
Loading