Biocontainers

Last updated:

What is Biocontainers

Biocontainers is a ommunity-driven project that provides bioinformatics packages as Conda recipes, Docker Containers, Biocontainers registry.

Using biocontainers

We have a module named biocontainers that you can load which will show additional modules from biocontainers registry.

module load biocontainers

The biocontainers module will set MODULEPATH to a directory where modulefiles are auto-generated using a tool called singularity-hpc which is used to pull containers and generate modules. Shown below is a sample set of modules after loading biocontainers module

-------------------------------------------------------------------------------- /camber/home/tools/shpc/singularity-hpc/views/apps --------------------------------------------------------------------------------
   bcftools/1.22--h3a4d415_1          bwa/0.7.19--h577a1d6_1            picard/3.4.0--hdfd78af_0              samtools/1.22.1--h96c455f_0         trimmomatic/0.39--hdfd78af_2
   bedtools/2.31.1--h13024bc_3        fastqc/0.12.1--hdfd78af_0         portcullis/1.2.4--py39hc12ff1f_3      slow5tools/1.3.0--hee927d3_1        vcftools/0.1.17--pl5321h077b44d_0
   biobb_amber/5.1.0--pyhdfd78af_0    freebayes/1.3.10--hbefcdb2_0      prokka/1.14.6--pl5321hdfd78af_5       slow5tools/1.3.0--hee927d3_2 (D)
   blast/2.16.0--h66d330f_5           gatk4/4.6.2.0--py310hdfd78af_0    python/3.13                           spades/4.2.0--h8d6e82b_1
   bowtie2/2.5.4--he96a11b_6          hisat2/2.2.1--h503566f_8          quast/5.3.0--py313pl5321h5ca1c30_2    star/2.7.11b--h5ca1c30_6

Running Samtools

In this example, we will run a SAM to BAM, sort the BAM file, index and view the content of the BAM file. To get started, you can use this input file call it input.sam

@HD	VN:1.0	SO:coordinate
@SQ	SN:chr1	LN:1000
read1	0	chr1	100	60	50M	*	0	0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA	IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
read2	0	chr1	150	60	50M	*	0	0	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC	IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

Next we will create a script that will run the test.

#!/bin/bash
module load biocontainers
module load samtools
samtools view -bS input.sam > output.bam
samtools sort output.bam -o sorted_output.bam
samtools index sorted_output.bam
samtools view sorted_output.bam | head

Next we will run the test, we named this file convert_sam_to_bam.sh

[shahzebsiddiqui80981545@login samtools]$ bash convert_sam_to_bam.sh
read1	0	chr1	100	60	50M	*	0	0	AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA	IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
read2	0	chr1	150	60	50M	*	0	0	CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC	IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

Upon completion, we will have several files created during each intermediate step of the conversion.

[shahzebsiddiqui80981545@login samtools]$ ls -l
total 20
-rw-r--r-- 1 shahzebsiddiqui80981545 shahzebsiddiqui80981545 218 Aug 27 03:30 convert_sam_to_bam.sh
-rw-r--r-- 1 shahzebsiddiqui80981545 shahzebsiddiqui80981545 309 Aug 27 03:27 input.sam
-rw-r--r-- 1 shahzebsiddiqui80981545 shahzebsiddiqui80981545 264 Aug 27 03:35 output.bam
-rw-r--r-- 1 shahzebsiddiqui80981545 shahzebsiddiqui80981545 298 Aug 27 03:35 sorted_output.bam
-rw-r--r-- 1 shahzebsiddiqui80981545 shahzebsiddiqui80981545  96 Aug 27 03:35 sorted_output.bam.bai

As an end-user you are running samtools in a container which is sets up the appropriate logic to launch container. Shown below is the samtools wrapper script, as you can see the logic of running a singularity container can be complex.

[shahzebsiddiqui80981545@login samtools]$ cat $(which samtools)
#!/bin/bash

script=`realpath $0`
wrapperDir=`dirname $script`/..

singularity ${SINGULARITY_OPTS} exec ${SINGULARITY_COMMAND_OPTS} -B $wrapperDir/99-shpc.sh:/.singularity.d/env/99-shpc.sh   /camber/home/tools/shpc/containers/quay.io/biocontainers/samtools/1.22.1--h96c455f_0/quay.io-biocontainers-samtools-1.22.1--h96c455f_0-sha256:23dc2c29f457a448a0d341fb97b2632a2c8004925214cb6420562a5b12adf8a2.sif /usr/local/bin/samtools "$@"

You can inspect output of module using module show samtools, one of the environment will set SINGULARITY_CONTAINER that is path to the container. Shown below is the path to the samtools container that was pulled from biocontainers. As an end-user you dont have to worry about installing software, rather you can use a prepacked container that will provide everything for you.

[shahzebsiddiqui80981545@login samtools]$ echo $SINGULARITY_CONTAINER
/camber/home/tools/shpc/containers/quay.io/biocontainers/samtools/1.22.1--h96c455f_0/quay.io-biocontainers-samtools-1.22.1--h96c455f_0-sha256:23dc2c29f457a448a0d341fb97b2632a2c8004925214cb6420562a5b12adf8a2.sif