Snakemake Conda 环境似乎没有激活,尽管它说是

Snakemake Conda environment does not seem to be activating though it says it is

我 运行ning Snakemake 有 --use-conda 选项。 Snakemake 成功创建了环境,其中应该包括 pysam。我能够手动激活这个创建的环境,并且在其中 运行 我的脚本 split_strands.py,它导入模块 pysam,没有任何问题。但是,当 运行 连接 Snakemake 管道时,我收到以下错误日志:

Activating conda environment: /projects/ps-yeolab3/ekofman/sc_STAMP_pipeline/STAMP/workflow/.snakemake/conda/7c375b6b
/projects/ps-yeolab3/ekofman/sc_STAMP_pipeline/STAMP/workflow/scripts/split_strands.py:166: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if args.output_fwd_bam is not '-':
/projects/ps-yeolab3/ekofman/sc_STAMP_pipeline/STAMP/workflow/scripts/split_strands.py:171: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if args.output_rev_bam is not '-':
Traceback (most recent call last):
  File "/projects/ps-yeolab3/ekofman/sc_STAMP_pipeline/STAMP/workflow/scripts/split_strands.py", line 20, in <module>
    import pysam
ModuleNotFoundError: No module named 'pysam'
[Mon Mar 29 16:41:06 2021]
Error in rule split_strands:
    jobid: 0
    output: 1_split_strands/TWA1_possorted_genome_bam_MD-GTCGCGACACGAGGTA-1.bam.fwd.bam, 1_split_strands/TWA1_possorted_genome_bam_MD-GTCGCGACACGAGGTA-1.bam.rev.bam
    conda-env: /projects/ps-yeolab3/ekofman/sc_STAMP_pipeline/STAMP/workflow/.snakemake/conda/7c375b6b
    shell:
        
        python scripts/split_strands.py -i /projects/ps-yeolab3/ekofman/sc_STAMP_pipeline/STAMP/workflow/inputs/TWA1_possorted_genome_bam_MD-GTCGCGACACGAGGTA-1.bam -f 1_split_strands/TWA1_possorted_genome_bam_MD-GTCGCGACACGAGGTA-1.bam.fwd.bam -r 1_split_strands/TWA1_possorted_genome_bam_MD-GTCGCGACACGAGGTA-1.bam.rev.bam
        
        (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Nodes:        tscc-1-37

正如您所见,虽然它说它是“激活 conda 环境”,但这似乎不是真的,因为随后找不到模块 'pysam',我已经验证会找到手动激活时。

规则是这样指定的:

rule split_strands:
    input: 
        input_bam=config["samples_path"]+"{sample}",
        index=config["samples_path"]+"{sample}.bai"
    output: 
        output_fwd="1_split_strands/{sample}.fwd.bam",
        output_rev="1_split_strands/{sample}.rev.bam"
    conda:
        "envs/python2.7.yaml"
    shell:
        """
        python scripts/split_strands.py -i {input.input_bam} -f {output.output_fwd} -r {output.output_rev}
        """

我已验证哈希 7c375b6b 对应于 python2.7.yaml.

中指定的适当环境

知道会发生什么吗?我的规则是 运行 一个集群并通过 qsub 命令提交。

原来snakemake 6.0.0+的新版本肯定有这个问题。我改用 snakemake 5.8.2,一切正常。不确定幕后到底发生了什么,但似乎与这个问题相同:https://github.com/snakemake/snakemake/issues/883