Skip to content

Commit

Permalink
Add first nf-test tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emi80 committed Apr 18, 2024
1 parent 8aceb37 commit 923014a
Show file tree
Hide file tree
Showing 10 changed files with 442 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config {

testsDir "tests"
workDir ".nf-test"
configFile "tests/nextflow.config"
profile "docker"

}
29 changes: 29 additions & 0 deletions tests/grape-pipeline-markdup.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
nextflow_pipeline {

name "Test Workflow grape-pipeline.nf"
script "grape-pipeline.nf"

profile "+markdup"

test("Should run markdup pipeline") {


when {
params {
// define parameters here. Example:
// outdir = "tests/results"
steps = 'mapping'
}
}

then {
assert workflow.success
assert workflow.trace.failed().size() == 0
assert workflow.trace.succeeded().size() == 20
def lines = file("${launchDir}/pipeline.db").readLines()
assert lines.size() == 9
}

}

}
29 changes: 29 additions & 0 deletions tests/grape-pipeline-starrsem.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
nextflow_pipeline {

name "Test Workflow grape-pipeline.nf"
script "grape-pipeline.nf"

profile "+starrsem"

test("Should run starrsem pipeline") {


when {
params {
// define parameters here. Example:
// outdir = "tests/results"
steps = 'mapping'
}
}

then {
assert workflow.success
assert workflow.trace.failed().size() == 0
assert workflow.trace.succeeded().size() == 17
def lines = file("${launchDir}/pipeline.db").readLines()
assert lines.size() == 9
}

}

}
28 changes: 28 additions & 0 deletions tests/modules/fastaIndex/samtools/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
nextflow_process {

name "Test Process fastaIndex"
script "modules/fastaIndex/samtools/main.nf"
process "fastaIndex"

test("Should produce the fasta index") {

when {
process {
"""
input[0] = "${baseDir}/data/genome.fa"
"""
}
}

then {
assert process.success
assert snapshot(process.out).match()
with(process.out[0]) {
assert size() == 1
assert path(get(0)).md5 == "12d36d122df8dfe8fcfc96d78f785328"
}
}

}

}
16 changes: 16 additions & 0 deletions tests/modules/fastaIndex/samtools/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"Should produce the fasta index": {
"content": [
{
"0": [
"genome.fa.fai:md5,12d36d122df8dfe8fcfc96d78f785328"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-16T11:50:45.127291"
}
}
88 changes: 88 additions & 0 deletions tests/modules/mapping/star/main.index.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
nextflow_process {

name "Test Process index"
script "modules/mapping/star/main.nf"
process "index"

test("Should index compressed references") {

when {
params {
sjOverHang = 100
}
process {
"""
input[0] = file("${baseDir}/data/genome.fa.gz")
input[1] = file("${baseDir}/data/annotation.gtf.gz")
"""
}
}

then {
assert process.success
with(process.out) {
def genomeDir = get(0)[0]
assert path(genomeDir).list().size() == 15
assert snapshot(
path("${genomeDir}/Genome"),
path("${genomeDir}/SA"),
path("${genomeDir}/SAindex"),
path("${genomeDir}/chrLength.txt"),
path("${genomeDir}/chrName.txt"),
path("${genomeDir}/chrNameLength.txt"),
path("${genomeDir}/chrStart.txt"),
path("${genomeDir}/exonGeTrInfo.tab"),
path("${genomeDir}/exonInfo.tab"),
path("${genomeDir}/geneInfo.tab"),
path("${genomeDir}/genomeParameters.txt"),
path("${genomeDir}/sjdbInfo.txt"),
path("${genomeDir}/sjdbList.fromGTF.out.tab"),
path("${genomeDir}/sjdbList.out.tab"),
path("${genomeDir}/transcriptInfo.tab")
).match()
}
}

}

test("Should index uncompressed references") {

when {
params {
sjOverHang = 100
}
process {
"""
input[0] = file("${baseDir}/data/genome.fa")
input[1] = file("${baseDir}/data/annotation.gtf")
"""
}
}

then {
assert process.success
with(process.out) {
def genomeDir = get(0)[0]
assert path(genomeDir).list().size() == 15
assert snapshot(
path("${genomeDir}/Genome"),
path("${genomeDir}/SA"),
path("${genomeDir}/SAindex"),
path("${genomeDir}/chrLength.txt"),
path("${genomeDir}/chrName.txt"),
path("${genomeDir}/chrNameLength.txt"),
path("${genomeDir}/chrStart.txt"),
path("${genomeDir}/exonGeTrInfo.tab"),
path("${genomeDir}/exonInfo.tab"),
path("${genomeDir}/geneInfo.tab"),
path("${genomeDir}/genomeParameters.txt"),
path("${genomeDir}/sjdbInfo.txt"),
path("${genomeDir}/sjdbList.fromGTF.out.tab"),
path("${genomeDir}/sjdbList.out.tab"),
path("${genomeDir}/transcriptInfo.tab")
).match()
}
}

}
}
50 changes: 50 additions & 0 deletions tests/modules/mapping/star/main.index.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"Should index compressed references": {
"content": [
"Genome:md5,7ede3c93094305c2b5c18e2f52110194",
"SA:md5,66c24435d4e28eeddb6a5014ac90c4ef",
"SAindex:md5,71a85071f83b3df03194ded791487bd8",
"chrLength.txt:md5,d5218aeba91780be1b6e6d122fc16089",
"chrName.txt:md5,c6ae136a5ea0ebef9922c1e905c78e01",
"chrNameLength.txt:md5,5c6cc18be0eab93c65b0cf7d65ccdf40",
"chrStart.txt:md5,4ae3effcfe1d1c9d34fcf77a79f5e930",
"exonGeTrInfo.tab:md5,06545472694f13d808a021c152e407ae",
"exonInfo.tab:md5,a5d45fa06470ea940fee46b8278d98b7",
"geneInfo.tab:md5,c60a6703eaa7c4b75f4245eac7a659ab",
"genomeParameters.txt:md5,d32462a2f9c818b4245f57f3198ba83c",
"sjdbInfo.txt:md5,3bde943689ac279664d66d15b20a81c8",
"sjdbList.fromGTF.out.tab:md5,3204292dd60c21bc905145ec15e8f680",
"sjdbList.out.tab:md5,89ad4cd2dd4c868f6c32b29a57c376bb",
"transcriptInfo.tab:md5,3e6f9806497187a01ecbaaab6cce4f25"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-17T17:20:31.357378"
},
"Should index uncompressed references": {
"content": [
"Genome:md5,7ede3c93094305c2b5c18e2f52110194",
"SA:md5,66c24435d4e28eeddb6a5014ac90c4ef",
"SAindex:md5,71a85071f83b3df03194ded791487bd8",
"chrLength.txt:md5,d5218aeba91780be1b6e6d122fc16089",
"chrName.txt:md5,c6ae136a5ea0ebef9922c1e905c78e01",
"chrNameLength.txt:md5,5c6cc18be0eab93c65b0cf7d65ccdf40",
"chrStart.txt:md5,4ae3effcfe1d1c9d34fcf77a79f5e930",
"exonGeTrInfo.tab:md5,06545472694f13d808a021c152e407ae",
"exonInfo.tab:md5,a5d45fa06470ea940fee46b8278d98b7",
"geneInfo.tab:md5,c60a6703eaa7c4b75f4245eac7a659ab",
"genomeParameters.txt:md5,d32462a2f9c818b4245f57f3198ba83c",
"sjdbInfo.txt:md5,3bde943689ac279664d66d15b20a81c8",
"sjdbList.fromGTF.out.tab:md5,3204292dd60c21bc905145ec15e8f680",
"sjdbList.out.tab:md5,89ad4cd2dd4c868f6c32b29a57c376bb",
"transcriptInfo.tab:md5,3e6f9806497187a01ecbaaab6cce4f25"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-17T17:20:43.134729"
}
}
15 changes: 15 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
========================================================================================
Nextflow config file for running tests
========================================================================================
*/

params {
comprExts = ['gz', 'bz2', 'zip']
}

profiles {
docker {
docker.enabled = true
}
}
79 changes: 79 additions & 0 deletions tests/workflows/mapping.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
nextflow_workflow {

name "Test Workflow mapping"
script "workflows/mapping.nf"
workflow "mapping"

test("Should run STAR mapping sorting with sambamba") {

when {
params {
mappingTool = "STAR"
quantificationTool = "RSEM"
sortBamTool = "sambamba"
sjOverHang = 100
maxMismatches = 4
maxMultimaps = 10
}
workflow {
"""
input[0] = file("${baseDir}/data/genome.fa.gz")
input[1] = file("${baseDir}/data/annotation.gtf.gz")
input[2] = Channel.from(
[
[ "sample1", "test1", file("${baseDir}/data/test1_*.fastq.gz"), "fastq", ["fqRd1", "fqRd2"], '']
]
)
"""
}
}

then {
assert workflow.success
assert snapshot(
workflow.out.genomeAlignments,
workflow.out.genomeAlignmentsIndices,
workflow.out.transcriptomeAlignments,
workflow.out.junctions
).match()
}

}

test("Should run STAR mapping sorting with samtools") {

when {
params {
mappingTool = "STAR"
quantificationTool = "RSEM"
sortBamTool = "samtools"
sjOverHang = 100
maxMismatches = 4
maxMultimaps = 10
}
workflow {
"""
input[0] = file("${baseDir}/data/genome.fa")
input[1] = file("${baseDir}/data/annotation.gtf")
input[2] = Channel.from(
[
[ "sample1", "test1", file("${baseDir}/data/test1_*.fastq.gz"), "fastq", ["fqRd1", "fqRd2"], '']
]
)
"""
}
}

then {
assert workflow.success
assert snapshot(
workflow.out.genomeAlignments,
workflow.out.genomeAlignmentsIndices,
workflow.out.transcriptomeAlignments,
workflow.out.junctions
).match()
}

}

}
Loading

0 comments on commit 923014a

Please sign in to comment.