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

Added nf-test for somalier/ancestry #7380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions modules/nf-core/somalier/ancestry/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ process SOMALIER_ANCESTRY {

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed because it cannot be used?


"""
somalier \\
ancestry \\
Expand All @@ -37,4 +35,14 @@ process SOMALIER_ANCESTRY {
END_VERSIONS
"""

stub:
"""
touch "somalier-ancestry.somalier-ancestry.tsv"
touch "somalier-ancestry.somalier-ancestry.html"

cat <<-END_VERSIONS > versions.yml
"${task.process}":
somalier: \$(echo \$(somalier 2>&1) | sed 's/^.*somalier version: //; s/Commands:.*\$//')
END_VERSIONS
"""
}
90 changes: 90 additions & 0 deletions modules/nf-core/somalier/ancestry/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
nextflow_process {

name "Test Process SOMALIER_ANCESTRY"
config "./nextflow.test.config"
script "../main.nf"
process "SOMALIER_ANCESTRY"

tag "modules"
tag "modules_nfcore"
tag "somalier"
tag "somalier/extract"
tag "somalier/ancestry"
tag "untar"

setup {
run("UNTAR") {
script "../../../untar/main.nf"
params {
module_args = "--wildcards '*.somalier'"
}

process {
"""
labelled_somalier_tar = file("https://zenodo.org/record/3479773/files/1kg.somalier.tar.gz")
input[0] = [[id:"1kg"],labelled_somalier_tar]
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
labelled_somalier_tar = file("https://zenodo.org/record/3479773/files/1kg.somalier.tar.gz")
input[0] = [[id:"1kg"],labelled_somalier_tar]
input[0] = [ [id:"1kg"], file("https://zenodo.org/record/3479773/files/1kg.somalier.tar.gz") ]

"""
}
}
}

test("test_somalier_ancestry") {

when {
params {
module_args = ''
}
process {
"""
whole_genome_sommalier = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/somalier/whole_genome.somalier", checkIfExists: true)
labels = file("https://github.com/brentp/somalier/raw/73db124d3fe9febe3a53787707554f863595b48f/scripts/ancestry-labels-1kg.tsv", checkIfExists: true)
Comment on lines +39 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these probably need to be moved from delete_me and also both to the test_datasets repo


ch_labels = Channel.of([[id:"1kg"], labels])
ch_whole_genome_somalier = Channel.of([[id:"test"], whole_genome_sommalier])

input[0] = Channel.of([[id:"test"],whole_genome_sommalier])
input[1] = ch_labels.join(UNTAR.out.untar)
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.tsv[0][1]).text.contains('AFR AFR'),
path(process.out.html[0][1]).text.contains('"ancestry_label":"AMR"'),
process.out.versions
).match()
}
)
}
}


test("test_somalier_ancestry -- stub") {
options '-stub'
when {
params {
module_args = ''
}
process {
"""
whole_genome_sommalier = file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/somalier/whole_genome.somalier", checkIfExists: true)
labels = file("https://github.com/brentp/somalier/raw/73db124d3fe9febe3a53787707554f863595b48f/scripts/ancestry-labels-1kg.tsv", checkIfExists: true)

ch_labels = Channel.of([[id:"1kg"], labels])
ch_whole_genome_somalier = Channel.of([[id:"test"], whole_genome_sommalier])

input[0] = Channel.of([[id:"test"],whole_genome_sommalier])
input[1] = ch_labels.join(UNTAR.out.untar)
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
65 changes: 65 additions & 0 deletions modules/nf-core/somalier/ancestry/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"test_somalier_ancestry": {
"content": [
true,
true,
[
"versions.yml:md5,75c0cd29fd1bf99528a819954cff93c6"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-28T09:39:02.833629"
},
"test_somalier_ancestry -- stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"somalier-ancestry.somalier-ancestry.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "test"
},
"somalier-ancestry.somalier-ancestry.html:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
"versions.yml:md5,75c0cd29fd1bf99528a819954cff93c6"
],
"html": [
[
{
"id": "test"
},
"somalier-ancestry.somalier-ancestry.html:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"tsv": [
[
{
"id": "test"
},
"somalier-ancestry.somalier-ancestry.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,75c0cd29fd1bf99528a819954cff93c6"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-28T09:41:31.001304"
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/somalier/ancestry/tests/nextflow.test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {

withName: "UNTAR" {
ext.args2 = params.module_args
}
}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ snapaligner/align:
snippy/core:
- modules/nf-core/snippy/core/**
- tests/modules/nf-core/snippy/core/**
somalier/ancestry:
- modules/nf-core/somalier/ancestry/**
- tests/modules/nf-core/somalier/ancestry/**
sourmash/gather:
- modules/nf-core/sourmash/gather/**
- tests/modules/nf-core/sourmash/gather/**
Expand Down
26 changes: 0 additions & 26 deletions tests/modules/nf-core/somalier/ancestry/main.nf

This file was deleted.

13 changes: 0 additions & 13 deletions tests/modules/nf-core/somalier/ancestry/nextflow.config

This file was deleted.

13 changes: 0 additions & 13 deletions tests/modules/nf-core/somalier/ancestry/test.yml

This file was deleted.

Loading