4.2. Singularity

Please see the slides about singularity before starting the following exercices.

4.2.1. Prerequisites

If you use the solution on desktop.pasteur.fr for this course, singularity is already installed for you.

If not, you will need to install Singularity yourself.

The easiest is to use Conda, create an environment, activate it and install singularity.

$ ## Activate the conda environment
$ conda activate
$ ## Install singularity (just once per newly activated VM)
$ conda install singularity=3.6.3
$ ## Display singularity help
$ singularity --help

If you prefer to install singularity yourself, please see the slides provided with the course. For most up-to-date installation instructions, please see the singularity instructions:

https://sylabs.io/guides/3.0/user-guide/installation.html#install-on-linux

4.2.2. Example: creation of a container with the fastqc software

First, following examples from the course, we should build a container with the fastqc executable in it.

Here is a recipe to install fastqc under a centos Linux box:

Bootstrap: docker
From: centos:7

%post
yum install -y java-1.8.0-openjdk
yum install -y wget unzip perl
wget https://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.9.zip
unzip fastqc_v0.11.9.zip
chmod 755 /FastQC/fastqc

%environment
    export PATH=/FastQC:$PATH

%runscript
    exec fastqc "$@"

Once you have that file, name it Singularity.fastqc. You can then create the container with this command:

sudo singularity build fastqc.img Singularity.fastqc

Note that you must use sudo. This command builds and installs fastqc on a blank Centos distribution. Here, all commands are executed in the %post section. You may define extra section to set environement variables. Here we also set a %runscript section to define a default behaviour (see later).

4.2.3. Running a container

Try the container you have just built:

singularity run fastqc.img --help

Here we have built an executable container thanks to the section "runscript".

Rebuild the previous container removing the section runscript. This new container will not be executable. However, you will be able to execute fastqc as follows:

singularity run fastqc.img fastqc --help

You can also enter a container. This is useful for different reasons. One obvious way is for debugging. Another is for introspection:

singularity shell fastqc.img

4.2.4. Exercices

4.2.4.1. Create a container with bwa

Using the previous recipe adapt the different sections (post/environment/runscript) to create a new recipe that a container with the bwa tool (http://bio-bwa.sourceforge.net/).

You can use different techniques:

  1. using the bwa source (compilation required)

  2. building a conda environement inside the container and installing bwa with conda

  3. building from an existing docker image (to be found)

4.2.4.2. Download an existing container from a URL

You can download existing file as follows:

singularity  pull  https://biomics.pasteur.fr/salsa/damona/fastqc_0.11.9.img

and try the image.

4.2.4.3. Use a singularity file on the Pasteur campus

You cannot build a singularity container on the IP cluster (you would need sudo permissions) but you can pull a container and then use it.

In practice, you can build a container locally and copy it remotely on the cluster. Or, from the cluster you can retrieve an existing container.

If both case, you will need to use singularity on the cluster. Singulariry is available via the module put in place by the DSI:

module av singularity
module load singularity/3.6.4

4.2.4.4. Build container for each tool

Using the technique you want (conda, compilation, existing recipe), create a singularity container with:

This tools will allow us to map, call variants and define clades using SARS-CoV-2 sequencing data. You can first organize in groups and coordinate who will create which image.