Skip to content

Commit

Permalink
nf-test + update to genotypegvcfs (#6553)
Browse files Browse the repository at this point in the history
* nf-test + update to genotypegvcfs

* fix linting

* review comments

* fix old typo

* Update modules/nf-core/gatk4/genotypegvcfs/meta.yml

Co-authored-by: Felix Lenner <[email protected]>

* Update modules/nf-core/gatk4/genotypegvcfs/meta.yml

Co-authored-by: Felix Lenner <[email protected]>

* Update modules/nf-core/gatk4/genotypegvcfs/meta.yml

Co-authored-by: Felix Lenner <[email protected]>

* Update modules/nf-core/gatk4/genotypegvcfs/meta.yml

Co-authored-by: Felix Lenner <[email protected]>

* Update modules/nf-core/gatk4/genotypegvcfs/meta.yml

Co-authored-by: Felix Lenner <[email protected]>

---------

Co-authored-by: Felix Lenner <[email protected]>
  • Loading branch information
nvnieuwk and fellen31 authored Sep 5, 2024
1 parent 51d4916 commit 8b74c80
Show file tree
Hide file tree
Showing 8 changed files with 512 additions and 324 deletions.
18 changes: 9 additions & 9 deletions modules/nf-core/gatk4/genotypegvcfs/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ process GATK4_GENOTYPEGVCFS {
'biocontainers/gatk4:4.5.0.0--py36hdfd78af_0' }"

input:
tuple val(meta), path(gvcf), path(gvcf_index), path(intervals), path(intervals_index)
path fasta
path fai
path dict
path dbsnp
path dbsnp_tbi
tuple val(meta), path(input), path(gvcf_index), path(intervals), path(intervals_index)
tuple val(meta2), path(fasta)
tuple val(meta3), path(fai)
tuple val(meta4), path(dict)
tuple val(meta5), path(dbsnp)
tuple val(meta6), path(dbsnp_tbi)

output:
tuple val(meta), path("*.vcf.gz"), emit: vcf
Expand All @@ -26,7 +26,7 @@ process GATK4_GENOTYPEGVCFS {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def gvcf_command = gvcf.name.endsWith(".vcf") || gvcf.name.endsWith(".vcf.gz") ? "$gvcf" : "gendb://$gvcf"
def input_command = input.name.endsWith(".vcf") || input.name.endsWith(".vcf.gz") ? "$input" : "gendb://$input"
def dbsnp_command = dbsnp ? "--dbsnp $dbsnp" : ""
def interval_command = intervals ? "--intervals $intervals" : ""

Expand All @@ -39,7 +39,7 @@ process GATK4_GENOTYPEGVCFS {
"""
gatk --java-options "-Xmx${avail_mem}M -XX:-UsePerfData" \\
GenotypeGVCFs \\
--variant $gvcf_command \\
--variant $input_command \\
--output ${prefix}.vcf.gz \\
--reference $fasta \\
$interval_command \\
Expand All @@ -57,7 +57,7 @@ process GATK4_GENOTYPEGVCFS {
def prefix = task.ext.prefix ?: "${meta.id}"

"""
touch ${prefix}.vcf.gz
echo | gzip > ${prefix}.vcf.gz
touch ${prefix}.vcf.gz.tbi
cat <<-END_VERSIONS > versions.yml
Expand Down
29 changes: 27 additions & 2 deletions modules/nf-core/gatk4/genotypegvcfs/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ input:
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- gvcf:
- input:
type: file
description: |
gVCF(.gz) file or to a GenomicsDB
gVCF(.gz) file or a GenomicsDB
pattern: "*.{vcf,vcf.gz}"
- gvcf_index:
type: file
Expand All @@ -36,22 +36,47 @@ input:
- intervals_index:
type: file
description: Interval index file (optional)
- meta2:
type: map
description: |
Groovy Map containing fasta information
e.g. [ id:'test' ]
- fasta:
type: file
description: Reference fasta file
pattern: "*.fasta"
- meta3:
type: map
description: |
Groovy Map containing fai information
e.g. [ id:'test' ]
- fai:
type: file
description: Reference fasta index file
pattern: "*.fai"
- meta4:
type: map
description: |
Groovy Map containing dict information
e.g. [ id:'test' ]
- dict:
type: file
description: Reference fasta sequence dict file
pattern: "*.dict"
- meta5:
type: map
description: |
Groovy Map containing dbsnp information
e.g. [ id:'test' ]
- dbsnp:
type: file
description: dbSNP VCF file
pattern: "*.vcf.gz"
- meta6:
type: map
description: |
Groovy Map containing dbsnp tbi information
e.g. [ id:'test' ]
- dbsnp_tbi:
type: file
description: dbSNP VCF index file
Expand Down
285 changes: 285 additions & 0 deletions modules/nf-core/gatk4/genotypegvcfs/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "gatk4"
tag "gatk4/genotypegvcfs"
tag "untar"

setup {
run("UNTAR") {
script "../../../untar/main.nf"
process {
"""
input[0] = [
[id:"test"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test_genomicsdb.tar.gz', checkIfExists: true)
]
"""
}
}
}

test("homo_sapiens - [gvcf, idx, [], []], fasta, fai, dict, [], []") {

when {
process {
"""
input[0] = [
[id:"test"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.idx', checkIfExists: true),
[],
[]
]
input[1] = [
[id:"fasta"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists:true)
]
input[2] = [
[id:"fai"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists:true)
]
input[3] = [
[id:"dict"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists:true)
]
input[4] = [[],[]]
input[5] = [[],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf.collect { [it[0], path(it[1]).vcf.variantsMD5] },
process.out.tbi.collect { [it[0], file(it[1]).name] },
process.out.versions
).match() }
)
}

}

test("homo_sapiens - [gvcf_gz, tbi, [], []], fasta, fai, dict, dbsnp, dbsnp_tbi") {

when {
process {
"""
input[0] = [
[id:"test"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz.tbi', checkIfExists: true),
[],
[]
]
input[1] = [
[id:"fasta"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists:true)
]
input[2] = [
[id:"fai"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists:true)
]
input[3] = [
[id:"dict"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists:true)
]
input[4] = [
[id:"dbsnp"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz', checkIfExists:true)
]
input[5] = [
[id:"dbsnp"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz.tbi', checkIfExists:true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf.collect { [it[0], path(it[1]).vcf.variantsMD5] },
process.out.tbi.collect { [it[0], file(it[1]).name] },
process.out.versions
).match() }
)
}

}

test("homo_sapiens - [gvcf_gz, tbi, bed, []], fasta, fai, dict, [], []") {

when {
process {
"""
input[0] = [
[id:"test"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz.tbi', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists:true),
[]
]
input[1] = [
[id:"fasta"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists:true)
]
input[2] = [
[id:"fai"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists:true)
]
input[3] = [
[id:"dict"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists:true)
]
input[4] = [[],[]]
input[5] = [[],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf.collect { [it[0], path(it[1]).vcf.variantsMD5] },
process.out.tbi.collect { [it[0], file(it[1]).name] },
process.out.versions
).match() }
)
}

}

test("homo_sapiens - [gendb, [], [], []], fasta, fai, dict, [], []") {

when {
process {
"""
input[0] = UNTAR.out.untar.map { meta, gendb -> [ meta, gendb, [], [], []] }
input[1] = [
[id:"fasta"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists:true)
]
input[2] = [
[id:"fai"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists:true)
]
input[3] = [
[id:"dict"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists:true)
]
input[4] = [[],[]]
input[5] = [[],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf.collect { [it[0], path(it[1]).vcf.variantsMD5] },
process.out.tbi.collect { [it[0], file(it[1]).name] },
process.out.versions
).match() }
)
}

}

test("homo_sapiens - [gendb, bed, [], []], fasta, fai, dict, [], []") {

when {
process {
"""
input[0] = UNTAR.out.untar.map { meta, gendb ->
[
meta,
gendb,
[],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.bed', checkIfExists:true),
[]
]
}
input[1] = [
[id:"fasta"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists:true)
]
input[2] = [
[id:"fai"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists:true)
]
input[3] = [
[id:"dict"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists:true)
]
input[4] = [[],[]]
input[5] = [[],[]]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.vcf.collect { [it[0], path(it[1]).vcf.variantsMD5] },
process.out.tbi.collect { [it[0], file(it[1]).name] },
process.out.versions
).match() }
)
}

}

test("homo_sapiens - [gvcf, idx, [], []], fasta, fai, dict, [], [] - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[id:"test"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.idx', checkIfExists: true),
[],
[]
]
input[1] = [
[id:"fasta"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists:true)
]
input[2] = [
[id:"fai"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta.fai', checkIfExists:true)
]
input[3] = [
[id:"dict"],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.dict', checkIfExists:true)
]
input[4] = [[],[]]
input[5] = [[],[]]
"""
}
}

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

}

}
Loading

0 comments on commit 8b74c80

Please sign in to comment.