1

我正在使用该--use-conda选项运行 Snakemake。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 命令提交。

4

1 回答 1

0

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

于 2021-03-30T22:22:58.730 回答