Search code examples
snakemake

snakemake - accessing conda environment assets not in bin/


I am using some conda envs in my workflow which contain useful assets (data, models, etc) that are not in the environment bin/ path, e.g. specific files found under share/ , opt/ or other.
Is there a standard way to access these paths from within the workflow? Maybe a variable containing the path to the environment? Otherwise, I'm finding myself using all sorts of Linux tricks to locate these files. Things like:

rule snap:
    ...
    conda:
        snap.yaml
    shell:
        """
        # find env dir
        env=`grep -l snap ./.snakemake/conda/*.yaml | xargs basename | sed 's/\.yaml//'`
        snap ./.snakemake/conda/$env/share/HMM/X.hmm {input}
        """

Any ideas on how to go about such cases?


Solution

  • The variable $CONDA_PREFIX contains the path to the current activated environment. From there it should be easy to go to share, opt etc.

    If this doesn't help, try posting the directory tree of your setup and what you want to access as it is not entirely clear, at least to me.