如何在 snakemake 中将变量值作为输入传递?

How to pass variable value as input in snakemake?

我想使用 Snakemake 使用 SRR ID 从 SRA 数据库下载 fastq 文件。我使用 python 代码读取文件以获取 SRR ID。

我想一个一个解析Variable作为输入。我的代码如下。

我要运行命令

fastq-dump SRR390728

#SAMPLES = ['SRR390728','SRR400816']
SAMPLES = [line.strip() for line in open("./srrList", 'r')]

rule all:
    input:
        expand("fastq/{sample}.fastq.log",sample=SAMPLES)

rule download_fastq:
    input:
        "{sample}"
    output:
        "fastq/{sample}.fastq.log"

    shell:
        "fastq-dump {input} > {output}"

跳过input,只在shell命令中输入call the wildcardinput 需要是一个需要已经存在或作为管道的一部分创建的文件路径 - 在您的情况下都不是这样。

rule download_fastq:
    output:
        "fastq/{sample}.fastq.log"
    shell:
        "fastq-dump {wildcards.sample} > {output}"