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

port parabricks/deepvariant to nf-test #6995

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .github/conda_skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ exclude:
path: modules/nf-core/xeniumranger/resegment
- profile: conda
path: modules/nf-core/xeniumranger/import-segmentation
- profile: conda
path: modules/nf-core/parabricks/deepvariant
- profile: conda
path: modules/nf-core/parabricks/dbsnp
- profile: conda
Expand Down
15 changes: 7 additions & 8 deletions modules/nf-core/parabricks/deepvariant/main.nf
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
process PARABRICKS_DEEPVARIANT {
tag "$meta.id"
label 'process_high'
label 'process_gpu'
stageInMode 'copy' // needed by the module to work properly can be removed when fixed upstream

container "nvcr.io/nvidia/clara/clara-parabricks:4.3.0-1"
container "nvcr.io/nvidia/clara/clara-parabricks:4.4.0-1"

input:
tuple val(meta), path(input), path(input_index), path(interval_file)
Expand All @@ -16,25 +18,23 @@ process PARABRICKS_DEEPVARIANT {
task.ext.when == null || task.ext.when

script:

// Exit if running this module with -profile conda / -profile mamba
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
exit 1, "Parabricks module does not support Conda. Please use Docker / Singularity / Podman instead."
}

def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def output_file = args =~ "gvcf" ? "${prefix}.g.vcf" : "${prefix}.vcf"
def output_file = ("--gvcf" =~ task.ext.args)? "${prefix}.g.vcf" : "${prefix}.vcf"
def interval_file_command = interval_file ? interval_file.collect{"--interval-file $it"}.join(' ') : ""
def num_gpus = task.accelerator ? "--num-gpus $task.accelerator.request" : ''
"""

pbrun \\
deepvariant \\
--ref $fasta \\
--in-bam $input \\
--out-variants $output_file \\
$interval_file_command \\
--num-gpus $task.accelerator.request \\
$num_gpus \\
$args

cat <<-END_VERSIONS > versions.yml
Expand All @@ -44,9 +44,8 @@ process PARABRICKS_DEEPVARIANT {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def output_file = args =~ "gvcf" ? "${prefix}.g.vcf" : "${prefix}.vcf"
def output_file = ("--gvcf" =~ task.ext.args)? "${prefix}.g.vcf" : "${prefix}.vcf"
"""
touch $output_file

Expand Down
178 changes: 178 additions & 0 deletions modules/nf-core/parabricks/deepvariant/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "parabricks"
tag "parabricks/deepvariant"
tag "gpu"

test("human - bam") {

when {
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true),
[], // bam.bai not needed unless using intervals
[]
]
input[1] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
]
"""
}
}

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

}

test("human - bam - intervals") {

config './nextflow.config'

when {
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true)
]
input[1] = [
[ id:'ref'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
]
"""
}
}

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

}

test("human - bam - intervals - gvcf") {

config './nextflow.config'

when {
params {
module_args = '--gvcf'
}
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true)
]
input[1] = [
[ id:'ref'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
// file(process.out.vcf[0][1]).name // fails with groovy.lang.MissingMethodException: No signature of method: static com.askimed.nf.test.lang.extensions.GlobalMethods.file() is applicable for argument types: (ArrayList) values:
).match()
}
)
}

}

test("human - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true),
[], // bam.bai not needed unless using intervals
[]
]
input[1] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
]
"""
}
}

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

}

test("human - bam - intervals - gvcf - stub") {

config './nextflow.config'
options "-stub"

when {
params {
module_args = '--gvcf'
}
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true)
]
input[1] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true)
]
"""
}
}

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

}

}
106 changes: 106 additions & 0 deletions modules/nf-core/parabricks/deepvariant/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"human - bam - intervals - gvcf": {
"content": [
[
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-14T15:26:48.481295634"
},
"human - bam - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
],
"vcf": [
[
{
"id": "test"
},
"test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-14T15:05:28.449273519"
},
"human - bam - intervals": {
"content": [
"27097afc7aae62918a3e26790cc189c3",
[
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-14T15:06:52.854870182"
},
"human - bam": {
"content": [
"8b526a232f93a5036176336415abf7d1",
[
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-14T15:06:37.651354312"
},
"human - bam - intervals - gvcf - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.g.vcf:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
],
"vcf": [
[
{
"id": "test"
},
"test.g.vcf:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,c7bcf80d609e2951eb99f0b774cd2f6d"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.0"
},
"timestamp": "2024-11-14T15:12:11.438654866"
}
}
7 changes: 7 additions & 0 deletions modules/nf-core/parabricks/deepvariant/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
process {

withName: 'PARABRICKS_DEEPVARIANT' {
ext.args = 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 @@ -392,9 +392,6 @@ ncbitools/vecscreen:
oncocnv:
- modules/nf-core/oncocnv/**
- tests/modules/nf-core/oncocnv/**
parabricks/deepvariant:
- modules/nf-core/parabricks/deepvariant/**
- tests/modules/nf-core/parabricks/deepvariant/**
parabricks/haplotypecaller:
- modules/nf-core/parabricks/haplotypecaller/**
- tests/modules/nf-core/parabricks/haplotypecaller/**
Expand Down
Loading
Loading