首页 > 解决方案 > 使用扩展功能时如何阻止snakemake将非文件结尾添加到通配符?(.g.vcf 失败,.vcf 有效)

问题描述

在扩展规则中的变量之后添加 .g.vcf 而不是 .vcf 以某种方式将 .g 添加到另一个模块中的通配符

我在所有规则中尝试了以下内容:

{stuff}.g.vcf 
{stuff}"+"g.vcf" 
{stuff}_var"+".g.vcf"
{stuff}.t.vcf 

全部失败,但 {stuff}.gvcf 或 {stuff}.vcf 工作

错误:

snake_modules/mark_duplicates.snakefile 第 21 行中的 InputFunctionException:KeyError:'Mother.g' 通配符:lane=Mother.g

代码:

LANES = config["list2"].split()

rule all:
    input:
         expand(projectDir+"results/alignments/variants/{stuff}.g.vcf", stuff=LANES)


rule mark_duplicates:
    """ this will mark duplicates for bam files from the same sample and library """
    input:
        get_lanes
    output:
        projectDir+"results/alignments/markdups/{lane}.markdup.bam"
    log:
        projectDir+"logs/"+stamp+"_{lane}_markdup.log"
    shell:
        " input=$(echo '{input}' |sed -e s'/ / I=/g') && java -jar /home/apps/pipelines/picard-tools/CURRENT MarkDuplicates I=$input O={projectDir}results/alignments/markdups/{wildcards.lane}.markdup.bam M={projectDir}results/alignments/markdups/{wildcards.lane}.markdup_metrics.txt &> {log}"

我希望我的最终输出具有 {stuff}.g.vcf 符号。请注意,此输出是在另一个蛇模块中创建的,但错误出现在另一个模块之前的标记重复中。

我尝试了多项更改,但导致问题的是 all 规则中的 .g.vcf 。

标签: snakemake

解决方案


我的猜测是,它{lane}被解释为正则表达式,并且它捕获的内容超出了应有的范围。尝试添加之前rule all

wildcard_constraints:
    stuff= '|'.join([re.escape(x) for x in LANES]),
    lane= '|'.join([re.escape(x) for x in LANES])

(另请参阅此线程https://groups.google.com/forum/#!topic/snakemake/wVlJW9X-9EU


推荐阅读