Snakemake:规则会产生奇怪的结果

时间:2017-09-19 12:53:45

标签: snakemake

我创建了这条规则:

rule picard_addRG2:
    input:
        "mapped_reads/merged_samples/{sample}.dedup.bam"
    output:
        "mapped_reads/merged_samples/{sample}_rg.dedup.bam"
    params:
        sample_idi = config['samples'],
        library = "library00"

    shell:
        """picard  AddOrReplaceReadGroups I={input} O={output}  RGID={params.sample_id}  RGLB={params.library} RGPL=illumina  RGPU=unit1 RGSM=20 RGPU=MP"""

我添加了o Snakemake文件这个规则:

expand("mapped_reads/merged_samples/{sample}_rg.dedup.bam",sample=config['samples'])

我在另一条规则上发现了这个奇怪的结果:

snakemake --configfile exome.yaml -np 
InputFunctionException in line 17 of /illumina/runs/FASTQ/test_play/rules/samfiles.rules:
KeyError: '445_rg'
Wildcards:
sample=445_rg

我做错了什么?

如果我以这种方式改变规则就可以完美地运作:

rule picard_addRG2:
    input:
        "mapped_reads/merged_samples/{sample}.dedup.bam"
    output:
        "mapped_reads/merged_samples/{sample}.dedup_rg.bam"
    params:
        sample_id = config['samples'],
        library = "library00"

    shell:
        """picard  AddOrReplaceReadGroups I={input} O={output}  RGID={params.sample_id}  RGLB={params.library} RGPL=illumina  RGPU=unit1 RGSM=20 RGPU=MP"""

1 个答案:

答案 0 :(得分:1)

由于它与编写输出的第二种方式完美配合,我建议使用这个。发生的事情如下:

因为在你的规则picard中输入是:
"mapped_reads/merged_samples/{sample}.dedup.bam"
您必须具有将此文件创建为输出的规则。 在你的规则picard中输出是: "mapped_reads/merged_samples/{sample}_rg.dedup.bam"

所以当你在扩展中询问时:
"mapped_reads/merged_samples/{sample}_rg.dedup.bam"
snakemake不知道是否必须使用sample作为通配符的规则picard或使用sample_rg作为通配符的其他规则,因为它们都以相同的模式结束并开始。

要恢复:尽量不要使用带有可扩展的通配符的两个输出。这两个你输出:
"mapped_reads/merged_samples/{sample}.dedup.bam"
"mapped_reads/merged_samples/{sample}_rg.dedup.bam"
以完全相同的模式开始和结束。

使用时: "mapped_reads/merged_samples/{sample}.dedup_rg.bam"
作为输出,通配符无法扩展!