Home > Software engineering >  Getting command line flags from snakemake
Getting command line flags from snakemake

Time:03-30

Is it possible to retrieve the flags used on the command line? For example, I want to force the use conda for my workflow, as I have set up environments for various rules. This allows me to control package versions, and users don't have to install packages manually. This is what I would like to do:

When on the command line, I use this command:
snakemake --cores 10

I can then detect the usage of these flags. For example:

if snakemake.flags.use_conda == False:
    print("You must use conda!")
    exit(1)

I know this isn't exactly perfect, but I hope my intentions are clear.

Thanks for any help!

CodePudding user response:

Maybe:

if not workflow.use_conda:
    sys.stderr.write("Use conda\n")
    sys.exit(1)

Note that sys.exit makes snakemake give an ugly error trace - I vaguely remember a hacky workaround which I cannot find now...

  • Related