snakemake - Snakemake:捕获名称无法更改的输出文件
问题描述
作为我正在构建的 Snakemake 管道的一部分,我必须使用一个不允许我指定输出文件的文件路径或名称的程序。
例如,在工作目录中运行程序时,workdir/
它会产生以下输出:
workdir/output.txt
我的蛇形规则看起来像这样:
rule NAME:
input: "path/to/inputfile"
output: "path/to/outputfile"
shell: "somecommand {input} {output}"
因此,每次运行规则 NAME 时,我都会output.txt
在 snakemake 工作目录中获得一个附加文件,如果规则 NAME 运行多次或并行运行,则该文件将被覆盖。
我知道影子规则,添加shadow: "full"
允许我简单地忽略output.txt
文件。但是,我想将其保留output.txt
并保存在与outputfile
. 有没有办法通过影子指令或其他方式实现这一目标?
我还想我可以在前面somecommand
加上一个cd
命令,但是当将其他规则连接到规则的输出时,我可能会在下游遇到其他问题NAME
。
解决方案
之后直接在外壳部分中直接移动它怎么样(前提是somecommand
成功完成)?
rule NAME:
input: "path/to/inputfile"
output: "path/to/outputfile"
params:
output_dir = "path/to/output_dir",
shell: "somecommand {input} {output} && mv output.txt {params.output_dir}/output.txt"
编辑:对于 NAME 的多个并行执行,结合shadow: "full"
可以工作:
rule NAME:
input: "path/to/inputfile"
output:
output_file = "path/to/outputfile"
output_txt = "path/to/output_dir/output.txt"
shadow: "full"
shell: "somecommand {input} {output.output_file} && mv output.txt {output.output_txt}"
这应该在其自己的临时目录中运行规则的每次执行,并且通过将移动的 output.txt 指定为输出 Snakemake 应该在规则运行完成后将其移动到真实的输出目录。
推荐阅读
- java - 如何使用 solr 中不同字段的间隔计算字段的值总和?
- android-security - FCM 安全警报
- javascript - 如何将任何数字转换为 1 或 -1 并通过按位运算符保留符号?
- css - 输入类显示正确,按钮类不显示
- sql - 如何使用 SQL Developer 以 CSV 单独文件导出 Oracle 表数据
- django - 当我将图像上传到数据库时,nonetype' 对象没有属性 'decode' 错误
- excel - VBA将满足条件的多个行复制到另一个工作表
- itext - itextsharp ,为什么 GetSingleSpaceWidth() 在空间很明显时返回 0 ?
- reactjs - 如何在反应状态下将状态从 1 循环到 100
- python - 解析根节点,获取整个文件结构?