蛇级联检查站不起作用



>我有以下情况

  1. 检查点A在文件夹A_Out中创建文件(1 或 2(
  2. 检查点BA_Out中的所有文件作为输入,并在B_Out中生成文件(1 或 2(
  3. 我有条件规则C,它可以从 A 或 B 获取输入并产生最终输出

我正在使用以下代码,

checkpoint A:
output: directory("A_Out")
# Rest of the logic
def collect_a(wildcards):
path = checkpoints.A.get(**wildcards).output[0]
return expand("{path}/{file}.txt",
path=path,
file=glob_wildcards(os.path.join(path, "{name}.txt")).name)
checkpoint B:
input: collect_a
output: directory("B_Out")
# Rest of the logic
def collect_b(wildcards):
path = checkpoints.B.get(**wildcards).output[0]
return expand("{path}/{file}.txt",
path=path,
file=glob_wildcards(os.path.join(path, "{name}.txt")).name)
def conditional_input(wildcards):
if condition_A:
return collect_a(wildcards)
else:
return collect_b(wildcards)
rule c:
input: conditional_input
# Rest of the logic

在上述情况下,当condition_aFalse时,它只评估检查点B,而不评估检查点A。如何解决这个问题?还是有其他优雅的方式?

这些级联检查点调用非常有问题,并且有几个与之相关的问题。 如果你充实你的示例,你可以向github提交一个问题,假设你有最新版本的snakemake。

作为解决方法,您可以尝试在每个目录中添加一个临时信号文件,以指示规则已完成。 然后,您需要在规则代码中执行 glob 通配符。

不是很好,但可以工作。 因为您有一个临时输入作为信号,所以即使其他文件已经存在,规则也会每次重新运行;Snakemake不知道它们是输出。 另一种选择是事先检查您的输入,以确定是否将生成一个或两个文件,并将其绑定到输入函数逻辑中,绕过检查点。

最新更新