我正在运行的程序只需要指定目录即可保存输出文件。如果我用snakemake运行它,它会给我错误:
IOError: [Errno 2] No such file or directory: 'BOB/call_images/chrX_194_1967_BOB_78.rpkm.png'我的尝试:
rule all:
input:
"BOB/call_images/"
rule plot:
input:
hdf="BOB/hdf5/analysis.hdf5",
txt="BOB/calls.txt"
output:
directory("BOB/call_images/")
shell:
"""
python someprogram.py plotcalls --input {input.hdf} --calls {input.txt} --outputdir {output[0]}
"""这两个版本都不工作:
output:
outdir="BOB/call_images/"发布于 2021-04-21 22:42:19
通常,snakemake会为指定的输出文件创建输出目录。snakemake directory()声明告诉snakemake目录就是输出,所以它让规则来创建输出目录。
如果您可以预测输出文件的名称(即使您没有在命令行中指定它们),那么您应该在output:字段中告诉snakemake输出文件名。例如:
rule plot:
input:
hdf="BOB/hdf5/analysis.hdf5",
txt="BOB/calls.txt"
output:
"BOB/call_images/chrX_194_1967_BOB_78.rpkm.png"
params:
outdir="BOB/call_images"
shell:
"""
python someprogram.py plotcalls --input {input.hdf} --calls {input.txt} --outputdir {params.outdir}
"""(使用params来定义输出目录而不是在shell命令中对其进行硬编码的好处是,您可以在其中使用通配符)
如果无法预测输出文件名,则必须手动运行mkdir -p {output}作为外壳命令的第一步。
rule plot:
input:
hdf="BOB/hdf5/analysis.hdf5",
txt="BOB/calls.txt"
output: directory("BOB/call_images")
shell:
"""
mkdir -p {output}
python someprogram.py plotcalls --input {input.hdf} --calls {input.txt} --outputdir {output}
"""https://stackoverflow.com/questions/67197779
复制相似问题