英文:
Access working directory from bash script
问题
I'd like to access the snakemake working directory variable in a post deployment bash script (similarly to how you can access workflow.basedir
in Python)
I've seen this example but it doesn't mention what I want. I can't find any overview of these types of variables in general which sucks because they are massively helpful.
EDIT: $PWD does appear to be the parent of the workflow.basedir but I'd still like to know if accessing the variable is possible in a bash script.
英文:
I'd like to access the snakemake working directory variable in a post deployment bash script (similarly to how you can access workflow.basedir
in Python)
I've seen this example but it doesn't mention what I want. I can't find any overview of these types of variables in general which sucks because they are massively helpful.
EDIT: $PWD does appear to be the parent of the workflow.basedir but I'd still like to know if accessing the variable is possible in a bash scrip.
答案1
得分: 1
看起来你可以使用workflow.workdir
来获取工作目录。
对于bash脚本,你可以传递该值,但注释是正确的,bash脚本的工作目录应该在$PWD
中,除非你使用cd命令,这应该与你在snakemake中设置的工作目录匹配。
考虑提出一个问题,要求关于可用属性的文档,我同意它们不容易找到。你可以尝试在Snakefile中添加一个breakpoint()
,然后使用pdb来检查workflow
的自动完成选项...
英文:
Seems like you can get the workdir with workflow.workdir
For a bash script you can pass that value in, but the comments are correct, the working directory of the bash script should be in $PWD
and unless you cd that should match the working directory you set in snakemake.
Consider opening an issue requesting documentation on the available attributes, I agree they aren't easy to find. You could try to add a breakpoint()
in the Snakefile and use pdb to examine autocomplete options of workflow
...
答案2
得分: 1
我不知道你的工作流程是如何运作的,但我认为应该类似于这样:
rule run_bash_script:
output:
"output.txt"
shell:
"""
# 你的 Bash 脚本
echo "Directory: {workflow.basedir}" > {output}
"""
英文:
Idk how your workflow works, but think something like this:
rule run_bash_script:
output:
"output.txt"
shell:
"""
# Your bash script
echo "Directory: {workflow.basedir}" > {output}
"""
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论