python - 如何在snakemake中修复这个 "IndexError: list index out of range"

标签 python snakemake

我第一次设置一个新的 Snakemake 管道,并遇到了代码问题。

我一开始就试图让它变得非常简单。


configfile: "config.yaml"
SAMPLES, = glob_wildcards("data/{sample}_L008_R1_001.fastq.gz")

rule all:
    input:
        expand("umi_labeled_fastq/{sample}.umi-extract.fq.gz", sample=SAMPLES)
rule umi_tools_extract:
    input:
        "data/{sample}_L008_R1_001.fastq.gz"
    output:
        "umi_labeled_fastq/{sample}.umi-extract.fq.gz"
    shell:
        "umi_tools extract --extract-method=regex --bc-pattern=”(?P<umi_1>.{6})(?P<discard_1>.{4}).*” -I {input} -S {output}"

这是我收到的输出:

Job counts:
    count   jobs
    1   all
    6   umi_tools_extract
    7

[Thu May 16 16:55:05 2019]
rule umi_tools_extract:
    input: data/YL5_S221_L008_R1_001.fastq.gz
    output: umi_labeled_fastq/YL5_S221.umi-extract.fq.gz
    jobid: 3
    wildcards: sample=YL5_S221

RuleException in line 9 of /home/ryan/lexogen/test2.snakefile:
IndexError: list index out of range

如果我从正则表达式模式中删除这部分,那么我不会收到错误:

--bc-pattern=”(?P<umi_1>.{6})(?P<discard_1>.{4}).*”

然后我就没有错误了。我该如何解决这个问题?

最佳答案

您需要在 shell 命令中通过 doubling the brackets{4}{6} 转义大括号。 Snakemake 认为它们是某种类型的变量,但实际上它们不是,因此会出现错误。

shell:
    "umi_tools extract --extract-method=regex --bc-pattern=”(?P<umi_1>.{{6}})(?P<discard_1>.{{4}}).*” -I {input} -S {output}"

关于python - 如何在snakemake中修复这个 "IndexError: list index out of range",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56177987/

相关文章:

python - 调用成员函数的类实例 : C++ Vs Python syntax

python - 在 Snakemake 中全局加载 R 库

python - 在 Snakemake 参数部分使用特殊符号

python - Snakemake:基于 jsonschema 验证嵌套 yaml

python - 如何在python中按顺序从多个列表中删除重复记录

python - 在 Python 中用定界符分割大文本文件

python - 检查 python 2.6 中 deque 的 maxlen

python - Whoosh 索引查看器

python - 批处理 : GNU-make, Snakemake 还是什么?

windows - 为什么snakemake不执行shell命令