首页 > 解决方案 > 具有特定文件组合作为输入的 Snakemake

问题描述

你知道如何用特定的文件组合运行snakemake吗?即在这个 txt 文件中,我有序列 ID 的列表:

bob.txt 
steve.txt 
john.txt

从这些文件中,我想提取上述文件中 ID 的序列:

bob.fa
steve.fa
john.fa

所以来自 bob 的序列 ID 应该在 bob.fa 中查找序列,而在 john.fa 中查找 john,依此类推。

workdir: "/path/to/dir/"
(SAMPLES,) =glob_wildcards('path/to/dir/{sample}.fa')

rule all:
    input: 
        expand("{sample}.unique.fa", sample=SAMPLES)

rule seqkit:
    input:
        infa ="path/to/dir/{sample}.fa"
        intxt = "path/to/dir/{sample}.txt
    output:
        outfa = "{sample}.unique.fa"
    shell:
        ("/Tools/seqkit grep -f {input.intxt} {input.infa} > {output.outfa}")

所以我不需要所有的组合,而只需要特定的组合,比如 bob.txt 和 bob.fa,steve.txt 和 steve.fa。因为我当前的代码也会在 steve.fa 中做 bob.txt

标签: snakemake

解决方案


rule seqkit输入中缺少逗号。

rule seqkit:
    input:
        infa ="path/to/dir/{sample}.fa",
        intxt = "path/to/dir/{sample}.txt

推荐阅读