-
Notifications
You must be signed in to change notification settings - Fork 0
BuildFromScratch
The following tutorial will involve the creation of a container for the STAR (RNA-Seq) aligner.
# Creating Container from Scratch
sudo singularity build --sandbox STARSingularity/ docker://ubuntu
# Begin Modifying Container
sudo singularity shell --writable STARSingularity/
Important Notes:
-
Using sandbox parameters creates folder system instead of single file so we can modify the container.
-
To make any permant changes to container we must use the singularity shell --writeable command.
# Once inside container shell environment. Install necessary dependencies:
# Always do this first
apt update
# Install dependencies.
apt install libbz2-dev
apt install liblzma-dev
apt install zlib1g-dev
apt-get install g++
apt install wget
apt install unzip
apt install nano
wget https://github.com/alexdobin/STAR/releases/download/2.7.11a/STAR_2.7.11a.zip
unzip STAR_2.7.11a.zip
# Move STAR Binary to sbin folder.
mv ./STAR_2.7.11a/Linux_x86_64/STAR /usr/local/sbin/
Now exit out of singularity using (CMD+D). We can now test if STAR can be executed from outside the container.
# Confirm container works:
singularity exec STARSingularity STAR --help
Once we have finished building a container environment in sandbox mode it is best pratice to release a production version.
sudo singularity build STARSingularityProduction.sif STARSingularity
To confirm the production container works we can run:
singularity exec STARSingularityProduction.sif STAR --help
When building a container there may be certain commands which you want to run as soon as the contain is called via the command:
singularity run STARSingularity
This is alternative to using singularity exec command where you have to parse the command.
When building a container from scratch the way to create the runscript is to modify a file called 'singularity' as shown below:
sudo singularity shell --writable STARSingularity/
nano /singularity
Then delete what is in the file which is automatically added when creating the sandbox container and replace it with:
#!/bin/sh
echo "Positional Arguments:"
for arg in "$@"; do
echo "$arg"
done
This run script will parse commands given to it and print these as positional arguments. To validate this:
singularity run STARSingularity My First Container
The output should be:
Positional Arguments:
My
First
Container
By modicfying the run script we can standardise container inputs and outputs.