snakemake / snakemake-wrappers

This is the development home of the Snakemake wrapper repository, see
https://snakemake-wrappers.readthedocs.io
213 stars 184 forks source link

NameError: name 'PosixPath' is not defined #2793

Open odetteg opened 5 months ago

odetteg commented 5 months ago

Snakemake version 8.10.0 snakemake-wrappers version : "v3.7.0/bio/multiqc"

Describe the bug So, I have a bigger project, where in the end, I run multqc on reports generated by other tools. I am using the multiqc wrapper. I have a multiqc.smk that executes the relevant rules. When I execute the multqc.smk, everything works just fine. However, when I include the multiqc.smk in the entry snakefile and try to run, I get the error NameError: name 'PosixPath' is not defined So the error comes up on when I execute the entry snakefile and not multiqc.smk independently Logs Here is the error in detail:

NameError: name 'PosixPath' is not defined
RuleException:
CalledProcessError in file /home/odette/NGS_pipeline/workflow/rules/multiqc.smk, line 47:
Command 'set -euo pipefail;  /home/odette/anaconda3/envs/snakemake/bin/python3.12 /home/odette/NGS_pipeline/.snakemake/scripts/tmpc7l3marc.wrapper.py' returned non-zero exit status 1.

Minimal example Here is how my fastqc rule looks like. Note, all other rules execute just fine and produces needed results

import os
import sys
from pathlib import Path
from pathlib import PosixPath
sys.path.insert(0, Path(workflow.basedir).parent.parent.as_posix())
from constants.common import *

rule multiqc:
    input:
        expand(
            ["{fastqc_dir}/{sample}_fastqc.html", "{fastqc_dir}/{sample}_fastqc.zip"],
            fastqc_dir=FASTQC_DIR,
            sample=SAMPLES_f,
        ),
        expand(
            TRIMMED_OUT_DIR + "/trimmed_{sample}_{reads}.fastq.gz",
            sample=sample_name,
            reads=["R1", "R2"],
        ),
        expand(
            TRIMMED_OUT_DIRfq + "/trimmed_{sample}_{reads}_fastqc.{ext}",
            sample=sample_name,
            ext=["html", "zip"],
            reads=["R1", "R2"],
        ),
        expand(
            str(BASE_DIR) + "/results/bam/aligned_{sample}_sorted_stats.txt",
            sample=sample_name,
        ),
        expand(
            str(BASE_DIR) + "/results/variants/bcf/{sample}.filtered_stats.txt",
            sample=sample_name,
        ),
        str(FASTQC_DIR) + "/all_summary_stats.txt",
    output:
       report(
            str(BASE_DIR) + "/results/multiqc/multiqc_report.html",
            caption="report/multiqc.rst",
            category="Quality control",
        ),
        directory("results/multiqc/multiqc_data"),
    log:
        "logs/multiqc.log",
    params:
        extra="--force",
    wrapper:
        "v3.7.0/bio/multiqc"

Additional context Here is how my entry snakefile looks like:

import os
import sys
from pathlib import Path
from pathlib import PosixPath
sys.path.insert(0, Path(workflow.basedir))
from constants.common import *
configfile: 'config/config.yaml'
include: "workflow/rules/download.smk"
include: "workflow/rules/fastqc.smk"
include: "workflow/rules/trim.smk"
include: "workflow/rules/map.smk"
include: "workflow/rules/call.smk"
include: "workflow/rules/multiqc.smk"

rule all:
    input:
        report(
            str(BASE_DIR) + "/results/multiqc/multiqc_report.html",
            caption="report/multiqc.rst",
            category="Quality control",
        ),
fgvieira commented 4 months ago

Have you tried removing the PosixPath imports?