The Seven Bridges Knowledge Center

The Seven Bridges Platform is a simple solution for doing bioinformatics at industrial scale. But sometimes, everyone needs a little help.

Get Started

Upload a custom python program using a Dockerfile

Objective

This tutorial will explain how to create a Docker image containing two custom Python programs, using a Dockerfile to build the image. You will then learn how to push the image to the Seven Bridges image registry.

The scripts used in the tutorial are:

  • transcribe.py - Gets an input DNA file composed of nucleotides and transcribes it into RNA. The output file produced by the program is rna.txt.
  • translate.py - Takes mRNA as input and translates it into a peptide. The output file produced by the program is peptide.txt.

📘

Learn more about Dockerfiles.

Prerequisites

For this tutorial, you will need:

  1. An account on the Seven Bridges Platform.
  2. One of the following machines:

1. Create a project on the Platform

To create a project:

  1. Click Projects in the top navigation bar and choose Create a project.
  2. Name the project dna2protein.
  1. Click Create.
    You have now created the new project.

2. Build the image

You will first need to download the package containing the programs and the Dockerfile, and then create a Docker image called dna2protein containing the programs.

To do this:

  1. Click here to download the archive containing the programs and the Dockerfile.
  2. Open up a terminal.

📘

Depending on your operating system, first make sure that Docker is started:

  • Docker on Mac OS 10.10.3 Yosemite or newer run Docker for Mac and start a terminal of your choice.
  • Docker on Mac OS 10.8 Mountain Lion or newer run Docker Machine, by opening Docker Quickstart terminal or by using the command docker-machine start default.
  • Windows 7 or 8: run Docker Quickstart Terminal.
  • Windows 10: run Docker for Windows and start a terminal of your choice.
  • Linux: skip this step.
  1. Use the cd command to navigate to the folder where the downloaded archive is located, for example:
cd /home/rfranklin/Downloads
  1. Unzip the downloaded file by typing:
unzip dna2protein-tutorial.zip -d ../dna2protein
  1. Navigate to the folder containing the programs and the Dockerfile:
cd ../dna2protein/dna2protein-tutorial

You are now ready to build the image.

  1. Build the image from the Dockerfile:
docker build -t dna2protein .

The image is built based on the instructions in the Dockerfile, which is supplied in the downloaded archive.
When the build process is over, you will have a newly created image containing the Python programs.

  1. To test the programs, enter the following command which will run the image and open the bash terminal inside a container:
docker run -ti dna2protein bash

Then display the help messages for the programs:

transcribe.py -h

This command should return:

Translates a DNA input test into a RNA
 
positional arguments:
  dna            DNA input file to transcribe
 
optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose
  --version      show program's version number and exit

You can do the same with translate.py:

translate.py -h

Which should return:

Transcribe the provided mRNA into a peptide.
 
positional arguments:
  mRNA           mRNA to transcribe
 
optional arguments:
  -h, --help     show this help message and exit
  --verbose, -v  Run in verbose mode (default: False)
  --version      show program's version number and exit

You have now successfully created and tested a Docker image containing the software.

  1. Enter the following command to leave the container:
exit

3. Push the image to the Seven Bridges image registry

As you now need to push the image to the Seven Bridges image registry, you have to specify the repository name for the image, according to the following naming convention: images.sbgenomics.com/<username>/<repository_name>:<tag>. Note that the <username> part needs to be your Platform username, while <repository_name> must be at least 3 characters long and can only contain lowercase letters, numbers, ., - and _. Learn more about repository names in the Seven Bridges image registry.

📘

If you are using the Seven Bridges Platform on AWS EU, please use eu-images.sbgenomics.com as the image registry instead of images.sbgenomics.com.

If you signed up for the Seven Bridges Platform by explicitly selecting Google Cloud Platform as the cloud service provider, you will need to use Docker Hub to store your images, instead of the Seven Bridges image registry. For detailed instructions on how to push your image(s) to Docker Hub, please refer to the official Docker Hub documentation.

If you signed up for the Platform before August 2015, the cloud service provider will be Amazon Web Services US by default.

  1. Enter the following command to specify the repository name:
docker tag dna2protein images.sbgenomics.com/<user_name>/dna2protein:v0.5.4.dev

The repository name also includes the version of the software we are wrapping for use on the Platform, which is currently 0.5.4.dev.

  1. Now you need to log in to the Seven Bridges image registry (images.sbgenomics.com):
docker login images.sbgenomics.com

❗️

You should enter your authentication token in response to the password prompt, not your Seven Bridges password.

  1. Finally, push the image to the Seven Bridges image registry:
docker push images.sbgenomics.com/<user_name>/dna2protein:v0.5.4.dev
  1. Once you are finished, you can explicitly stop your connection to the Seven Bridges image registry (images.sbgenomics.com):
docker logout images.sbgenomics.com

Once the process has been completed, use the Tool Editor to provide a description of the programs on the Platform.

Updated 10 months ago

Upload a custom python program using a Dockerfile


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.