'snakemake parameter exploration: how to pass options to a command in shell directive?
I'm performing parameter exploration using Paramspace utility as described here. I've read parameters in a pandas dataframe and next I wish to pass these as values of options of a shell command but can't figure out how.
In the below minimal example, I wish to pass parameter s (read in dataframe df) as the value of option -n for head command in the shell directive.
from snakemake.utils import Paramspace
import pandas as pd
df = pd.DataFrame(
{'s' : [1, 2, 3]},
index = [1, 2, 3]
)
paramspace_empty = Paramspace(df)
rule all:
input:
expand("results/{params}.tsv", params=paramspace_empty.instance_patterns)
rule simulate_empty:
output:
f"results/{paramspace_empty.wildcard_pattern}.tsv"
params:
simulation=paramspace_empty.instance
shell: """
head input.txt > {output}
"""
I tried the below and similar variations but nothing worked.
shell: """
head -n {params.simulation['s']} input.txt > {output}
"""
The above example is extracted (and modified a bit) from the Snakefile here which tests paramspace utility.
I seem to be missing something fundamental or trivial. Thank you in advance for any help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
