在我的第一轮中,我有两类样本将由不同的参数处理,然后在第二轮中将它们合并在一起。类似于以下示例:
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
,这的确使我感到困惑。
答案 0 :(得分:1)
我认为是因为{class1}.first.txt
和{class2}.first.txt
共享相同的常数部分,即.first.txt
,并且错误消息表明它们不是唯一的。您可以通过将所有规则放在规则前面来限制通配符来解决它:
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。就个人而言,我希望约束条件是默认行为...