我是使用Snakemake的新手,也不是Python方面的专家,所以答案可能很明显。在我的测试中,工作流中的所有内容都可以正常运行,直到我尝试使用glob_wildcards,以将我的所有fastq.gz文件从一个目录(FASTQDIR)转换为fastqc文件。
SAMPLES列表中的样本名称是可以的,但是我有一个错误,说应该使用字符串而不是列表(我认为这是我的SAMPLES列表),而且我真的不知道where会在其中起作用我的Snakefile来纠正它。我知道它肯定与我对glob_wildcards的使用有关,但我不知道问题出在哪里。您是否知道我该如何解决?
这是我的Snakefile代码:
FASTQDIR = "/fastq/files/directory/"
WDIR = "/my/working/directory/"
SAMPLES, = glob_wildcards(FASTQDIR + "{sample}.fastq.gz")
rule all:
input:
expand(WDIR + "Fastqc/{sample}_fastqc.html", sample=SAMPLES),
expand(WDIR + "Fastqc/{sample}_fastqc.zip", sample=SAMPLES)
#Generates fastqc file for the sample fastq.gz file in the Fastqc directory
rule fastqc_generate_qc:
input:
expand(FASTQDIR + "{sample}.fastq.gz", sample=SAMPLES)
output:
expand(WDIR + "Fastqc/{sample}_fastqc.html", sample=SAMPLES),
expand(WDIR + "Fastqc/{sample}_fastqc.zip", sample=SAMPLES)
shell:
"fastqc --outdir Fastqc/ {input}"
这里是整个Traceback:
Traceback (most recent call last):
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/__init__.py", line 420, in snakemake
force_use_threads=use_threads)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/workflow.py", line 480, in execute
success = scheduler.schedule()
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/scheduler.py", line 215, in schedule
self.run(job)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/scheduler.py", line 229, in run
error_callback=self._error)
File "/home/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/executors.py", line 59, in run
self._run(job)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/executors.py", line 120, in _run
super()._run(job)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/executors.py", line 66, in _run
self.printjob(job)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/executors.py", line 85, in printjob
msg=job.message,
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/jobs.py", line 175, in message
self.rule.message else None)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/jobs.py", line 542, in format_wildcards
return format(string, **_variables)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/site-packages/snakemake/utils.py", line 259, in format
return fmt.format(_pattern, *args, **variables)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/string.py", line 187, in format
return self.vformat(format_string, args, kwargs)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/string.py", line 191, in vformat
result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/string.py", line 201, in _vformat
self.parse(format_string):
File "/home/miniconda3/envs/snakemake-tutorial/lib/python3.5/string.py", line 285, in parse
return _string.formatter_parser(format_string)
TypeError: expected str, got list
谢谢您的帮助
您在这里不使用通配符。
您的规则fastqc_generate_qc
将所有fastq文件作为输入并在此处输出所有fastqc文件。在蛇制作中要记住的一件事是:expand
产生文件列表。您不想在这里:
rule fastqc_generate_qc:
input:
FASTQDIR + "{sample}.fastq.gz"
output:
WDIR + "Fastqc/{sample}_fastqc.html",
WDIR + "Fastqc/{sample}_fastqc.zip"
shell:
"fastqc --outdir Fastqc/ {input}"
这里sample
是通配符。这是您的全部规则,将触发实际文件名的产生。然后,规则fastqc_generate_qc将使用通配符将规则应用于规则all中要求的任何输出。
有关信息,如果要在扩展功能中使用通配符,则必须加括号:expand("path/{{study}}/{sample}, sample=SAMPLES)
在这里,study
是通配符,sample
不是通配符。 sample
值在扩展函数的第二个参数中定义。