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

Convert ultraplex to nf-test #5706

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
33 changes: 29 additions & 4 deletions modules/nf-core/ultraplex/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ process ULTRAPLEX {
val(adapter_seq)

output:
tuple val(meta), path("*[!no_match].fastq.gz"), emit: fastq
tuple val(meta), path("*no_match.fastq.gz"), optional: true, emit: no_match_fastq
path "*.log", emit: report
path "versions.yml", emit: versions
tuple val(meta), path("*matched.fastq.gz") , emit: fastq
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
tuple val(meta), path("*no_match.fastq.gz"), emit: no_match_fastq, optional: true
path "*.log" , emit: report
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when
Expand Down Expand Up @@ -47,6 +47,31 @@ process ULTRAPLEX {

"""
${ultraplex_command}

## rename the matched files to be able to emit only the matched files
MATCHES=\$( find . -type f -name '*.fastq.gz' ! -name '*_no_match_*.fastq.gz' )
for MATCH in \$MATCHES; do
mv \$MATCH \${MATCH/.fastq.gz/_matched.fastq.gz}
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
done

cat <<-END_VERSIONS > versions.yml
"${task.process}":
ultraplex: $VERSION
END_VERSIONS
"""

stub:
def VERSION = "1.2.5" // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
"""
echo "" | gzip > ultraplex_demux_Sample1_matched.fastq.gz
echo "" | gzip > ultraplex_demux_Sample2_matched.fastq.gz
echo "" | gzip > ultraplex_demux_Sample1_no_match.fastq.gz
echo "" | gzip > ultraplex_demux_Sample2_no_match.fastq.gz

touch ultraplex.log

cat <<-END_VERSIONS > versions.yml
"${task.process}":
ultraplex: $VERSION
Expand Down
148 changes: 148 additions & 0 deletions modules/nf-core/ultraplex/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "ultraplex"

test("ultraplex") {

when {
process {
"""
input[0] = [[id: "test"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/reads/multiplexed.fastq.gz", checkIfExists: true)
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/barcodes.csv", checkIfExists: true)
input[2] = ""
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.fastq,
process.out.no_match_fastq,
process.out.versions).match()},
{ assert process.out.report.get(0) ==~ ".*ultraplex_.*.log" }
)

}

}

test("ultraplex - adaptor") {

when {
process {
"""
input[0] = [[id: "test"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/reads/multiplexed.fastq.gz", checkIfExists: true)
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/barcodes.csv", checkIfExists: true)
input[2] = "AGATCGGAAGAGCGGTTCAG"
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.fastq,
process.out.no_match_fastq,
process.out.versions).match()},
{ assert process.out.report.get(0) ==~ ".*ultraplex_.*.log" }
)
}

}

test("ultraplex - pairedend") {

when {
process {
"""
input[0] = [[id: "test"],
[file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/reads/multiplexed.fastq.gz", checkIfExists: true),
file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/reads/multiplexed2.fastq.gz", checkIfExists: true)]
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/barcodes.csv", checkIfExists: true)
input[2] = ""
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.fastq,
process.out.no_match_fastq,
process.out.versions).match()},
{ assert process.out.report.get(0) ==~ ".*ultraplex_.*.log" }
)
}

}

test("ultraplex - incorrect barcodes") {

when {
process {
"""
input[0] = [[id: "test"],
[ 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) ]
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/barcodes.csv", checkIfExists: true)
input[2] = ""
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.fastq,
process.out.no_match_fastq,
process.out.versions).match()},
{ assert process.out.report.get(0) ==~ ".*ultraplex_.*.log" }
)
}

}


test("ultraplex - stub") {

options "-stub"

when {
process {
"""
input[0] = [[id: "test"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/reads/multiplexed.fastq.gz", checkIfExists: true)
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/clipseq/barcodes.csv", checkIfExists: true)
input[2] = ""
"""
}
}

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

}

}
175 changes: 175 additions & 0 deletions modules/nf-core/ultraplex/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
{
"ultraplex - incorrect barcodes": {
"content": [
[
[
{
"id": "test"
},
[
"ultraplex_demux_Sample2_Fwd_matched.fastq.gz:md5,4451dd878b7d12ff8ceb05fce2ebfa89",
"ultraplex_demux_Sample2_Rev_matched.fastq.gz:md5,f1c6ca8d7f8407b5bb0b6e8906fe41ad"
]
]
],
[

],
[
"versions.yml:md5,916995657ca9c5fd70171d69c3aba409"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-05T06:08:12.106448378"
},
"ultraplex - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_matched.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"ultraplex_demux_Sample2_matched.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
]
],
"1": [
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_no_match.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"ultraplex_demux_Sample2_no_match.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
]
],
"2": [
"ultraplex.log:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"3": [
"versions.yml:md5,916995657ca9c5fd70171d69c3aba409"
],
"fastq": [
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_matched.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"ultraplex_demux_Sample2_matched.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
]
],
"no_match_fastq": [
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_no_match.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"ultraplex_demux_Sample2_no_match.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
]
],
"report": [
"ultraplex.log:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,916995657ca9c5fd70171d69c3aba409"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-05T05:52:36.211334997"
},
"ultraplex - adaptor": {
"content": [
[
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_matched.fastq.gz:md5,77870ddf54ed3e474d4bb63fea65fc08",
"ultraplex_demux_Sample2_matched.fastq.gz:md5,f3960ec2757672915538923ecb3539f8"
]
]
],
[

],
[
"versions.yml:md5,916995657ca9c5fd70171d69c3aba409"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-05T05:54:27.606493007"
},
"ultraplex": {
"content": [
[
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_matched.fastq.gz:md5,77870ddf54ed3e474d4bb63fea65fc08",
"ultraplex_demux_Sample2_matched.fastq.gz:md5,f3960ec2757672915538923ecb3539f8"
]
]
],
[

],
[
"versions.yml:md5,916995657ca9c5fd70171d69c3aba409"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-05T05:54:11.263761896"
},
"ultraplex - pairedend": {
"content": [
[
[
{
"id": "test"
},
[
"ultraplex_demux_Sample1_Fwd_matched.fastq.gz:md5,6b516012c4b19bb0d2109881e3a36102",
"ultraplex_demux_Sample1_Rev_matched.fastq.gz:md5,79637dfeca38bc9314cc5bde37373b5f",
"ultraplex_demux_Sample2_Fwd_matched.fastq.gz:md5,1f17530c291f74a6b29c63ebaba15c96",
"ultraplex_demux_Sample2_Rev_matched.fastq.gz:md5,81ea922ee9842b8f6fe9654406b4f479"
]
]
],
[

],
[
"versions.yml:md5,916995657ca9c5fd70171d69c3aba409"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-05T05:54:44.157822884"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/ultraplex/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ultraplex:
- "modules/nf-core/ultraplex/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1902,9 +1902,6 @@ ultra/index:
ultra/pipeline:
- modules/nf-core/ultra/pipeline/**
- tests/modules/nf-core/ultra/pipeline/**
ultraplex:
- modules/nf-core/ultraplex/**
- tests/modules/nf-core/ultraplex/**
umitools/group:
- modules/nf-core/umitools/group/**
- tests/modules/nf-core/umitools/group/**
Expand Down
Loading
Loading