如何修复 'MissingOutputException'?

How to fix 'MissingOutputException'?

我猜这是在 snakemake v5.1 之后反复出现的问题 看到几个线程,但无法弄清楚出了什么问题。请帮忙。

rule all:
input:
    [OUT_DIR + "/" + x for x in expand('{sample}', sample = SAMPLES)]

rule star_mapping:
input:
    dna= DNA,
    r1 = lambda wildcards: FILES[wildcards.sample]['R1'],
    r2 = lambda wildcards: FILES[wildcards.sample]['R2'],
output:
    directory(join(OUT_DIR, '{sample}'))
log:
    'logs/{sample}_star_mapping.log'
run:
    shell(
    'STAR --runMode alignReads'
        ' --runThreadN 10'
        ' --genomeDir {input.dna}'
        ' --genomeLoad LoadAndKeep'
        ' --limitBAMsortRAM 8000000000'
        ' --readFilesIn {input.r1} {input.r2}'
        ' --outSAMtype BAM SortedByCoordinate'
        ' --quantMode GeneCounts'
        ' --readFilesCommand zcat'
        ' --outFileNamePrefix {output}_'
        ' &> {log}'
    )

错误: 规则 star_mapping.

中的 MissingOutputException

我认为您没有正确理解 directory() 函数。
通过指定 directory(join(OUT_DIR, '{sample}')),snakemake 期望创建 OUTDIR/{sample}/ 目录。
但是,规则 star_mapping 将创建以下文件:

OUTDIR/{sample}_Aligned.sortedByCoord.out.bam
OUTDIR/{sample}_Log.final.out
OUTDIR/{sample}_Log.out
etc...

根据
https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#directories-as-outputs
directory() 应该用于时间戳查找问题。该文件指出:

Always consider if you can’t formulate your workflow using normal files before resorting to using directory().

所以我想你应该考虑像这样定义文件:
"OUTDIR/{sample}_Aligned.sortedByCoord.out.bam" 作为星规则的输出并且
--outFileNamePrefix {OUTDIR}/{wildcards.sample}_ 星选项