【问题标题】:Snakemake workflow, ChildIOException or MissingInputExceptionSnakemake 工作流程、ChildIOException 或 MissingInputException
【发布时间】:2022-11-11 00:58:06
【问题描述】:

我正在尝试在我当前的工作流程中添加文件重命名步骤,以使其他一些用户更容易。我想要做的是从黑桃程序集目录中获取contigs.fasta 文件并将其重命名为包含示例名称。 (即foo_de_novo/contigs.fastafoo_de_novo/foo.fasta

这是我的代码......目前很好。

configfile: "config.yaml"

import os


def is_file_empty(file_path):
    """ Check if file is empty by confirming if its size is 0 bytes"""
    # Check if singleton file exist and it is empty from bbrepair output
    return os.path.exists(file_path) and os.stat(file_path).st_size == 0

rule all:
    input:
        expand("{sample}_de_novo/{sample}.fasta", sample = config["names"]),

rule fastp:
    input:
        r1 = lambda wildcards: config["sample_reads_r1"][wildcards.sample],
        r2 = lambda wildcards: config["sample_reads_r2"][wildcards.sample]
    output:
        r1 = temp("clean/{sample}_r1.trim.fastq.gz"),
        r2 = temp("clean/{sample}_r2.trim.fastq.gz")
    shell:
        "fastp --in1 {input.r1} --in2 {input.r2} --out1 {output.r1} --out2 {output.r2} --trim_front1 20 --trim_front2 20"

rule bbrepair:
    input:
        r1 = "clean/{sample}_r1.trim.fastq.gz",
        r2 = "clean/{sample}_r2.trim.fastq.gz"
    output:
        r1 = temp("clean/{sample}_r1.fixed.fastq"),
        r2 = temp("clean/{sample}_r2.fixed.fastq"),
        singles = temp("clean/{sample}.singletons.fastq")
    shell:
        "repair.sh -Xmx10g in1={input.r1} in2={input.r2} out1={output.r1} out2={output.r2} outs={output.singles}"

rule spades:
    input:
        r1 = "clean/{sample}_r1.fixed.fastq",
        r2 = "clean/{sample}_r2.fixed.fastq",
        s = "clean/{sample}.singletons.fastq"
    output:
        directory("{sample}_de_novo")
    run:
        isempty = is_file_empty("clean/{sample}.singletons.fastq")
        if isempty == "False":
          shell("spades.py --careful --phred-offset 33 -1 {input.r1} -2 {input.r2} -s {input.singletons} -o {output}")
        else:
           shell("spades.py --careful --phred-offset 33 -1 {input.r1} -2 {input.r2} -o {output}")

rule rename_spades:
    input:
        "{sample}_de_novo/contigs.fasta"
    output:
        "{sample}_de_novo/{sample}.fasta"
    shell:
        "cp {input} {output}"

当我这样写时,我得到MissingInputError,当我把它改成这样时。

rule rename_spades:
    input:
        "{sample}_de_novo"
    output:
        "{sample}_de_novo/{sample}.fasta"
    shell:
        "cp {input} {output}"

我得到ChildIOException

我觉得我理解为什么snakemake 对这两个版本都不满意。第一个是因为我没有明确输出"{sample}_de_novo/contigs.fasta" 文件。它只是黑桃输出的几个文件之一。另一个错误是因为它不喜欢我要求它查看目录的方式。然而,我不知道如何解决这个问题。

有没有办法让 snakmake 在目录中查找文件,然后执行请求的任务?

谢谢, 肖恩

编辑黑桃输出的文件结构

Sample_de_novo
  |-corrected/
  |-K21/
  |-K33/
  |-K55/
  |-K77/
  |-misc/
  |-mismatch_corrector/
  |-tmp/
  |-assembly_graph.fastg
  |-assembly_graph_with_scaffolds.gfa
  |-before_rr.fasta
  |-contigs.fasta
  |-contigs.paths
  |-dataset.info
  |-input_dataset.ymal
  |-params.txt
  |-scaffolds.fasta
  |-scaffolds.paths
  |spades.log

【问题讨论】:

    标签: workflow snakemake


    【解决方案1】:

    所以黑桃的输出是{sample}_de_novo/contigs.fasta。如果是这样,只需让{sample}_de_novo/contigs.fasta 成为规则spades 的输出和规则rename_spades 的输入。喜欢:

    rule spades
        ...
        output:
            # Could be written in a better way...
            outdir='{sample}_de_novo',
            fasta='{sample}_de_novo/contigs.fasta',            
        ...
    
    rule rename_spades:
        input:
            fasta='{sample}_de_novo/contigs.fasta',
        output:
            fasta='{sample}_de_novo/{sample}.fasta',
        ...
    

    【讨论】:

    • 感谢您的建议,不幸的是,它返回了相同的 ChildIO 错误。我认为主要问题是,因为我从不调用 fasta 输出,snakemake 没有从哪里得到它。即使我只是在输出中列出它。如果我尝试显式添加到输出黑桃失败。黑桃的输出也不仅仅是一个文件。看起来像这样
    • 我将文件结构添加到正文中以澄清
    猜你喜欢
    • 2022-10-15
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-13
    相关资源
    最近更新 更多