Am not very good with updating modules, but for th...
# modules
f
Am not very good with updating modules, but for those using pypgx, here is a hack when you're using more than 1 target gene and you didn't map to an entire reference genome.. the
-- \
signals the end command options allowing the CLI tool to interpret the positional arguments correctly..
Copy code
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
Copy code
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" }
a
Could you not just add the
--
to the end of
ext.args
?
f
Nope.. WHen you have more than 1 gene, then the tool somehow doesn't identify where the positional args start because they don't have flags e.g --bam FILE --outfile OUTFILENAME --... Tried a few times and the only remedy was that -- \
a
Yeah but why can’t you add
--
to the
ext.args
instead of needing to modify the process script? They should both end up in
$args
followed by `--`:
Copy code
ext.args = { "--assembly GRCh38 --genes DPYD MTHFR F5 CACNA1S UGT1A1 -- " }
f
That I cannot explain.. Hence why my post starts with my naive approach..
a
Assuming you didn’t already try it, I don’t see why it wouldn’t work. The
$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 done
✅ 1
f
Could be just me, but I tried all these before making that rather rudimentary fix. It was easier on the other annotation by pypgx as that only takes 1 gene at a time
Copy code
// 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
    )
l
I would need to try again but I had the same issue. I believe that also moving args in the end of the command line may do the trick. But cannot recall 100% so I would have to play again with it.
f
Some of these observations are incidental and sometimes it takes ages to reproduce them.
@Arthur, thanks for your suggestions. I went back and tested the
--
in
modules.config
and am happy to report that it works. I was the problem 🙂, wrapping the genes in quote marks. this worked:
Copy code
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 }
        ]
    }