How to build Bioinformatic tools image for docker

Docker is getting popular for Serverless application. In this article, I would like to show how to build a docker image for Bioinformatic tools like Bowtie. You can find what Bowtie is at http://bowtie-bio.sourceforge.net/index.shtml
 

Installing Docker
For Mac
1. Let’s start with downloading docker for Mac from this url: https://download.docker.com/mac/stable/Docker.dmg
2. Mount Docker.dmg, install by dragging Docker.app to Applications dir.

install docker

3. Docker (the whale icon) should now appeared on the Applications, click on Docker to being the installation. Follow the installation instruction.
4. When installation is complete, Open terminal and check by running:

$ docker --version

which should response like this:

Docker version 1.12.0, build 8eab29e

5. Docker is ready!

Creating a docker image with bioconda environment
Bioconda is a channel of bioinformatic tools for a package manager, Conda. Most of the tools can be easily installed with Bioconda, so a docker image with bioconda environment is required.
1. Create working directory.

mkdir docker-conda
cd docker conda

2. Create Dockerfile

touch Dockerfile

3. Using editor, put following lines to Dockerfile.

FROM ubuntu

This tells docker to use ubuntu as base image.

RUN apt-get -y update
RUN apt-get install -y wget gzip zip bzip2 python

Update and install the required packages.

RUN mkdir /usr/tools && cd /usr/tools
RUN mkdir /usr/tools/bin
WORKDIR /usr/tools

Create working directory in the image.

RUN wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh

Download miniconda installer.

RUN echo "yes\nyes\n" > conda_inst_stdin.txt

Create input fot miniconda installer’s prompt.

RUN bash Miniconda2-latest-Linux-x86_64.sh < conda_inst_stdin.txt

Install conda.

ENV PATH /root/miniconda2/bin:$PATH

Add conda’s executable path to environment.

RUN conda config --add channels r
RUN conda config --add channels bioconda
RUN conda list

Add bioconda channel.

ADD . /data
WORKDIR /data

Add current directory to the container at ‘/data’ and change container’s working directory to ‘/data/’
4. To build the image, run ‘docker build’.

docker build -t docker-conda .

5. Test integrity of bioconda by running:

docker run docker-conda conda --version

Which should print current version of conda

conda 4.1.11

Create automate build from github repository
1. Create github repository with the dockerfile.

Docker_automate_githup
2. Create account and log in to https://hub.docker.com.
3. Click ‘Create‘ and select ‘Create Automate build‘.

Docker_automate_create

4. Click ‘Create Auto-Build Github‘.

Aocker_automate_link_githup

5. Select github repository which would be auto-built.

Aocker_automate_select_repo

6. Enter description of the repository.

Aocker_automate_description

7. Click create.

Install Bowtie1 with conda
To install bowtie to the image, put following line to Dockerfile:

RUN conda install -y bowtie

Build image.

docker build -t docker-conda .

Test If bowtie installed correctly. Run:

docker run docker-conda bowtie -v

Docker_bowtie_show

Let’s start with building reference index for bowtie. Create directory ‘reference’.

mkdir reference

Build the reference fasta file using bowtie.

docker run -v `pwd`:/data -w /data docker-conda bowtie-build reference/ref.fa reference/ref

Docker_bowtie_index

Check the index. There should be some files with .ebwt extension.

docker run -v `pwd`:/data -w /data docker-conda ls -al reference

Docker_bowtie_ls

Run mapping reference index with sequence.fastq .

docker run -v `pwd`:/data -w /data docker-conda bowtie reference/ref sequence.fastq > map.sam

Docker_bowtie_map


2 thoughts on “How to build Bioinformatic tools image for docker

  1. Hello,

    Thanks for your post, when I ran:
    docker build -t docker-conda .

    I got the following error:
    E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/python-defaults/python-minimal_2.7.11-1_amd64.deb 503 Service Unavailable [IP: 91.189.91.26 80]

    E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
    Fetched 7097 kB in 42s (167 kB/s)
    The command ‘/bin/sh -c apt-get install -y wget gzip zip bzip2 python’ returned a non-zero code: 100

    Any help?

Comments are closed.