user3224522
user3224522

Reputation: 1151

Snakemake copy one file to multiple files

I have several folders

folder_1234
folder_4321

I want to copy one file myfile.sh from one folders (already exists) to all folders and then change the number inside the file using 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
        """

This gives me an error:

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

Upvotes: 0

Views: 147

Answers (1)

Manavalan Gajapathy
Manavalan Gajapathy

Reputation: 4089

In shell command, wildcard syntax here would be {wildcards.sample} instead of {sample}. For documentation on wildcards usage, see here.

Upvotes: 1

Related Questions