Fredrick
03/31/2026, 3:34 AM-- \ signals the end command options allowing the CLI tool to interpret the positional arguments correctly..
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
tuple val("${task.process}"), val('pypgx'), eval('pypgx -v 2>&1 | grep -oE "[0-9]+\\.[0-9]+\\.[0-9]+" | head -1'), emit: versions_pypgx, topic: versions
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
pypgx create-input-vcf \\
${args} \\
-- \\
${prefix}.vcf.gz \\
${fasta} \\
$bam
"""
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
echo "" | gzip > ${prefix}.vcf.gz
touch ${prefix}.vcf.gz.tbi
"""
}
Of course this has to be accompanied by the usual shenanigans in you modules.config
withName: 'PYPGX_CREATEINPUTVCF' {
ext.args = { "--assembly GRCh38 --genes DPYD MTHFR F5 CACNA1S UGT1A1 BCHE UGT2B15 ABCG2 TPMT HLA-A HLA-B HLA-DRB1 HLA-DQA1 OPRM1 ABCB1 CYP3A5 CYP3A4 NAT2 OPRK1 CYP2C19 CYP2C9 CYP2C8 ADRA2A F2 ANKK1 DRD2 GRIK4 SLCO1B1 NUDT15 CYP1A2 VKORC1 SLC6A4 CYP4F2 RYR1 IFNL3 CYP2B6 COMT CYP2D6 G6PD"}
ext.prefix = { "${meta.id}_pypgx_input" }Arthur
03/31/2026, 4:04 AM-- to the end of ext.args?Fredrick
03/31/2026, 4:40 AMArthur
03/31/2026, 4:41 AM-- to the ext.args instead of needing to modify the process script?
They should both end up in $args followed by `--`:
ext.args = { "--assembly GRCh38 --genes DPYD MTHFR F5 CACNA1S UGT1A1 -- " }Fredrick
03/31/2026, 4:42 AMArthur
03/31/2026, 4:44 AM$args just gets inserted before the positional args so as long as it ends with -- it should have the same effect as adding it to the script as you have doneFredrick
03/31/2026, 4:49 AM// Define PyPGx supported genes (based on PyPGx 0.25.0)
def pypgx_supported_genes = [
'ABCB1', 'ABCG2', 'ACYP2', 'ADRA2A', 'ADRB2', 'ANKK1', 'APOE', 'ATM',
'BCHE', 'BDNF', 'CACNA1S', 'CFTR', 'COMT',
'CYP1A1', 'CYP1A2', 'CYP1B1', 'CYP2A6', 'CYP2A13', 'CYP2B6', 'CYP2C8',
'CYP2C9', 'CYP2C19', 'CYP2D6', 'CYP2E1', 'CYP2F1', 'CYP2J2', 'CYP2R1',
'CYP2S1', 'CYP2W1', 'CYP3A4', 'CYP3A5', 'CYP3A7', 'CYP3A43',
'CYP4A11', 'CYP4A22', 'CYP4B1', 'CYP4F2', 'CYP17A1', 'CYP19A1', 'CYP26A1',
'DBH', 'DPYD', 'DRD2', 'F2', 'F5', 'G6PD',
'GRIK1', 'GRIK4', 'GRIN2B', 'GSTM1', 'GSTP1', 'GSTT1',
'HTR1A', 'HTR2A', 'IFNL3', 'IFNL4', 'ITGB3', 'ITPA',
'MT-RNR1', 'MTHFR', 'NAT1', 'NAT2', 'NUDT15',
'OPRK1', 'OPRM1', 'POR', 'PTGIS', 'RARG', 'RYR1',
'SLC6A4', 'SLC15A2', 'SLC22A2', 'SLC28A3', 'SLC47A2',
'SLCO1B1', 'SLCO1B3', 'SLCO2B1', 'SULT1A1',
'TBXAS1', 'TPMT', 'UGT1A1', 'UGT1A4', 'UGT1A6', 'UGT2B7', 'UGT2B15', 'UGT2B17',
'VKORC1', 'XPC'
]
// Read and validate genes from panel file
ch_genes = Channel
.fromPath("${projectDir}/assets/panel_genes.txt")
.splitText()
.map { line -> line.trim() }
.filter { gene ->
if (!gene || gene.startsWith('#')) {
return false
}
if (gene in pypgx_supported_genes) {
log.info "✓ Processing ${gene}"
return true
} else {
log.warn "⚠️ Skipping ${gene} - not supported by PyPGx"
return false
}
}
.unique()
/*
MODULE: PYPGX_RUNLONGREADPIPELINE (runs per gene)
*/
ch_pypgx_input = ch_pypgx_vcf_tbi
.combine(ch_genes)
.map { meta, vcf, tbi, gene ->
[meta + [gene: gene], vcf, tbi, gene]
}
PYPGX_RUNLONGREADPIPELINE (
ch_pypgx_input,
assembly_ch
)Luisa Santus
03/31/2026, 8:00 AMFredrick
03/31/2026, 1:40 PMFredrick
03/31/2026, 10:31 PM-- in modules.config and am happy to report that it works. I was the problem 🙂, wrapping the genes in quote marks.
this worked:
withName: 'PYPGX_CREATEINPUTVCF' {
ext.args = { "--assembly GRCh38 --genes DPYD MTHFR F5 CACNA1S UGT1A1 BCHE UGT2B15 ABCG2 TPMT HLA-A HLA-B HLA-DRB1 HLA-DQA1 OPRM1 ABCB1 CYP3A5 CYP3A4 NAT2 OPRK1 CYP2D6 G6PD --"}
ext.prefix = { "${meta.id}_pypgx_input" }
publishDir = [
path: { "${params.outdir}/samples/${meta.id}/variant_calling/pypgx" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}