Skip to content

Commit

Permalink
Added nf-test for angsd/contamination (#6602)
Browse files Browse the repository at this point in the history
* Added nf-test for angsd/contamination

* Swap container version

* Update snapshot

---------

Co-authored-by: Simon Pearce <[email protected]>
Co-authored-by: Phil Ewels <[email protected]>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent 9897e69 commit 97504fc
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 48 deletions.
16 changes: 14 additions & 2 deletions modules/nf-core/angsd/contamination/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process ANGSD_CONTAMINATION {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/angsd:0.939--h468462d_0':
'biocontainers/angsd:0.939--h468462d_0' }"
'https://depot.galaxyproject.org/singularity/angsd:0.940--hf5e1c6e_3':
'biocontainers/angsd:0.940--hf5e1c6e_3' }"

input:
tuple val(meta), path(icounts)
Expand All @@ -30,6 +30,18 @@ process ANGSD_CONTAMINATION {
2> >(tee ${prefix}.txt >&2)
cat <<-END_VERSIONS > versions.yml
"${task.process}":
angsd: \$(echo \$(angsd 2>&1) | grep version | head -n 1 | sed 's/.*version: //g;s/ .*//g')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
angsd: \$(echo \$(angsd 2>&1) | grep version | head -n 1 | sed 's/.*version: //g;s/ .*//g')
Expand Down
5 changes: 5 additions & 0 deletions modules/nf-core/angsd/contamination/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ input:
type: file
description: Internal format for dumping binary single chrs. Useful for ANGSD contamination
pattern: "*.icnts.gz"
- meta2:
type: map
description: |
Groovy Map containing information related to the hapmap_file.
e.g. [ id:'test' ]
- hapmap_file:
type: file
description: A list of variable sites to look for heterozygosity.
Expand Down
78 changes: 78 additions & 0 deletions modules/nf-core/angsd/contamination/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "angsd"
tag "angsd/contamination"
tag "angsd/docounts"

setup {
run("ANGSD_DOCOUNTS") {
script "../../../angsd/docounts/main.nf"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.markduplicates.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.markduplicates.sorted.bam.bai', checkIfExists: true),
[]
]
"""
}
}
}

test("test-angsd-contamination") {

when {
process {
"""
input[0] = ANGSD_DOCOUNTS.out.icounts
input[1] = [ [id:'test2'], file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/angsd/HapMapChrX.gz")]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.txt[0][1]).readLines()[3..7],
file(process.out.versions[0]).readLines(),
process.out.versions
).match()
}
)
}
}

test("test-angsd-contamination-stub") {
options '-stub'

when {
process {
"""
input[0] = ANGSD_DOCOUNTS.out.icounts
input[1] = [ [id:'test2'], file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/angsd/HapMapChrX.gz")]
"""
}
}

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

}
60 changes: 60 additions & 0 deletions modules/nf-core/angsd/contamination/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"test-angsd-contamination": {
"content": [
[
"Seed value of 0 (zero) will use time as seed",
"-----------------",
"[readhap] We now have: 58190 snpSites after filtering based on hapMapfile",
"[readicnts] fname:test.icnts.gz minDepth:2 maxDepth:200",
"[readicnts] Has read:1557012 sites, 1517472 sites (after depfilter) from ANGSD icnts file"
],
[
"\"ANGSD_CONTAMINATION\":",
" angsd: 0.940-dirty"
],
[
"versions.yml:md5,e496b7eb11be581adf1781883ba2abff"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-09T05:53:42.620175303"
},
"test-angsd-contamination-stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,e496b7eb11be581adf1781883ba2abff"
],
"txt": [
[
{
"id": "test",
"single_end": false
},
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,e496b7eb11be581adf1781883ba2abff"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-09T05:53:56.844309422"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/angsd/contamination/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: ANGSD_DOCOUNTS {
ext.args = "-iCounts 1 -doDepth -dumpCounts 2"
}
}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
amps:
- modules/nf-core/amps/**
- tests/modules/nf-core/amps/**
angsd/contamination:
- modules/nf-core/angsd/contamination/**
- tests/modules/nf-core/angsd/contamination/**
arriba/arriba:
- modules/nf-core/arriba/arriba/**
- tests/modules/nf-core/arriba/arriba/**
Expand Down
23 changes: 0 additions & 23 deletions tests/modules/nf-core/angsd/contamination/main.nf

This file was deleted.

9 changes: 0 additions & 9 deletions tests/modules/nf-core/angsd/contamination/nextflow.config

This file was deleted.

11 changes: 0 additions & 11 deletions tests/modules/nf-core/angsd/contamination/test.yml

This file was deleted.

0 comments on commit 97504fc

Please sign in to comment.