我第一次设置一个新的 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/