Skip to content

Commit

Permalink
Add nf-test for mergeBam module and merging workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
emi80 committed May 2, 2024
1 parent 82b08ce commit f64b16a
Show file tree
Hide file tree
Showing 10 changed files with 411 additions and 0 deletions.
Binary file added data/test2/sample2_m4_n10_toGenome_sorted.bam
Binary file not shown.
Binary file not shown.
Binary file added data/test3/sample2_m4_n10_toGenome_sorted.bam
Binary file not shown.
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/modules/mergeBam/sambamba/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
nextflow_process {

name "Test Process mergeBam"
script "modules/mergeBam/sambamba/main.nf"
process "mergeBam"

tag "module"

test("Should merge BAM files using sambamba") {

when {
params {
maxMismatches = 4
maxMultimaps = 10
}
process {
"""
input[0] = Channel.from([
[ "sample2", [ "test2", "test3" ], file("${baseDir}/data/test*/*.bam"), "bam", "GenomeAlignments", true]
])
"""
}
}

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

}

}
23 changes: 23 additions & 0 deletions tests/modules/mergeBam/sambamba/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"Should merge BAM files using sambamba": {
"content": [
{
"0": [
[
"sample2",
"test2:test3",
"sample2_m4_n10_toGenome.bam:md5,724ebe0d965d40decaa80c6b09e47ba5",
"bam",
"GenomeAlignments",
true
]
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-05-02T11:08:00.400122"
}
}
32 changes: 32 additions & 0 deletions tests/modules/mergeBam/samtools/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
nextflow_process {

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

tag "module"

test("Should merge BAM files using samtools") {

when {
params {
maxMismatches = 4
maxMultimaps = 10
}
process {
"""
input[0] = Channel.from([
[ "sample2", [ "test2", "test3" ], file("${baseDir}/data/test*/*.bam"), "bam", "GenomeAlignments", true]
])
"""
}
}

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

}

}
23 changes: 23 additions & 0 deletions tests/modules/mergeBam/samtools/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"Should merge BAM files using samtools": {
"content": [
{
"0": [
[
"sample2",
"test2:test3",
"sample2_m4_n10_toGenome.bam:md5,1aafe9aacc6e403ed8a5466a30549c85",
"bam",
"GenomeAlignments",
true
]
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-05-02T11:27:59.686395"
}
}
123 changes: 123 additions & 0 deletions tests/workflows/merging.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
nextflow_workflow {

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

tag "workflow"

test("Should merge genome BAM files using sambamba") {

when {
params {
maxMismatches = 4
maxMultimaps = 10
mergeBamTool = "sambamba"
markdupTool = "sambamba"
}
workflow {
"""
input[0] = Channel.from([
[ "sample2", "test2", file("${baseDir}/data/test2/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true],
[ "sample2", "test3", file("${baseDir}/data/test3/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true]
])
input[1] = Channel.empty()
"""
}
}

then {
assert workflow.success
assert snapshot(workflow.out).match()
}

}

test("Should merge genome BAM files using samtools") {

when {
params {
maxMismatches = 4
maxMultimaps = 10
mergeBamTool = "samtools"
markdupTool = "sambamba"
}
workflow {
"""
input[0] = Channel.from([
[ "sample2", "test2", file("${baseDir}/data/test2/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true],
[ "sample2", "test3", file("${baseDir}/data/test3/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true]
])
input[1] = Channel.empty()
"""
}
}

then {
assert workflow.success
assert snapshot(workflow.out).match()
}

}

test("Should merge all BAM files using samtools") {

when {
params {
maxMismatches = 4
maxMultimaps = 10
mergeBamTool = "samtools"
markdupTool = "sambamba"
}
workflow {
"""
input[0] = Channel.from([
[ "sample2", "test2", file("${baseDir}/data/test2/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true],
[ "sample2", "test3", file("${baseDir}/data/test3/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true]
])
input[1] = Channel.from([
[ "sample2", "test2", file("${baseDir}/data/test2/sample2_m4_n10_toTranscriptome_sorted.bam"), "bam", "TranscriptomeAlignments", true],
[ "sample2", "test3", file("${baseDir}/data/test3/sample2_m4_n10_toTranscriptome_sorted.bam"), "bam", "TranscriptomeAlignments", true]
])
"""
}
}

then {
assert workflow.success
assert snapshot(workflow.out).match()
}

}

test("Should merge all BAM files using sambamba") {

when {
params {
maxMismatches = 4
maxMultimaps = 10
mergeBamTool = "sambamba"
markdupTool = "sambamba"
}
workflow {
"""
input[0] = Channel.from([
[ "sample2", "test2", file("${baseDir}/data/test2/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true],
[ "sample2", "test3", file("${baseDir}/data/test3/sample2_m4_n10_toGenome_sorted.bam"), "bam", "GenomeAlignments", true]
])
input[1] = Channel.from([
[ "sample2", "test2", file("${baseDir}/data/test2/sample2_m4_n10_toTranscriptome_sorted.bam"), "bam", "TranscriptomeAlignments", true],
[ "sample2", "test3", file("${baseDir}/data/test3/sample2_m4_n10_toTranscriptome_sorted.bam"), "bam", "TranscriptomeAlignments", true]
])
"""
}
}

then {
assert workflow.success
assert snapshot(workflow.out).match()
}

}

}
Loading

0 comments on commit f64b16a

Please sign in to comment.