我正致力于在snakemake中实现一个非常简单的管道,希望用一个内聚的Snakefile来替换一系列烦人的bash脚本。
我在编写一个规则时遇到了困难,该规则将文件分割成更小的部分(使用GNU拆分),然后导致第二个规则,其中的输出被连接在一起。
我不知道如何在concat步骤中为输入编写什么,因为我不知道如何定义所有适合模式bam_files/test*的文件。我试过用glob,但这显然是行不通的(看起来它实际上是跳过了所有的分裂,其中包括了glob )。有什么更好的办法让我这么做吗?
# test snakemake pipeline
import glob
SAMPLE_IDS = ["test"]
rule all:
input:
expand("bam_files/{FASTQ}.out", FASTQ=SAMPLE_IDS)
rule split:
input:
expand("{FASTQ}.txt", FASTQ=SAMPLE_IDS)
output:
"bam_files/{FASTQ}."
shell:
"cat {input} | split -l 1000 -d - {output}."
rule concat:
input:
split_files = glob.glob("bam_files/{FASTQ}.*")
output:
"bam_files/{FASTQ}.out"
shell:
"cat {input} > {output}"发布于 2018-10-01 22:27:23
我认为这应该是可行的:
SAMPLE_IDS = ["test"]
rule all:
input:
expand("bam_files/{FASTQ}.out", FASTQ=SAMPLE_IDS)
rule split:
input:
"{FASTQ}.txt"
output:
dynamic("bam_files/{FASTQ}.{PART}")
params:
length=1000
shell:
"cat {input} | split -l {params.length} -d - bam_files/{FASTQ}."
rule concat:
input:
split_files = dynamic("bam_files/{FASTQ}.{PART}")
output:
"bam_files/{FASTQ}.out"
shell:
"cat {input} > {output}"看起来,split规则应该一次获取一个文件{FASTQ}.txt,并生成{FASTQ}.1, {FASTQ}.2, ...或类似的东西。因为您不知道它会产生多少文件,所以需要将dynamic()用于split.output和concat.input。
https://stackoverflow.com/questions/52598637
复制相似问题