Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: explain relative path interpretation #1428

Merged
merged 1 commit into from Feb 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/project_info/faq.rst
Expand Up @@ -17,6 +17,29 @@ The key idea is very similar to GNU Make. The workflow is determined automatical
When you start using Snakemake, please make sure to walk through the :ref:`official tutorial <tutorial>`.
It is crucial to understand how to properly use the system.

How does Snakemake interpret relative paths?
--------------------------------------------

Relative paths in Snakemake are interpreted depending on their context.

* Input, output, log, and benchmark files are considered to be relative to the working directory (either the directory in which you have invoked Snakemake or whatever was specified for ``--directory`` or the ``workdir:`` directive).
* Any other directives (e.g. ``conda:``, ``include:``, ``script:``, ``notebook:``) consider paths to be relative to the Snakefile they are defined in.

If you have to manually specify a file that has to be relative to the currently evaluated Snakefile, you can use ``workflow.source_path(filepath)``.

.. code-block:: python

rule read_a_file_relative_to_snakefile:
input:
workflow.get_source("resources/some-file.txt")
output:
"results/some-output.txt"
shell:
"somecommand {input} {output}"


This will in particular also work in combination with :ref:`modules <snakefiles-modules>`.

Snakemake does not connect my rules as I have expected, what can I do to debug my dependency structure?
-------------------------------------------------------------------------------------------------------

Expand Down