Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shell() function in run does not use singularity

Tags:

snakemake

EDIT I have now posted this question as an issue on the Snakemake bitbucket given this seems to be an unknown behavior.


I am using snakemake with the --use-singularity option.

When I use a classic rule of the form:

singularity: mycontainer

rule myrule:
  input:
  output:
  shell:
    "somecommand"

with the somecommand only present in the singularity container, everything goes fine.

However, when I need to use some python code in the run part of the rule, the command is not found.

rule myrule:
  input:
  output:
  run:
    some python code here
    shell("somecommand")

The only workaround I found is to use

shell("singularity exec mycontainer somecommand")

but this is not optimal.

I am either missing something, such as an option, or this is a missing feature in snakemake.

What I would like to obtain is to use the shell() function with the --use-singularity option.

like image 232
Alexis Avatar asked Jan 28 '26 21:01

Alexis


1 Answers

Snakemake doesn't allow using --use-conda with run block and this is why:

The run block of a rule (see Rules) has access to anything defined in the Snakefile, outside of the rule. Hence, it has to share the conda environment with the main Snakemake process. To avoid confusion we therefore disallow the conda directive together with the run block. It is recommended to use the script directive instead (see External scripts).

I bet --use-singularity is not allowed with run block for the same reason.

like image 147
Manavalan Gajapathy Avatar answered Jan 30 '26 17:01

Manavalan Gajapathy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!