Snakemake automatization

Viewed 29

I am new to snakemake and I tried to do some short workflow.

It looks like this:

rule extractfeat:
    input:
        "/media/murva/450A-F844/PULs/PspTF13.gbf"
    output:
        "PspTF13_{id}"
    shell:
        """
        extractfeat {input} {output} -value PspTF13_{wildcards.id} -describe product,locus_tag
        """

rule transeq:
    input: 
        "PspTF13_{id}"
    output:
        "ak_PspTF13_{id}"
    shell:
        """
        transeq {input} {output}
        """

rule blastp:
    input:
        "ak_PspTF13_{id}"
    output:
        "homology_PspTF13_{id}"
    shell:
        """
        blastp -query {input} -db /media/murva/450A-F844/PULs/prevotelladb/prevotelladb -out {output}
        """
        
rule homology_numbers:
    input:
        "homology_PspTF13_{id}"
    output:
        "numbers_homology_PspTF13_{id}"
    shell:
        """
        sed -e '/Identities/G' -n -e '/^>/,/Identities/p' {input} > {output}
        """

Everything works fine I would just like to get files for ex. numbers_homology_PspTF13_00490 till numbers_homology_PspTF13_00505 so {id} from 00490-00505 so I dont need to type each time one number. What would be the possible way to automate this?

Thank you!!

1 Answers

Usually, you would have a rule, called all at the top of your workflow defining your final output files, then you could say:

rule all:
    input:
        expand('numbers_homology_PspTF13_00{id}', id=range(490, 506))

Alternative, you can request a range of values from the bash command line:

snakemake numbers_homology_PspTF13_{00490..00506}

Remember snakemake is basically python with a little extra syntax. Any way you want to automate listing your requested output files with python will work.

Related