How to fix this "IndexError: list index out of range" in snakemake

How to fix this "IndexError: list index out of range" in 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}).*”

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

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

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