snakemake - 如何使用输出目录来聚合文件(并接收更多信息丰富的错误消息)?

标签 snakemake

我试图解决的总体问题是一种计算我正在构建的 QC 管道的每个步骤中每个文件中存在的读取数量的方法。我有一个过去使用过的 shell 脚本,它接收一个目录并输出每个文件的读取次数。由于我希望使用目录作为输入,因此我尝试遵循 Rasmus 在这篇文章中规定的格式:

https://bitbucket.org/snakemake/snakemake/issues/961/rule-with-folder-as-input-and-output

以下是之前在管道中创建的一些示例输入:

$ ls -1 cut_reads/
97_R1_cut.fastq.gz
97_R2_cut.fastq.gz
98_R1_cut.fastq.gz
98_R2_cut.fastq.gz
99_R1_cut.fastq.gz
99_R2_cut.fastq.gz

还有一个简化的 Snakefile,首先通过在新目录中创建符号链接(symbolic link)来聚合所有读取,然后使用该目录作为读取计数 shell 脚本的输入:

import os

configfile: "config.yaml"

rule all:
    input:
        "read_counts/read_counts.txt"

rule agg_count:
    input:
        cut_reads = expand("cut_reads/{sample}_{rdir}_cut.fastq.gz", rdir=["R1", "R2"], sample=config["forward_reads"])
    output:
        cut_dir = directory("read_counts/cut_reads")
    run:
        os.makedir(output.cut_dir)
        for read in input.cut_reads:
            abspath = os.path.abspath(read)       
            shell("ln -s {abspath} {output.cut_dir}")

 rule count_reads:
    input:
        cut_reads = "read_counts/cut_reads"
    output:
        "read_counts/read_counts.txt"
    shell:
        '''
        readcounts.sh {input.cut_reads} >> {output}
        '''

在空运行中一切都很好,但是当我尝试实际执行它时,我收到一条相当神秘的错误消息:

Building DAG of jobs...
Using shell: /bin/bash
Provided cores: 1
Rules claiming more threads will be scaled down.
Job counts:
    count   jobs
    1   agg_count
    1   all
    1   count_reads
    3

[Tue Jun 18 11:31:22 2019]
rule agg_count:
    input: cut_reads/99_R1_cut.fastq.gz, cut_reads/98_R1_cut.fastq.gz, cut_reads/97_R1_cut.fastq.gz, cut_reads/99_R2_cut.fastq.gz, cut_reads/98_R2_cut.fastq.gz, cut_reads/97_R2_cut.fastq.gz
output: read_counts/cut_reads
    jobid: 2

 Job counts:
    count   jobs
    1   agg_count
    1
[Tue Jun 18 11:31:22 2019]
Error in rule agg_count:
    jobid: 0
    output: read_counts/cut_reads

Exiting because a job execution failed. Look above for error message
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Complete log: /home/douglas/snakemake/scrap_directory/.snakemake/log/2019-06-18T113122.202962.snakemake.log

read_counts/ 已创建,但内部没有 cut_reads/ 目录。完整日志中不存在其他错误消息。有人知道出了什么问题或如何接收更具描述性的错误消息吗?

我(显然)对snakemake也相当陌生,所以可能有更好的方法来完成整个过程。非常感谢任何帮助!

最佳答案

...这是一个错字。典型的。 os.makedir(output.cut_dir) 应该是 os.makedirs(output.cut_dir) 。我仍然很好奇为什么当您尝试运行此命令时,snakemake 不显示 AttributeError python 抛出的异常:

AttributeError: module 'os' has no attribute 'makedir'

是否有地方存储或可以访问这些信息以防止将来出现问题?

关于snakemake - 如何使用输出目录来聚合文件(并接收更多信息丰富的错误消息)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56655147/

相关文章:

bioinformatics - 使用不推荐使用的动态 API 构建具有动态输入的工作流

Snakemake:如何指定 shell 命令的绝对路径

python - Snakemake无法成功加载conda环境

snakemake - 有可能在 Snakefile 中覆盖的默认内存请求?

snakemake - 在参数中使用通配符

snakemake - 使用 snakemake 条件执行多重分析

python - Snakemake 在配置中声明临时文件

snakemake - Snakemake 文件中存在多个 "params"

linux - 在snakemake上运行管道所需的基本框架?

snakemake - Snakemake 如何处理由于并行运行的规则同时附加到单个文件而可能发生的损坏?