snakemake中的动态输出

ate*_*ggs 3 python snakemake

我正在使用snakemake开发管道。我正在尝试为目录中的每个文件创建符号链接到新目标。我不知道会有多少文件,所以我想使用动态输出。

rule source:
    output: dynamic('{n}.txt')
    run:
        source_dir = config["windows"]
        source = os.listdir(source_dir)
        for w in source:
            shell("ln -s %s/%s source/%s" % (source_dir, w, w))
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

WorkflowError:“目标规则可能不包含通配符。请指定具体文件或不包含通配符的规则。”

有什么问题

Per*_*ugo 6

为了使用动态功能,您必须获得另一个规则,其中输入是动态文件,如下所示:

rule target :
  input : dynamic('{n}.txt')

rule source:
  output: dynamic('{n}.txt')
  run:
    source_dir = config["windows"]
    source = os.listdir(source_dir)
    for w in source:
      shell("ln -s %s/%s source/%s" % (source_dir, w, w))
Run Code Online (Sandbox Code Playgroud)

像这样,Snakemake将知道通配符必须具有的属性。

提示当您使用通配符时,必须始终对其进行定义。在目标规则输入中调用动态将定义通配符'{n}'。