OronNavon
OronNavon

Reputation: 1333

How to get snakemake to --use-conda by default?

My Snakefiles contain "conda" directives, and I always invoke snakemake with the --use-conda flag.

Is there a way to have this flag enabled by default? That is, can I get snakemake to use conda by default without explicitly adding --use-conda to every invocation?

Upvotes: 2

Views: 369

Answers (2)

dariober
dariober

Reputation: 9062

You could define an alias for snakemake as

alias snakemake='snakemake --use-conda'

but then if you don't want to set --use-conda you would have either to remove the alias (unalias snakemake) or use a different name for the alias (e.g. alias mysnakemake='snakemake --use-conda').

But really, I would just write --use-conda throughout to avoid confusion.

UPDATE

UPDATE 2: This below doesn't work anymore in (at least) 7.32.4

After @OronNavon comments, maybe something like this could do. On top of your Snakefile add:

if 'use_conda' in config and config['use_conda']:
    workflow.use_conda = True

where use_conda is a boolean variable that you read from a configuration file. It should work, but again, in my opinion it makes things confusing...

Upvotes: 3

karldw
karldw

Reputation: 371

One way to have a "global" configuration file is to create a snakemake profile, then change your alias to always load it.

mkdir -p ~/.config/snakemake/my_profile
echo "use-conda: True" >> ~/.config/snakemake/my_profile/config.yaml

Then set an alias:

alias snakemake='snakemake --profile my_profile'

Upvotes: 1

Related Questions