3

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.

Alexis
  • 367
  • 2
  • 9

1 Answers1

1

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.

Manavalan Gajapathy
  • 3,900
  • 2
  • 20
  • 43
  • Thanks for the link, you are right this must be the reason, I think in the end I will switch to using a script to mix python and shell calls. – Alexis Apr 23 '20 at 08:26