Installing Snakemake and Tibanna using AWS Image Builder
AWS EC2 Image Builder is a great way of automatically building machine images that can be used to run your data analyses.
When you launch an EC2 instance, you want all of your software installed on the instance already, so that you can get your analysis started without having to manually install it every time.
To do this, you need a recipe, which is an ordered list of components.
Components like the one below can be used to install software, verify it, and test it.
In this case, the component below installs the latest Snakemake, Tibanna, numpy, biopython and bioconda (and dependancies), and creates an environment called Tibanna which allows you to access them.
This component is designed to work with default Ubuntu images as a base.
name: InstallSnakemakeAndTibanna
description: Install Snakemake, conda, Tibanna, Mamba
schemaVersion: 1.0
phases:
- name: build
steps:
- name: InstallTibanna
action: ExecuteBash
inputs:
commands:
- mkdir -p /home/ubuntu/bin
- cd /home/ubuntu/bin
- curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"
- bash Mambaforge-$(uname)-$(uname -m).sh -b -p ./mambaforge
- chown -R ubuntu:ubuntu /home/ubuntu/bin
- sudo -H -u ubuntu bash -c '/home/ubuntu/bin/mambaforge/bin/conda init'
- sudo -H -u ubuntu bash -c '. ~/.bashrc; /home/ubuntu/bin/mambaforge/bin/mamba update python conda mamba -y'
- sudo -H -u ubuntu bash -c '/home/ubuntu/bin/mambaforge/bin/mamba create -y -n Tibanna -c conda-forge -c bioconda snakemake biopython numpy tibanna'
- sudo -H -u ubuntu bash -c '/home/ubuntu/bin/mambaforge/bin/mamba init'
Explanation
- The Image Builder takes a component and runs the component’s commands as
root. - First, it makes
~/binfor userubuntu, then it downloads and runs a Mamba install script for it. - Now, it uses
chownto give control of the directory to userubuntu. - Using
sudo -H -u ubuntu bash -c '',rootnow executes commands as the user to update libraries and to initialise Mamba.