Skip to content

Commit

Permalink
Merge branch 'master' into shapeit5_phaserare
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisLeNezet authored Dec 4, 2024
2 parents 08a702c + 175e642 commit 532f301
Show file tree
Hide file tree
Showing 23 changed files with 646 additions and 185 deletions.
2 changes: 1 addition & 1 deletion modules/nf-core/shapeit5/ligate/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ channels:
- conda-forge
- bioconda
dependencies:
- bioconda::shapeit5=1.0.0
- bioconda::shapeit5=5.1.1
14 changes: 7 additions & 7 deletions modules/nf-core/shapeit5/ligate/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ process SHAPEIT5_LIGATE {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/shapeit5:1.0.0--h0c8ee15_0':
'biocontainers/shapeit5:1.0.0--h0c8ee15_0'}"
'https://depot.galaxyproject.org/singularity/shapeit5:5.1.1--hb60d31d_0':
'biocontainers/shapeit5:5.1.1--hb60d31d_0'}"

input:
tuple val(meta), path(input_list), path (input_list_index)
tuple val(meta), path(input_list), path(input_list_index)

output:
tuple val(meta), path("*.{vcf,bcf,vcf.gz,bcf.gz}"), emit: merged_variants
Expand Down Expand Up @@ -37,11 +37,11 @@ process SHAPEIT5_LIGATE {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def suffix = task.ext.suffix ?: "vcf.gz"
def prefix = task.ext.prefix ?: "${meta.id}"
def suffix = task.ext.suffix ?: "vcf.gz"
def create_cmd = suffix.endsWith(".gz") ? "echo '' | gzip >" : "touch"
"""
touch ${prefix}.${suffix}
${create_cmd} ${prefix}.${suffix}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
99 changes: 99 additions & 0 deletions modules/nf-core/shapeit5/ligate/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "shapeit5"
tag "shapeit5/ligate"
tag "bcftools/view"

test("homo sapiens - map, [vcf], [tbi]") {
config "./nextflow.config"
setup {
run("BCFTOOLS_VIEW", alias: "BCFTOOLS_VIEW_1") {
script "../../../bcftools/view"
params {
bcftools_args = "--regions chr22:16570000-16600000 -Ob --write-index=csi -e 'GT=\"./.\"||GT=\".\"'"
}
process {
"""
input[0] = [
[ id:'NA12878_1' ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/vcf/NA12878_GIAB.chr22.vcf.gz", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/vcf/NA12878_GIAB.chr22.vcf.gz.csi", checkIfExists: true),
]
input[1] = []
input[2] = []
input[3] = []
"""
}
}
run("BCFTOOLS_VIEW", alias: "BCFTOOLS_VIEW_2") {
script "../../../bcftools/view"
params {
bcftools_args = "--regions chr22:16580000-16610000 -Ob --write-index=csi -e 'GT=\"./.\"||GT=\".\"'"
}
process {
"""
input[0] = [
[ id:'NA12878_2' ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/vcf/NA12878_GIAB.chr22.vcf.gz", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/vcf/NA12878_GIAB.chr22.vcf.gz.csi", checkIfExists: true),
]
input[1] = []
input[2] = []
input[3] = []
"""
}
}
}

when {
process {
"""
input[0] = BCFTOOLS_VIEW_1.out.vcf.join(BCFTOOLS_VIEW_1.out.csi)
.mix(BCFTOOLS_VIEW_2.out.vcf.join(BCFTOOLS_VIEW_2.out.csi))
.map { meta, vcf, csi -> [ [id : "NA12878"], vcf, csi ] }
.groupTuple()
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.merged_variants.collect {meta, vcf -> [ meta, path(vcf).vcf.summary ]},
process.out.versions
).match() }
)
}
}

test("homo sapiens - map, [vcf], [tbi] - stub") {
options '-stub'

when {
process {
"""
input[0] = [
[id: 'NA12878'],
[file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/vcf/NA12878_GIAB.chr22.vcf.gz", checkIfExists: true)],
[file(params.modules_testdata_base_path + "genomics/homo_sapiens/illumina/vcf/NA12878_GIAB.chr22.vcf.gz.csi", checkIfExists: true)]
]
"""
}
}

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

}
55 changes: 55 additions & 0 deletions modules/nf-core/shapeit5/ligate/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"homo sapiens - map, [vcf], [tbi] - stub": {
"content": [
{
"0": [
[
{
"id": "NA12878"
},
"NA12878.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"1": [
"versions.yml:md5,4b66c655a4fd210ca7bc47b6fe35230b"
],
"merged_variants": [
[
{
"id": "NA12878"
},
"NA12878.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"versions": [
"versions.yml:md5,4b66c655a4fd210ca7bc47b6fe35230b"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-22T17:22:34.235879155"
},
"homo sapiens - map, [vcf], [tbi]": {
"content": [
[
[
{
"id": "NA12878"
},
"VcfFile [chromosomes=[chr22], sampleCount=1, variantCount=60, phased=false, phasedAutodetect=false]"
]
],
[
"versions.yml:md5,4b66c655a4fd210ca7bc47b6fe35230b"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-12-04T10:07:53.185018802"
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/shapeit5/ligate/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: "BCFTOOLS_VIEW_*" {
ext.args = params.bcftools_args
ext.prefix = { "${meta.id}" }
}
}
2 changes: 1 addition & 1 deletion modules/nf-core/shapeit5/switch/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ channels:
- conda-forge
- bioconda
dependencies:
- bioconda::shapeit5=1.0.0
- bioconda::shapeit5=5.1.1
24 changes: 12 additions & 12 deletions modules/nf-core/shapeit5/switch/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process SHAPEIT5_SWITCH {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/shapeit5:1.0.0--h0c8ee15_0':
'biocontainers/shapeit5:1.0.0--h0c8ee15_0'}"
'https://depot.galaxyproject.org/singularity/shapeit5:5.1.1--hb60d31d_0':
'biocontainers/shapeit5:5.1.1--hb60d31d_0'}"

input:
tuple val(meta) , path(estimate), path(estimate_index), val(region), path(pedigree)
Expand Down Expand Up @@ -43,18 +43,18 @@ process SHAPEIT5_SWITCH {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def create_cmd = "echo '' | gzip >"
"""
touch ${prefix}.block.switch.txt.gz
touch ${prefix}.calibration.switch.txt.gz
touch ${prefix}.flipsAndSwitches.txt.gz
touch ${prefix}.frequency.switch.txt.gz
touch ${prefix}.sample.switch.txt.gz
touch ${prefix}.sample.typing.txt.gz
touch ${prefix}.type.switch.txt.gz
touch ${prefix}.variant.switch.txt.gz
touch ${prefix}.variant.typing.txt.gz
${create_cmd} ${prefix}.block.switch.txt.gz
${create_cmd} ${prefix}.calibration.switch.txt.gz
${create_cmd} ${prefix}.flipsAndSwitches.txt.gz
${create_cmd} ${prefix}.frequency.switch.txt.gz
${create_cmd} ${prefix}.sample.switch.txt.gz
${create_cmd} ${prefix}.sample.typing.txt.gz
${create_cmd} ${prefix}.type.switch.txt.gz
${create_cmd} ${prefix}.variant.switch.txt.gz
${create_cmd} ${prefix}.variant.typing.txt.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
105 changes: 105 additions & 0 deletions modules/nf-core/shapeit5/switch/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "shapeit5"
tag "shapeit5/switch"
tag "shapeit5/phasecommon"
tag "bcftools/index"

test("homo sapiens - vcf, scaffold, []") {
config "./nextflow.config"
setup {
run("SHAPEIT5_PHASECOMMON") {
script "../../../shapeit5/phasecommon"
params {
shapeit5_phasecommon_args = "--filter-maf 0.001"
}
process {
"""
input[0] = Channel.of([
[ id:'scaffold', single_end:false ], // meta map
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.vcf.gz", checkIfExists: true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.vcf.gz.csi", checkIfExists: true),
[],
"chr22",
])
input[1] = Channel.of([[],[],[]])
input[2] = Channel.of([[],[],[]])
input[3] = Channel.of([[],[]])
"""
}
}
run("BCFTOOLS_INDEX") {
script "../../../bcftools/index"
process {
"""
input[0] = SHAPEIT5_PHASECOMMON.out.phased_variant
"""
}
}
}

when {
process {
"""
input[0] = SHAPEIT5_PHASECOMMON.out.phased_variant
.join(BCFTOOLS_INDEX.out.csi)
.combine(Channel.of("chr22"))
.combine(Channel.of([[]]))
input[1] = Channel.of([[ id:'truth_panel'],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.vcf.gz",checkIfExists:true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.vcf.gz.csi",checkIfExists:true)
])
input[2] = Channel.of([[ id:'freq_file'],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.sites.vcf.gz",checkIfExists:true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.sites.vcf.gz.csi",checkIfExists:true)
])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.errors.collect { meta, txt -> [ meta, txt.collect{ file(it).name } ] },
process.out.versions
).match() }
)
}

}

test("homo sapiens - vcf, scaffold, [] - stub") {
options "-stub"
when {
process {
"""
input[0] = Channel.of([
[id:'truth_panel'],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.vcf.gz",checkIfExists:true),
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/1000GP.chr22.vcf.gz.csi",checkIfExists:true),
"chr21",
[]
])
input[1] = [[], [], []]
input[2] = [[], [], []]
"""
}
}

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

}

}
Loading

0 comments on commit 532f301

Please sign in to comment.