Reputation: 21
I recently started using snakemake
and would like to run a shell
script in my snakefile. However, I'm having trouble accessing input
, output
and params
. I would appreciate any advice!
Here the relevant code snippets:
rule ..:
input:
munged = 'results/munged.sumstats.gz'
output:
ldsc = 'results/ldsc.txt'
params:
mkdir = 'results/ldsc_results/',
ldsc_sumstats = '/resources/ldsc_sumstats/',
shell:
'scripts/run_gc.sh'
chmod 770 {input.munged}
mkdir -p {params.mkdir}
ldsc=$(ls {params.ldsc_sumstats})
for i in $ldsc; do
...
I get the following error message:
...
chmod: cannot access '{input.munged}': No such file or directory
ls: cannot access '{params.ldsc_sumstats}': No such file or directory
...
Upvotes: 2
Views: 574
Reputation: 3330
From v7.14.0 Snakemake now supports executing external Bash scripts, with access to snakemake objects inside. See the docs for example usage.
Upvotes: 1
Reputation: 16561
The syntax of using {}
statements applies only to shell scripts defined within Snakefile
, while in the example you provide, the script is defined externally.
If you want to use the script as an external script you will need to pass the relevant arguments (and parse them inside the shell script). Otherwise, it should be possible to copy-paste the script content inside the shell
directive and let snakemake substitute the {}
variables.
Upvotes: 2