gpt4 book ai didi

snakemake - snakemake 中的 ambiguousruleexception,两个分支的 parms 崩溃

转载 作者:行者123 更新时间:2023-12-04 14:19:56 27 4
gpt4 key购买 nike

在我的第一次运行中,我有两类样本要由不同的参数处理,然后在第二次运行中将它们合并在一起。像下面的例子:

SAMPLES = ['1', '2', '3']
CLASS1 = ['1', '2']
CLASS2 = ['3']

rule all:
input:
expand('{class1}.first.txt', class1 = CLASS1),
expand('{class2}.first.txt', class2 = CLASS2),
expand('{sample}.second.tx', sample = SAMPLES)

rule first_CLASS1:
input:
'{class1}.txt'
output:
'{class1}.first.txt'
shell:
'touch {wildcards.class1}.first.txt'

rule first_CLASS2:
input:
'{class2}.txt'
output:
'{class2}.first.txt'
shell:
'touch {wildcards.class2}.first.txt'

rule second:
input:
'{sample}.first.txt'
output:
'{sample}.second.txt'
shell:
'touch {wildcards.sample}.second.txt'

但我得到了这样的 AmbiguousRuleException:

AmbiguousRuleException:
Rules first_CLASS2 and first_CLASS1 are ambiguous for the file 1.first.txt.
Consider starting rule output with a unique prefix, constrain your wildcards, or use the ruleorder directive.
Wildcards:
first_CLASS2: class2=1
first_CLASS1: class1=1
Expected input files:
first_CLASS2: 1.txt
first_CLASS1: 1.txtExpected output files:
first_CLASS2: 1.first.txt
first_CLASS1: 1.first.txt

我声明

expand('{class2}.first.txt', class2 = CLASS2)

全部运行,CLASS2 = ['3']。然而它报告class2 = 1,这让我很困惑。

最佳答案

我认为这是因为 {class1}.first.txt{class2}.first.txt 共享相同的常量部分,即 .first。 txt 并且错误消息表明它们不是唯一的。您可以通过将通配符放在规则 all 之前来限制通配符来解决它:

wildcard_constraints:
class1= '|'.join([re.escape(x) for x in CLASS1]),
class2= '|'.join([re.escape(x) for x in CLASS2]),

另请参阅我的这个问题 https://groups.google.com/forum/#!msg/snakemake/wVlJW9X-9EU/gSZh4U0_CQAJ .就我个人而言,如果约束是默认行为,我更愿意...

关于snakemake - snakemake 中的 ambiguousruleexception,两个分支的 parms 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56122204/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com