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

NameError: name 'PosixPath' is not defined #2793

Open
odetteg opened this issue Apr 6, 2024 · 2 comments
Open

NameError: name 'PosixPath' is not defined #2793

odetteg opened this issue Apr 6, 2024 · 2 comments
Labels
bug Something isn't working Stale

Comments

@odetteg
Copy link

odetteg commented Apr 6, 2024

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",
        ),
@odetteg odetteg added the bug Something isn't working label Apr 6, 2024
@fgvieira
Copy link
Collaborator

Have you tried removing the PosixPath imports?

Copy link
Contributor

github-actions bot commented Dec 1, 2024

This issue was marked as stale because it has been open for 6 months with no activity.

@github-actions github-actions bot added the Stale label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants