'snakemake --use-conda with an already created envs

I work on an SGE cluster where some tools are available with conda :

source activate unicycler-0.4.7

I can use conda on my snakemake workflow with yaml, but in this way, I will going to reinstall the environment.

name: unicycler
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - unicycler=0.4.7

Is it possible to activate an existing environment?

Thanks very much for your helps!

Version :

  • snakemake 5.4.0
  • conda 4.6.14

Best regards,



Solution 1:[1]

I should add at the beginning of the Snakefile :

shell.executable("/bin/bash")
shell.prefix("source /usr/local/genome/Anaconda3/etc/profile.d/conda.sh; ") 

Prefix to be adapted according to your installation.

After that, envs can be load like in interactive session with conda activate unicycler-0.4.7 for example.

Solution 2:[2]

This has gotten support recently: https://snakemake.readthedocs.io/en/stable/snakefiles/deployment.html#using-already-existing-named-conda-environments

rule NAME:
    input:
        "table.txt"
    output:
        "plots/myplot.pdf"
    conda:
        "unicycler"
    script:
        "scripts/unicycler.py"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Midoux
Solution 2 Maarten-vd-Sande