Skip to content

Commit

Permalink
Added nf-test for hapibd (#6575)
Browse files Browse the repository at this point in the history
  • Loading branch information
GallVp authored Sep 5, 2024
1 parent db53f41 commit db2057c
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 58 deletions.
21 changes: 21 additions & 0 deletions modules/nf-core/hapibd/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,25 @@ process HAPIBD {
hapibd: \$(hap-ibd 2>&1 |head -n1 | sed 's/^hap-ibd.jar \\[ version //; s/, /rev/; s/ \\]//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"

def avail_mem = 3072
if (!task.memory) {
log.info '[hapibd] Available memory not known - defaulting to 3GB. Specify process memory requirements to change this.'
} else {
avail_mem = (task.memory.mega*0.8).intValue()
}

"""
touch ${prefix}.log
echo | gzip > ${prefix}.hbd.gz
echo | gzip > ${prefix}.ibd.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
hapibd: \$(hap-ibd 2>&1 |head -n1 | sed 's/^hap-ibd.jar \\[ version //; s/, /rev/; s/ \\]//')
END_VERSIONS
"""
}
2 changes: 1 addition & 1 deletion modules/nf-core/hapibd/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tools:
homepage: "https://github.com/browning-lab/hap-ibd/blob/master/README.md"
documentation: "https://github.com/browning-lab/hap-ibd/blob/master/README.md"
doi: "10.1016/j.ajhg.2020.02.010"
licence: "['Apache-2.0']"
licence: ["Apache-2.0"]
input:
- meta:
type: map
Expand Down
99 changes: 99 additions & 0 deletions modules/nf-core/hapibd/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "hapibd"

test("test-hapibd") {

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/target.truth.vcf.gz", checkIfExists: true)
]
input[1] = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/target.map", checkIfExists: true)
input[2] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert file(process.out.log[0][1]).text.contains('End Time') },
{ assert snapshot(
file(process.out.hbd[0][1]).name, // empty
file(process.out.ibd[0][1]).name, // unstable
file(process.out.log[0][1]).name,
process.out.versions
).match()
}
)
}
}

test("test-hapibd-excludesamples") {

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/target.truth.vcf.gz", checkIfExists: true)
]
input[1] = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/target.map", checkIfExists: true)
input[2] = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/excludeSamples.txt", checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert file(process.out.log[0][1]).text.contains('End Time') },
{ assert snapshot(
file(process.out.hbd[0][1]).name, // empty
file(process.out.ibd[0][1]).name, // unstable
file(process.out.log[0][1]).name,
process.out.versions
).match()
}
)
}
}

test("test-hapibd-excludesamples-stub") {
options '-stub'

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/target.truth.vcf.gz", checkIfExists: true)
]
input[1] = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/target.map", checkIfExists: true)
input[2] = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/hapibd/excludeSamples.txt", checkIfExists: true)
"""
}
}

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

}
103 changes: 103 additions & 0 deletions modules/nf-core/hapibd/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"test-hapibd": {
"content": [
"test.hbd.gz",
"test.ibd.gz",
"test.log",
[
"versions.yml:md5,27c1ec7c19884a358c01031f02604c2a"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-05T21:50:07.8312"
},
"test-hapibd-excludesamples": {
"content": [
"test.hbd.gz",
"test.ibd.gz",
"test.log",
[
"versions.yml:md5,27c1ec7c19884a358c01031f02604c2a"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-05T21:50:29.730739"
},
"test-hapibd-excludesamples-stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.hbd.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"1": [
[
{
"id": "test",
"single_end": false
},
"test.ibd.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"2": [
[
{
"id": "test",
"single_end": false
},
"test.log:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"3": [
"versions.yml:md5,27c1ec7c19884a358c01031f02604c2a"
],
"hbd": [
[
{
"id": "test",
"single_end": false
},
"test.hbd.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"ibd": [
[
{
"id": "test",
"single_end": false
},
"test.ibd.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"log": [
[
{
"id": "test",
"single_end": false
},
"test.log:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,27c1ec7c19884a358c01031f02604c2a"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-05T21:40:49.71258"
}
}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ gunc/mergecheckm:
gunc/run:
- modules/nf-core/gunc/run/**
- tests/modules/nf-core/gunc/run/**
hapibd:
- modules/nf-core/hapibd/**
- tests/modules/nf-core/hapibd/**
hicexplorer/hicpca:
- modules/nf-core/hicexplorer/hicpca/**
- tests/modules/nf-core/hicexplorer/hicpca/**
Expand Down
28 changes: 0 additions & 28 deletions tests/modules/nf-core/hapibd/main.nf

This file was deleted.

5 changes: 0 additions & 5 deletions tests/modules/nf-core/hapibd/nextflow.config

This file was deleted.

21 changes: 0 additions & 21 deletions tests/modules/nf-core/hapibd/test.yml

This file was deleted.

0 comments on commit db2057c

Please sign in to comment.