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/createinputvcf #6720

Open
wants to merge 1 commit 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/createinputvcf/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
56 changes: 56 additions & 0 deletions modules/nf-core/pypgx/createinputvcf/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
process PYPGX_CREATEINPUTVCF {
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)
tuple val(meta2), path(fasta)


output:
tuple val(meta), path("*.vcf.gz"), emit: vcf
tuple val(meta), path("*.vcf.gz.tbi"), emit: tbi
path("versions.yml"), emit: versions

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

script:
def args = task.ext.args ?: ''
def assembly = task.ext.assembly_version ?: "GRCh38"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a value input. We don't allow additional external arguments to keep everything consistent

def prefix = task.ext.prefix ?: "${meta.id}"
def pgx_genes = "--genes ${task.ext.pgx_genes.join(' ')}" ?: ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for pgx_genes


"""
pypgx create-input-vcf \\
${args} \\
${pgx_genes} \\
--assembly ${assembly} \\
${prefix}_variants.vcf.gz \\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${prefix}_variants.vcf.gz \\
${prefix}.vcf.gz \\

This is to maintain the flexibility of prefix you can add _variants there if you want to add this to the file name

${fasta} \\
$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}"
"""
touch ${prefix}_variants.vcf.gz
touch ${prefix}_variants.vcf.gz.tbi
Comment on lines +48 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
touch ${prefix}_variants.vcf.gz
touch ${prefix}_variants.vcf.gz.tbi
echo "" | gzip > ${prefix}.vcf.gz
touch ${prefix}.vcf.gz.tbi

nf-test has throws an error with gzipped files that are not actually gzipped


cat <<-END_VERSIONS > versions.yml
"${task.process}":
pypgx: \$(echo \$(pypgx -v 2>&1) | sed 's/.* //')
END_VERSIONS
"""
}
69 changes: 69 additions & 0 deletions modules/nf-core/pypgx/createinputvcf/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "pypgx_createinputvcf"
description: Call SNVs/indels from BAM files for all target genes.
keywords:
- pypgx
- Pharmacogenetics
- variants
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":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- - "meta":
- - meta:

type: map
description: |
Groovy Map containing sample information
e.g. [id: 'test']
- bam:
type: file
description: Input BAM file
pattern: "*.{bam}"
- bai:
type: file
description: Input BAM index file
pattern: "*.{bam.bai}"
- - meta2:
type: map
description: |
Groovy Map containing sample information
e.g. [id: 'test']
- fasta:
type: file
description: Reference genome file
pattern: "*.{fasta,fa,fna,fasta.gz,fa.gz,fna.gz}"
output:
- vcf:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [id: 'test']
- "*.vcf.gz":
type: file
description: VCF file containing called SNVs/indels
pattern: "*.vcf.gz"
- tbi:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [id: 'test']
- "*.vcf.gz.tbi":
type: file
description: File containing the VCF tabix index
pattern: "*.vcf.gz.tbi"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@jorisvansteenbrugge"
maintainers:
- "@jorisvansteenbrugge"
71 changes: 71 additions & 0 deletions modules/nf-core/pypgx/createinputvcf/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// nf-core modules test pypgx/createinputvcf
nextflow_process {

name "Test Process PYPGX_CREATEINPUTVCF"
script "../main.nf"
process "PYPGX_CREATEINPUTVCF"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "pypgx"
tag "pypgx/createinputvcf"


test("human paired end bam - genome.fa") {
when {
process {
"""
input[0] = [
[id: 'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.markduplicates.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.markduplicates.sorted.bam.bai', checkIfExists: true)
]
input[1] = [
[id: 'GRCh38'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.vcf[0][1]).name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test this a little better? You can use the nft-vcf nf-test plugin to easily test VCF files. This plugin is already enabled in this repository so you can immediately start using these methods

process.out.versions).match() }
)
}
}


test("stub") {
options "-stub"

when {
process {
"""
input[0] = [
[id: 'test'],
[],
[]
]
input[1] = [
[id: 'test_genome'],
[]
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.vcf[0][1]).name,
process.out.versions).match() }
Comment on lines +65 to +67
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ assert snapshot(
file(process.out.vcf[0][1]).name,
process.out.versions).match() }
{ assert snapshot(process.out).match() }

Stub tests don't need to be limited as they are empty files

)
}
}
}
28 changes: 28 additions & 0 deletions modules/nf-core/pypgx/createinputvcf/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"stub": {
"content": [
"test_variants.vcf.gz",
[
"versions.yml:md5,6afe5f69d9cb49f74eb1958a8ba2e990"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-10-01T14:20:26.587276"
},
"human paired end bam - genome.fa": {
"content": [
"test_variants.vcf.gz",
[
"versions.yml:md5,6afe5f69d9cb49f74eb1958a8ba2e990"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-10-01T14:10:19.196392"
}
}
6 changes: 6 additions & 0 deletions modules/nf-core/pypgx/createinputvcf/tests/nextflow.config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file can be removed

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: "PYPGX_CREATEINPUTVCF" {

ext.assembly_version = {"GRCh38"}
ext.pgx_genes = {["GRIK1"]}}
}
2 changes: 2 additions & 0 deletions modules/nf-core/pypgx/createinputvcf/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pypgx/createinputvcf:
- "modules/nf-core/pypgx/createinputvcf/**"
Loading