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

pypgx/runngspipeline #6823

Open
wants to merge 3 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
7 changes: 7 additions & 0 deletions modules/nf-core/pypgx/runngspipeline/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::pypgx=0.25.0
58 changes: 58 additions & 0 deletions modules/nf-core/pypgx/runngspipeline/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
process PYPGX_RUNNGSPIPELINE {
tag "$meta.id"
label 'process_low'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/pypgx:0.25.0--pyh7e72e81_0':
'biocontainers/pypgx:0.25.0--pyh7e72e81_0' }"

input:
tuple val(meta), path(vcf), path(tbi), path(coverage), path(control_stats), val(pgx_gene)
tuple val(meta2), path(resource_bundle)
val(assembly_version)

output:
tuple val(meta), val(pgx_gene), path("*pypgx_output"), emit: outdir
path("versions.yml"), emit: versions

when:
task.ext.when == null || task.ext.when

script:
def prefix = task.ext.prefix ?: "${meta.id}_${pgx_gene}"
def assembly = assembly_version ?: "GRCh38"

"""
export MPLCONFIGDIR="/tmp/"
export PYPGX_BUNDLE=${resource_bundle}/

pypgx run-ngs-pipeline \\
--assembly ${assembly} \\
${pgx_gene} \\
${prefix}_pypgx_output/ \\
--variants ${vcf} \\
--depth-of-coverage ${coverage} \\
--control-statistics ${control_stats}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
pypgx: \$(echo \$(pypgx -v 2>&1) | sed 's/.* //')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}_${pgx_gene}"

"""
mkdir ${prefix}_pypgx_output
# zip program unavailable in container
python -c 'import zipfile; zipfile.ZipFile("${prefix}_pypgx_output/results.zip", "w").close()'

cat <<-END_VERSIONS > versions.yml
"${task.process}":
pypgx: \$(echo \$(pypgx -v 2>&1) | sed 's/.* //')
END_VERSIONS
"""
}
77 changes: 77 additions & 0 deletions modules/nf-core/pypgx/runngspipeline/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "pypgx_runngspipeline"

description: PyPGx pharmacogenomics genotyping pipeline for NGS data.
keywords:
- pypgx
- pharmacogenetics
- genotyping
tools:
- "pypgx":
description: "A Python package for pharmacogenomics research"
homepage: "https://pypgx.readthedocs.io/en/latest/"
documentation: "https://pypgx.readthedocs.io/en/latest/"
tool_dev_url: "https://github.com/sbslee/pypgx"
doi: "10.1371/journal.pone.0272129"
licence: ["MIT"]
identifier: ""

input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`.
- vcf:
type: file
description: BGZIP compressed VCF file with SNVs/indels. Output of pypgx/createinputvcf.
pattern: "*.{vcf.gz}"
- tbi:
type: file
description: VCF tabix index.
pattern: "*.{vcf.gz.tbi}"
- coverage:
type: file
description: ZIP compressed file with depth of coverage information. Output
of pypgx/preparedepthofcoverage.
pattern: "*.{zip}"
- control_stats:
type: file
description: ZIP compressed file with control statistics. Output of pypgx/computecontrolstatistics.
- pgx_gene:
type: string
description: Pharmacogene to genotype/phenotype.
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`.
- resource_bundle:
type: directory
description: Path to the pypgx resource bundle (https://github.com/sbslee/pypgx-bundle).
- - assembly_version:
type: string
description: Genome assembly version to use.
output:
- outdir:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- pgx_gene:
type: string
description: Pharmacogene used to genotype/phenotype
- "*pypgx_output":
type: directory
description: Directory containing all pipeline output files
pattern: "*pypgx_output*"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@jorivansteenbrugge"
maintainers:
- "@jorivansteenbrugge"
125 changes: 125 additions & 0 deletions modules/nf-core/pypgx/runngspipeline/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "pypgx"
tag "pypgx/runngspipeline"
tag "pypgx/createinputvcf"
tag "pypgx/computecontrolstatistics"
tag "pypgx/preparedepthofcoverage"
tag "untar"

test("human paired end bam - CYP2D6 locus - GRCh37 - CYP2D6 pharmacogene") {
setup {
run("PYPGX_CREATEINPUTVCF") {
script "../../createinputvcf/main.nf"
process {
"""
input[0] = [
[id: 'test'], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam.bai', checkIfExists: true)
]
input[1] = [
[id: 'GRCh37'], // meta2 map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/GRCh37_chr22.fasta.gz', checkIfExists: true)
]
input[2] = ["CYP2D6"] // Pharmacogene
input[3] = "GRCh37" // assembly version
"""
}
}
run("PYPGX_PREPAREDEPTHOFCOVERAGE") {
script "../../preparedepthofcoverage"
process {
"""
input[0] = [
[id: 'test'], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam.bai', checkIfExists: true)
]
input[1] = ["CYP2D6"] // Pharmacogene
input[2] = "GRCh37" // assembly version
"""
}
}
run("PYPGX_COMPUTECONTROLSTATISTICS") {
script "../../computecontrolstatistics/main.nf"
process {
"""
input[0] = [
[id: 'test'], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.PGx.CYP2D6.bam.bai', checkIfExists: true)
]
input[1] = "22:42512500-42551883"
input[2] = "GRCh37" // assembly version
"""
}
}
run("UNTAR") {
script "../../../untar/main.nf"
process {
"""
input[0] = [
[id: 'resource_bundle'],
file('https://github.com/sbslee/pypgx-bundle/archive/refs/tags/0.25.0.tar.gz')
]
"""
}
}
}
when {
process {
"""
input[0] = PYPGX_CREATEINPUTVCF.out.vcf
.join(PYPGX_CREATEINPUTVCF.out.tbi)
.join(PYPGX_PREPAREDEPTHOFCOVERAGE.out.coverage)
.join(PYPGX_COMPUTECONTROLSTATISTICS.out.control_stats)
.combine(Channel.fromList(["CYP2D6"]))
input[1] = UNTAR.out.untar // resource bundle
input[2] = 'GRCh37' //assembly version
"""
}
}
then {
def outDir = process.out.outdir[0][2]
def zipFile = path(outDir+"/results.zip").zip
def paths = zipFile.extractAll()
def metaFile = paths.find { it.getFileName().toString() == 'metadata.txt' }

assertAll(
{ assert process.success },
{ assert zipFile.isValid() },
{ assert paths.size() == 2 },
{ assert snapshot(
metaFile,
process.out.versions).match()}
)
}

}

test("stub") {
options "-stub"
when {
process {
"""
input[0] = [[id: 'test'], [], [], [], [], 'gene']
input[1] = [[id: 'bundle'], []]
input[2] = ''
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
54 changes: 54 additions & 0 deletions modules/nf-core/pypgx/runngspipeline/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"gene",
[
"results.zip:md5,76cdb2bad9582d23c1f6f4d868218d6c"
]
]
],
"1": [
"versions.yml:md5,9eab385d76a79cf80f7ca26a25592525"
],
"outdir": [
[
{
"id": "test"
},
"gene",
[
"results.zip:md5,76cdb2bad9582d23c1f6f4d868218d6c"
]
]
],
"versions": [
"versions.yml:md5,9eab385d76a79cf80f7ca26a25592525"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-22T13:42:22.619637"
},
"human paired end bam - CYP2D6 locus - GRCh37 - CYP2D6 pharmacogene": {
"content": [
"metadata.txt:md5,ea596a886920435c2a3c719b0ae85a8a",
[
"versions.yml:md5,9eab385d76a79cf80f7ca26a25592525"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-22T13:42:15.881551"
}
}
Loading