Snakemake 复制一个文件到多个文件

Snakemake copy one file to multiple files

我有几个文件夹

folder_1234
folder_4321

我想从一个文件夹(已经存在)复制一个文件myfile.sh到所有文件夹,然后使用sed:

更改文件内的数字
SAMPLE=["1234","4321"]
rule all:
    input:
        expand("workdir/folder_{sample}/myfile.sh", sample=SAMPLES)
rule copy:
    input:
        copy_from="/path/to/folder_1234/myfile.sh"
    output:
        copy_to="workdir/folder_{sample}/myfile.sh"
    shell:
        """
        cp {input.copy_from} {output.copy_to}
        sed "s/folder_1234/folder_{sample}/g" folder_{sample}/myfile.sh
        """

这给了我一个错误:

NameError: The name 'sample' is unknown in this context. Did you mean 'wildcards.sample'?

shell命令中,这里的通配符语法是{wildcards.sample}而不是{sample}。有关通配符用法的文档,see here.