【问题标题】:Recursive input calling in Snakemake ruleSnakemake 规则中的递归输入调用
【发布时间】:2021-03-31 07:07:31
【问题描述】:

我正在编写规则来处理一些数据:
目录中的数据将类似于:

myfirst.trim_1P, myfirst.trim_2P, mysecond.trim_1P, mysecond.trim_2P,...

rule trim_data:
        input:"{dataset}/{sample}.trim_{r}P"
        output:"{dataset}/{sample}.{r}.fastq"
        params:
            length=14
        shell:
            """
            reformat.sh forcetrimleft="{params.length}" in="{input}" out="{output}"
            """

我有这个错误:

WorkflowError:
RecursionError: maximum recursion depth exceeded
If building the DAG exceeds the recursion limit

myDir/myfirst.1.trimed.1.trimed.2.trimed.2.trimed.2....

如果输出与输入不同,为什么它以递归方式运行?以及如何解决?

【问题讨论】:

    标签: snakemake


    【解决方案1】:

    这是一个疯狂的猜测......也许通配符捕获的比它们应该捕获的更多,因为它们被解释为正则表达式。如果 {dataset}{sample}{r} 采用已定义的值列表,请尝试使用以下方法限制它们的范围:

    wildcard_constraints:
        dataset= '|'.join([re.escape(x) for x in DATASET]),
        sample= '|'.join([re.escape(x) for x in SAMPLE]),
        r= '|'.join([re.escape(x) for x in R]),
    

    其中 DATASET、SAMPLE 和 R 是值列表(例如 R= ['1', '2']

    【讨论】:

    • 谢谢,可能是这种情况,我会测试它并提供反馈。
    • 不幸的是,它不起作用。我会试着想点别的,谢谢。
    • 所以错误出现在另一个可能导致此递归的下游规则中,我修复了它并在名称上添加了一些约束,例如 rule bam2fastq: input: datain="{dataset}/{sample}.{filter, ^[0-9]}.bam" output: dataout="{dataset}/{sample}.{filter}.reads.fastq" run: shell(""" bedtools bamtofastq -i "{input.datain}" -fq "{output.dataout}" """)
    【解决方案2】:

    我遇到了类似的错误(如下)。事实证明,这是由于规则输出的文件名与不同的规则相同。更改输出文件的名称修复了此错误。

    代码:

    rule merge_sample_chr:
        input:
    
                bcftools=config["bcftools"],
                chr_list=expand(config["vcf_dir_ase"]+"/Eagle/all_{{sample}}_chr{this_chr}_sorted.vcf.gz",this_chr=CHRS)
        params:
                chr_list=expand("I="+config["vcf_dir_ase"]+"/Eagle/all_{{sample}}_chr{this_chr}_sorted.vcf.gz",this_chr=CHRS)
    
        output:
                vcf=config["vcf_dir_ase"]+"/Eagle/all_{sample}.vcf.gz"
        shell:
                """
                {input.bcftools} concat {input.chr_list} -Oz -o {output}
                """
    

    错误:

    WorkflowError:
    RecursionError: maximum recursion depth exceeded in __instancecheck__
    If building the DAG exceeds the recursion limit, this is likely due to a cyclic dependency.E.g. you might have a sequence of rules that can generate their own input. Try to make the output files more specific. A common pattern is 
    Problematic file pattern: /path/samplid_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_chr1_.vcf.gz
    

    【讨论】:

    • 没错,我在@dariober 回答中提到过,您可以通过更改输出名称来修复它,或者像我一样设置一些约束。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 2021-12-29
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多