python MultiQC蛇饼 Package :No module named 'footer'

wlp8pajw  于 2023-10-14  发布在  Python
关注(0)|答案(1)|浏览(215)

我在snakemake管道中运行FastQC和MultiQC:

rule fastqc:
    input:
        "reads/{sample}_trimmed.fq.gz"
    output:
        html="qc/fastqc/{sample}.html",
        zip="qc/fastqc/{sample}_fastqc.zip" # the suffix _fastqc.zip is necessary for multiqc to find the file
    params:
        extra = "--quiet"
    log:
        "logs/fastqc/{sample}.log"
    threads: config["resources"]["fastqc"]["cpu"]
    resources:
        runtime=config["resources"]["fastqc"]["time"]
    wrapper:
        "v1.31.1/bio/fastqc"

rule multiqc:
    input:
        expand("qc/fastqc/{sample}_fastqc.zip", sample=SAMPLES)
    output:
        report("qc/multiqc.html", caption="workflow/report/multiqc.rst", category="MultiQC analysis of fastq files")
    params:
        extra="",  # Optional: extra parameters for multiqc.
        use_input_files_only=True, # Optional, use only a.txt and don't search folder samtools_stats for files
    resources:
        runtime=config["resources"]["fastqc"]["time"]
    log:
        "logs/multiqc/multiqc.log"
    wrapper:
        "v1.31.1/bio/multiqc"

fastqc规则运行时没有任何问题,但multiqc失败:

Traceback (most recent call last):
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/bin/multiqc", line 6, in <module>
    from multiqc.__main__ import run_multiqc
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/multiqc/__init__.py", line 16, in <module>
    from .multiqc import run
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/multiqc/multiqc.py", line 30, in <module>
    from .plots import table
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/multiqc/plots/table.py", line 9, in <module>
    from multiqc.plots import beeswarm, table_object
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/multiqc/plots/beeswarm.py", line 8, in <module>
    from multiqc.plots import table_object
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/multiqc/plots/table_object.py", line 9, in <module>
    from multiqc.utils import config, report
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/multiqc/utils/report.py", line 18, in <module>
    import lzstring
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/lzstring/__init__.py", line 11, in <module>
    from future import standard_library
  File "/mnt/4TB_SSD/analyses/CRISPR/test/.snakemake/conda/db6c33339e73e6beea68618300022717_/lib/python3.12/site-packages/future/standard_library/__init__.py", line 65, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

使用更高版本的 Package 器(v2.6.0)也会出现同样的错误。multiqc规则以前也有效,所以我不明白为什么突然找不到imp
为multiqc Package 器创建conda env的yaml文件:

channels:
  - conda-forge
  - bioconda
  - nodefaults
dependencies:
  - multiqc =1.16

快速的互联网搜索告诉我,"The imp module includes functions that expose part of the underlying implementation of Python’s import mechanism for loading code in packages and modules",在我看来已经是Python的一部分?

ffx8fchx

ffx8fchx1#

imp模块是deprecated in favor of importlib, and removed from the standard library since python version 3.12.0。因此,根据您的program-call/conda-environment使用的python版本,您将遇到ModuleNotFoundError错误。
一个快速的解决方法可以是简单地在<3.12.0的版本上修复所使用的Python。
我是这样做的:

multiqc_env.yaml

name: multiqc_env
channels:
  - bioconda
  - conda-forge
  - default
dependencies:
  - python<3.12
  - multiqc

multiqc.smk

rule run_multiqc:
  input: 
    some_input_file
  output:
    some_output_file
  params:
    extra="-d",
    output_dir=lambda wildcards, output: os.path.dirname(output[0]),
    output_file_name=lambda wildcards, output: os.path.basename(output[0]),
    input_directories=lambda wildcards, input: set(os.path.dirname(fp) for fp in input)
  log:
    ...
  conda:
    "multiqc_env.yaml"
  shell:
    "multiqc {params.extra} --force "
    "-o {params.output_dir} -n {params.output_file_name} "
    "{params.input_directories} &> {log}"

在我的例子中,Conda安装了一个python version=3.11.6,这使得MultiQC再次运行。
希望这对你有帮助:)

相关问题