Home > database >  Avoid shell printing output when running in params directive
Avoid shell printing output when running in params directive

Time:08-13

I have a rule approximately structured as

rule something:
    input: "file1.txt"
    output: "file2.txt"
    params: my_variable = shell("uname")
    shell: "cat <({params.my_variable}) {input} > {output}"

This causes my workflow to print out the output of my_variable right before

Linux
Building DAG of jobs...

etc.

This messes up with a series of options in Snakemake, though (e.g., snakemake -R $(snakemake --list-code-changes) or snakemake --dag | dot) and forces to sanitise the output of the snakemake call (e.g. snakemake --dag | grep <(uname) -v | dot). Is there a way to prevent this?

Thanks!

CodePudding user response:

I would use:

params:
    my_variable=os.uname().sysname

my_variable=shell(...) probably doesn't do what you need anyway because it just executes the shell command and the variable my_variable stays empty (None)

  • Related