我对snakemake非常陌生,我正试图为每个示例创建一个merged.fastq。下面是我的蛇形。
configfile: "config.yaml"
print(config['samples'])
print(config['ss_files'])
print(config['pass_files'])
rule all:
input:
expand("{sample}/data/genome_assembly/medaka/medaka.fasta", sample=config["samples"]),
expand("{pass_file}", pass_file=config["pass_files"]),
expand("{ss_file}", ss_file=config["ss_files"])
rule merge_fastq:
input:
directory("{pass_file}")
output:
"{sample}/data/merged.fastq.gz"
wildcard_constraints:
id="*.fastq.gz"
shell:
"cat {input}/{id} > {output}"
其中,“样本”是一个样本名字的列表,
“pass_files”是fastq_pass文件夹的目录路径列表,其中包含小的fastq文件
我试图将每个示例的小fastq文件合并为一个大的merged.fastq。
我得到了以下信息,
无法从输出文件中确定输入文件中的
通配符:“pass_file”
作为错误。
发布于 2020-09-07 04:52:17
input
部分中的每个通配符都应该在output
节中具有相应的通配符(同名)。这就是Snakemake的工作原理:当Snakemake试图构造作业的DAG并发现它需要某个文件时,它会查看每个规则的output
部分,并检查该规则是否能够生成所需的文件。这就是Snakemake如何在output
部分中为通配符分配某些值的方式。其他部分中的每个通配符都应该匹配output
中的一个通配符,这就是input
获取具体文件名的方式。
现在让我们来看看你的rule merge_fastq
rule merge_fastq:
input:
directory("{pass_file}")
output:
"{sample}/data/merged.fastq.gz"
wildcard_constraints:
id="*.fastq.gz"
shell:
"cat {input}/{id} > {output}"
唯一能够获得其值的通配符是{sample}
。{pass_file}
和{id}
在摇摆。
正如我所看到的,您正在尝试合并设计时不知道的文件。看看dynamic
文件,checkpoint
,并在input
中使用一个函数。
其他的Snakefile很难理解。例如,我不知道如何指定与此模式匹配的文件:"{sample}/data/merged.fastq.gz"
。
更新
让我们说,我有一个directory(/home/other_computer/jobs/data//*.fastq.gz),它是我的输入,输出是(/result/merged//merged.fastq.gz).我尝试的是将第一个路径作为输入:{"pass_files"} (这来自我的配置文件)和输出:“结果/合并/{sample}/merged.fastq.gz”
首先,让我们简化一下任务,用硬编码路径替换{pass_file}
。您有两个自由度:<sample_name>
和/home/other_computer/jobs/data/<sample_name>/
文件夹中的未知文件。<sample_name>
是成为通配符的好人选,因为这个名称可以从目标文件中派生出来。未知数量的文件*.fastq.gz
甚至不需要任何Snakemake构造,因为这可以使用shell命令来表示。
rule merge_fastq:
output:
"/result/merged/{sample_name}/merged.fastq.gz"
shell:
"cat /home/other_computer/jobs/data/{sample_name}/*.fastq.gz > {output}"
https://stackoverflow.com/questions/63766652
复制相似问题