mardi 27 juillet 2021

Using wildcards in shell if-else command in snakemake [duplicate]

I have a bit of trouble when running a snakemake rule with a conditional shell part.

I have the following rule, which should execute some shell commands dependent on the value of the wildcard (which is either smaller than 1 or bigger than 1).

rule test:
input: "input.txt"
output: "output_{ratio}.txt"
conda: "envs/env.yaml"
shell:
 """
if [ {wildcards.ratio} -lt 1 ]; then
    head {input} > {output}
else
    ln -sr {input} {output}
fi
 """

If I ran this code i get the following error (e.g.):

/bin/bash: line 0: [: 0.8: integer expression expected

The question is, how can I correctly use wildcard values in the shell script part of my snakemake rule? Thanks

In addition, I can't use the run directive as I need to use a conda environment.

Aucun commentaire:

Enregistrer un commentaire