使用snakemake运行nanofilt

我是第一次使用snakemake。我想使用nanofilt运行一个文件夹中的fastq文件。我想用snakemake运行它,因为我需要它来创建管道。这是我的蛇制作脚本:

rule NanoFilt:
    input:
        "data/samples/{sample}.fastq"
    output:
        "nanofilt_out.gz"
    shell:
        "gunzip -c {input} | NanoFilt -q 8 | gzip > {output}"

运行它时,出现以下错误消息:

WildcardError in line 2:
Wildcards in input files cannot be determined from output files:
'sample'

编辑

我尝试搜索错误消息,但仍然无法弄清楚如何使其工作。谁能帮我吗?

所以我尝试了这里人们告诉我的内容,所以新脚本是这样的:

samples = ['fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8293','fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8292','fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8291','fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8290']
rule all:
    input:
        [f"nanofilt_out_{sample}.gz" for sample in samples]

rule NanoFilt:
    input:
        "zipped/zipped{sample}.gz"
    output:
        "nanofilt_out_{sample}.gz"
    shell:
        "gunzip -c {input} | NanoFilt -q 8 | gzip > {output}" 

但是运行此命令时,出现以下错误消息:

Error in rule NanoFilt:
Removing output files of failed job NanoFilt since they might be corrupted:
nanofilt_out_fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8292.gz
    jobid: 4
    output: nanofilt_out_fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8290.gz
    shell:
        gunzip -c zipped/zippedfastqrunid4d89b52e7b9734bd797205037ef201a30be415c8290.gz | NanoFilt -q 8 | gzip > nanofilt_out_fastqrunid4d89b52e7b9734bd797205037ef201a30be415c8290.gz
        (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

有人知道如何解决此问题吗?

xiaoman1987 回答:使用snakemake运行nanofilt

SnakeMake的“想法”是您指定所需的输出(例如通过全部规则),并且SnakeMake会查看所有定义的规则并知道如何获得所需的输出。

当您告诉SnakeMake您想要作为输出nanofilt_out.gz时,它如何知道要取什么样品?它不会..如果仅获取任何可能的示例文件,那么我们将丢失有关该文件属于哪个文件的信息。为了解决这个问题,我们需要在输出中使用与输入相同的通配符:

rule NanoFilt:
    input:
        "data/samples/{sample}.fastq"
    output:
        "nanofilt_out_{sample}.gz"
    shell:
        "gunzip -c {input} | NanoFilt -q 8 | gzip > {output}"

通过这种方式,SnakeMake可以为每个样本进行输出。您确实需要调整管道以指定所需的输出,也许是这样的:

samples = [1,2,3]

rule all:
    input:
        [f"nanofilt_out_{sample}.gz" for sample in samples]
,

我成功了。工作代码如下所示。

rule NanoFilt:
    input:
        expand("zipped/zipped.gz",sample=samples)
    output:
        "filtered/nanofilt_out.gz"
    conda:
        "envs/nanoFilt.yaml"
    shell:
        "gunzip -c {input} | NanoFilt -q 6 | gzip > {output}"

本文链接:https://www.f2er.com/3162928.html

大家都在问