snakemake:如何对glob_wildcards()排序
如何使用glob_wildcards()以字母顺序获取文件?
假设我在同一目录中有Sample1.txt,Sample2.txt,Sample3.txt和Sample4.txt。 当我运行此代码时:
file_pattern = 'dir_test/{sample}.txt'
FILES = glob_wildcards(file_pattern)
SAMPLES = FILES.sample
rule all:
input:
expand(file_pattern, sample=SAMPLES),
"concat.txt"
rule concat:
input:
expand("dir_test/{sample}.txt", sample=SAMPLES),
output:
"concat.txt"
shell:
"""
cat {input} > {output}
"""
我得到了glob_wildcards()的结果,按照以下任意顺序出现:
$ cat concat.txt
This is Sample4
This is Sample1
This is Sample2
This is Sample3
How can I get files in alphabetical order using glob_wildcards()?
Suppose I have sample1.txt, sample2.txt, sample3.txt, and sample4.txt in the same directory.
When I run this code:
file_pattern = 'dir_test/{sample}.txt'
FILES = glob_wildcards(file_pattern)
SAMPLES = FILES.sample
rule all:
input:
expand(file_pattern, sample=SAMPLES),
"concat.txt"
rule concat:
input:
expand("dir_test/{sample}.txt", sample=SAMPLES),
output:
"concat.txt"
shell:
"""
cat {input} > {output}
"""
I got the results of glob_wildcards() come out in an arbitrary order as follows:
$ cat concat.txt
This is Sample4
This is Sample1
This is Sample2
This is Sample3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过类似:(
不确定
list()
甚至是必要的)。Have you tried something like:
(not sure that
list()
is even necessary).