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/preparedepthofcoverage #6729

Open
wants to merge 6 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/preparedepthofcoverage/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"
53 changes: 53 additions & 0 deletions modules/nf-core/pypgx/preparedepthofcoverage/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
process PYPGX_PREPAREDEPTHOFCOVERAGE {
tag "$meta.id"
label 'process_single'

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(bam), path(bai)
val(pgx_genes)
val(assembly_version)

output:
tuple val(meta), path('*.zip'), emit: coverage
path("versions.yml"), emit: versions

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def genes = "--genes ${pgx_genes.join(' ')}" ?: ''
def assembly = assembly_version ?: "GRCh38"

"""
pypgx prepare-depth-of-coverage \\
${args} \\
${genes} \\
--assembly ${assembly} \\
${prefix}.zip \\
$bam

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}"
"""
python -c 'import zipfile; zipfile.ZipFile("${prefix}.zip", "w").close()'

cat <<-END_VERSIONS > versions.yml
"${task.process}":
pypgx: \$(echo \$(pypgx -v 2>&1) | sed 's/.* //')
END_VERSIONS
"""
}
61 changes: 61 additions & 0 deletions modules/nf-core/pypgx/preparedepthofcoverage/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "pypgx_preparedepthofcoverage"
description: Prepare a depth of coverage file for all target genes with SV from BAM
files.
keywords:
- Pharmacogenetics
- pypgx
- SV
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 ]`
- bam:
type: file
description: Input BAM file
pattern: "*.{bam}"
- bai:
type: file
description: Input BAM index file
pattern: "*.{bam.bai}"
- - pgx_genes:
type: list
description: List of PGx genes supported by PyPGx to include in variant calling.
- - assembly_version:
type: string
description: Genome assembly version to use.
pattern: "{GRCh37,GRCh38}"
output:
- coverage:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
pattern: "*.{zip}"
- "*.zip":
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
pattern: "*.{zip}"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@jorivansteenbrugge"
maintainers:
- "@jorivansteenbrugge"
65 changes: 65 additions & 0 deletions modules/nf-core/pypgx/preparedepthofcoverage/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// nf-core modules test pypgx/preparedepthofcoverage
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "pypgx"
tag "pypgx/preparedepthofcoverage"

test("human paired end bam CYP2D6 locus - GRCh37") {
when {
process {
"""
input[0] = [
[id: 'test'],
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"]
input[2] = "GRCh37"
"""
}
}
then {
def zipFile = path(process.out.coverage[0][1]).zip
def paths = zipFile.extractAll()
def metaFile = paths.find { it.getFileName().toString() == 'metadata.txt' }
def dataFile = paths.find { it.getFileName().toString() == 'data.tsv' }

assertAll(
{assert process.success},
{assert zipFile.isValid()},
{assert snapshot(
metaFile,
dataFile).match()}
)
}
}

test("stub") {
options "-stub"
when {
process {
"""
input[0] = [
[ id:'test' ],
[],
[]
]
input[1] = []
input[2] = ""
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"human paired end bam CYP2D6 locus - GRCh37": {
"content": [
"metadata.txt:md5,36e844724abd194e915ca0a9793cddc8",
"data.tsv:md5,4291d10aa774208ba97a9b753face059"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-10-04T08:27:28.096562"
},
"stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.zip:md5,76cdb2bad9582d23c1f6f4d868218d6c"
]
],
"1": [
"versions.yml:md5,245a2588c91875e1fe561955c4a0ad27"
],
"coverage": [
[
{
"id": "test"
},
"test.zip:md5,76cdb2bad9582d23c1f6f4d868218d6c"
]
],
"versions": [
"versions.yml:md5,245a2588c91875e1fe561955c4a0ad27"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-10-04T08:27:34.813018"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/pypgx/preparedepthofcoverage/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pypgx/preparedepthofcoverage:
- "modules/nf-core/pypgx/preparedepthofcoverage/**"
Loading