Skip to content

Commit

Permalink
add stubs for all + test for most
Browse files Browse the repository at this point in the history
  • Loading branch information
maxulysse committed Jun 21, 2024
1 parent 858cd5d commit 451483b
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 11 deletions.
10 changes: 10 additions & 0 deletions modules/local/gtf2bed/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ process GTF2BED {
perl: \$(echo \$(perl --version 2>&1) | sed 's/.*v\\(.*\\)) built.*/\\1/')
END_VERSIONS
"""

stub:
"""
touch ${gtf.baseName}.bed
cat <<-END_VERSIONS > versions.yml
"${task.process}":
perl: \$(echo \$(perl --version 2>&1) | sed 's/.*v\\(.*\\)) built.*/\\1/')
END_VERSIONS
"""
}
19 changes: 19 additions & 0 deletions modules/local/gtf2bed/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ nextflow_process {
{ assert snapshot(process.out).match() }
)
}
}

test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = file(params.modules_testdata_base_path + "genomics/sarscov2/genome/genome.gtf", checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
23 changes: 23 additions & 0 deletions modules/local/gtf2bed/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
{
"sarscov2 - bam - stub": {
"content": [
{
"0": [
"genome.bed:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"versions.yml:md5,d04d815c224b980b6f3818d4b2fd4fe3"
],
"bed": [
"genome.bed:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,d04d815c224b980b6f3818d4b2fd4fe3"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-21T11:46:28.123826"
},
"sarscov2 - bam": {
"content": [
{
Expand Down
10 changes: 10 additions & 0 deletions modules/local/gtf_filter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,14 @@ process GTF_FILTER {
python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""

stub:
"""
touch ${fasta.baseName}.filtered.gtf
cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""
}
23 changes: 21 additions & 2 deletions modules/local/gtf_filter/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nextflow_process {
script "../main.nf"
process "GTF_FILTER"

test("Should run without failures") {
test("sarscov2 - fasta - gtf") {

when {
process {
Expand All @@ -21,7 +21,26 @@ nextflow_process {
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - fasta - gtf - stub") {

options "-stub"

when {
process {
"""
input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.gtf', checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
29 changes: 26 additions & 3 deletions modules/local/gtf_filter/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Should run without failures": {
"sarscov2 - fasta - gtf": {
"content": [
{
"0": [
Expand All @@ -18,8 +18,31 @@
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nextflow": "24.04.2"
},
"timestamp": "2024-03-06T15:52:37.977802"
"timestamp": "2024-06-21T11:47:56.314297"
},
"sarscov2 - fasta - gtf - stub": {
"content": [
{
"0": [
"genome.filtered.gtf:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"versions.yml:md5,4adf55ec05d247fd6d253459bd80856f"
],
"genome_gtf": [
"genome.filtered.gtf:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,4adf55ec05d247fd6d253459bd80856f"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-21T11:48:19.085835"
}
}
12 changes: 12 additions & 0 deletions modules/local/multiqc_custom_biotype/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@ process MULTIQC_CUSTOM_BIOTYPE {
python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.biotype_counts_mqc.tsv
touch ${prefix}.biotype_counts_rrna_mqc.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
python: \$(python --version | sed 's/Python //g')
END_VERSIONS
"""
}
26 changes: 25 additions & 1 deletion modules/local/multiqc_custom_biotype/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,31 @@ nextflow_process {
{ assert snapshot(process.out).match()}
)
}

}

test("test sarscov2 count data - stub") {

options "-stub"

when {
process {
"""
input[0] = Channel.of(
[
[ id: 'test' ],
file(params.pipelines_testdata_base_path + 'multiqc_custom_biotype/test.featureCounts.txt', checkIfExists: true)
]
)
input[1] = file(params.pipelines_testdata_base_path + 'multiqc_custom_biotype/biotypes_header.txt', checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success},
{ assert snapshot(process.out).match()}
)
}
}
}
39 changes: 39 additions & 0 deletions modules/local/multiqc_custom_biotype/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,44 @@
"nextflow": "24.01.0"
},
"timestamp": "2024-03-08T09:38:04.260609"
},
"test sarscov2 count data - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
[
"test.biotype_counts_mqc.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
"test.biotype_counts_rrna_mqc.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"1": [
"versions.yml:md5,575b3b4c8a8a6e508c8ceeca41331b6b"
],
"tsv": [
[
{
"id": "test"
},
[
"test.biotype_counts_mqc.tsv:md5,d41d8cd98f00b204e9800998ecf8427e",
"test.biotype_counts_rrna_mqc.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
],
"versions": [
"versions.yml:md5,575b3b4c8a8a6e508c8ceeca41331b6b"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-21T11:50:15.104113"
}
}
12 changes: 12 additions & 0 deletions modules/local/preprocess_transcripts_fasta_gencode/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ process PREPROCESS_TRANSCRIPTS_FASTA_GENCODE {
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""

stub:
def gzipped = fasta.toString().endsWith('.gz')
def outfile = gzipped ? file(fasta.baseName).baseName : fasta.baseName
"""
touch ${outfile}.fixed.fa
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,33 @@ nextflow_process {
{ assert snapshot(process.out).match() }
)
}

}

test("gencode fasta - stub") {

options "-stub"

when {
process {
"""
def fileContents = [
'>chr22|removeme',
'ACTCAAGATAATGATGAGTAAAGAATATATTTCTAACAACAAAAAGGAAATTTGATAGTA'
]
def gencodeFasta = file("${workDir}/gencodeFasta.fasta")
gencodeFasta.withWriter{ out ->
fileContents.each {out.println it}
}
input[0] = gencodeFasta
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,28 @@
"nextflow": "23.10.1"
},
"timestamp": "2024-03-06T16:16:36.494744"
},
"gencode fasta - stub": {
"content": [
{
"0": [
"gencodeFasta.fixed.fa:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"1": [
"versions.yml:md5,e2c7f636c472887a914b128d1444737e"
],
"fasta": [
"gencodeFasta.fixed.fa:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,e2c7f636c472887a914b128d1444737e"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-21T11:54:20.291494"
}
}
13 changes: 13 additions & 0 deletions modules/local/rsem_merge_counts/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ process RSEM_MERGE_COUNTS {
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""

stub:
"""
touch rsem.merged.gene_counts.tsv
touch rsem.merged.gene_tpm.tsv
touch rsem.merged.transcript_counts.tsv
touch rsem.merged.transcript_tpm.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
sed: \$(echo \$(sed --version 2>&1) | sed 's/^.*GNU sed) //; s/ .*\$//')
END_VERSIONS
"""
}
Loading

0 comments on commit 451483b

Please sign in to comment.