如何解决Snakemake无法处理很长的命令行?
这是一个非常奇怪的问题。
当我在For Each k In dict
isConsider = False
lvl = False
部分中指定的{input}
是rule包含500个以上的文件时,snakemake刚刚退出并显示了消息{input}
。完整的日志未提供任何错误消息。
有关日志,请参阅:https://github.com/snakemake/snakemake/files/5285271/2020-09-25T151835.613199.snakemake.log
有效的规则是(注意(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)
的上限为200个文件):
input
失败的规则是:
rule combine_fastq:
input:
lambda wildcards: samples.loc[(wildcards.sample),["fq"]].dropna()[0].split(',')[:200]
output:
"combined.fastq/{sample}.fastq.gz"
group: "minion_assemble"
shell:
"""
echo {input} > {output}
"""
我的问题也发布在GitHub:https://github.com/snakemake/snakemake/issues/643。
解决方法
第二个我是马尔滕的答案,因为有那么多文件正在运行,而且没有外壳限制。 snakemake所做的工作很糟糕,无法帮助您发现问题。
根据您所参考的问题,似乎您正在使用cat合并所有文件。也许遵循答案here会有所帮助:
rule combine_fastq_list:
input:
lambda wildcards: samples.loc[(wildcards.sample),["fq"]].dropna()[0].split(',')
output:
temp("{sample}.tmp.list")
group: "minion_assemble"
script:
with open(output[0]) as out:
out.write('\n'.join(input))
rule combine_fastq:
input:
temp("{sample}.tmp.list")
output:
'combined.fastq/{sample}.fastq.gz'
group: "minion_assemble"
shell:
'cat {input} | ' # this is reading the list of files from the file
'xargs zcat -f | '
'...'
希望它能使您走上正确的轨道。
修改
第一个选项针对每个输入文件分别执行命令。对于整个输入列表,一次执行命令的另一个选项是:
rule combine_fastq:
...
shell:
"""
command $(< {input}) ...
"""
,
对于那些遇到类似问题(例如 Snakemake expand function alternative)的人,snakemake 6 可以处理长命令行。以下测试在 snakemake
rule all:
input:
'output.txt',rule one:
output:
'output.txt',params:
x= list(range(0,1000000))
shell:
r"""
echo {params.x} > {output}
"""
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。