Access working directory from bash script

huangapple go评论55阅读模式
英文:

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}
        """

huangapple
  • 本文由 发表于 2023年4月10日 20:42:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75977214.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定