Skip to content

Instantly share code, notes, and snippets.

@alanocallaghan
Created December 6, 2021 22:51
Show Gist options
  • Save alanocallaghan/6cfca73d80395842cd154874762bd2e3 to your computer and use it in GitHub Desktop.
Save alanocallaghan/6cfca73d80395842cd154874762bd2e3 to your computer and use it in GitHub Desktop.
Bash script for activating a conda environment with snakemake on a cluster. One argument - the conda environment. Use it like shell.prefix("./act-conda-sm-clust.sh env; ")
#!/usr/bin/env bash
set -eu
if [ -f ~/miniconda3/etc/profile.d/conda.sh ]; then
[ -z "${CONDA_EXE}" ] && echo "Error, missing \$CONDA_EXE !" && exit 1
CONDA_BASE=$(${CONDA_EXE} info --base)
ADDR2LINE=""
source $CONDA_BASE/etc/profile.d/conda.sh
conda activate $1 || exit 1
fi
set +eu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment