Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgalbraith committed Mar 22, 2023
0 parents commit dd184e7
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --tag buildtest:$(date +%s)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
################# BASE IMAGE ######################
FROM --platform=linux/amd64 mambaorg/micromamba:1.3.1-focal
# Micromamba for fast building of small conda-based containers.
# https://github.com/mamba-org/micromamba-docker
# The 'base' conda environment is automatically activated when the image is running.

################## METADATA ######################
LABEL base_image="mambaorg/micromamba:1.3.1-focal"
LABEL version="1.0.0"
LABEL software="Tophat"
LABEL software.version="2.1.1"
LABEL about.summary="TopHat is a fast splice junction mapper for RNA-Seq reads. It aligns RNA-Seq reads to mammalian-sized genomes using the ultra high-throughput short read aligner Bowtie, and then analyzes the mapping results to identify splice junctions between exons."
LABEL about.home="https://ccb.jhu.edu/software/tophat/index.shtml"
LABEL about.documentation="https://ccb.jhu.edu/software/tophat/manual.shtml"
LABEL about.license_file=""
LABEL about.license=""

################## MAINTAINER ######################
MAINTAINER Matthew Galbraith <matthew.galbraith@cuanschutz.edu>

################## INSTALLATION ######################

# Copy the yaml file to your docker image and pass it to micromamba
COPY --chown=$MAMBA_USER:$MAMBA_USER env.yaml /tmp/env.yaml
RUN micromamba install -y -n base -f /tmp/env.yaml && \
micromamba clean --all --yes
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[![Docker Image CI](https://github.com/mattgalbraith/tophat2-docker-singularity/actions/workflows/docker-image.yml/badge.svg)](https://github.com/mattgalbraith/tophat2-docker-singularity/actions/workflows/docker-image.yml)

# tophat2-docker-singularity

## Build Docker container for TopHat2 and (optionally) convert to Apptainer/Singularity.

TopHat is a fast splice junction mapper for RNA-Seq reads. It aligns RNA-Seq reads to mammalian-sized genomes using the ultra high-throughput short read aligner Bowtie, and then analyzes the mapping results to identify splice junctions between exons.
https://ccb.jhu.edu/software/tophat/index.shtml

#### Requirements:
Bowtie2
Install within image using micromamba + env.yaml file
https://github.com/mamba-org/micromamba-docker

## Build docker container:

### 1. For TopHat2 installation instructions:
https://ccb.jhu.edu/software/tophat/tutorial.shtml


### 2. Build the Docker Image

#### To build image from the command line:
``` bash
# Assumes current working directory is the top-level tophat2-docker-singularity directory
docker build -t tophat2:2.1.1 . # tag should match software version
```
* Can do this on [Google shell](https://shell.cloud.google.com)

#### To test this tool from the command line:
``` bash
docker run --rm -it tophat2:2.1.1 tophat2 --help

# Optional: Run with test data
wget https://ccb.jhu.edu/software/tophat/downloads/test_data.tar.gz
tar -xzvf test_data.tar.gz
cd test_data
docker run --rm -it -v "$PWD":/data -w /data tophat2:2.1.1 tophat -r 20 test_ref reads_1.fq reads_2.fq
# -v mounts current working dir as /data in container
# -w sets working dir in conatiner
# SUCCESSFUL TEST RESULT = output lines similar to this:

# [2023-03-22 00:29:02] Beginning TopHat run (v2.1.1)
# -----------------------------------------------
# [2023-03-22 00:29:02] Checking for Bowtie
# Bowtie version: 2.2.5.0
# [2023-03-22 00:29:03] Checking for Bowtie index files (genome)..
```

## Optional: Conversion of Docker image to Singularity

### 3. Build a Docker image to run Singularity
(skip if this image is already on your system)
https://github.com/mattgalbraith/singularity-docker

### 4. Save Docker image as tar and convert to sif (using singularity run from Docker container)
``` bash
docker images
docker save <Image_ID> -o tophat2.1.1-docker.tar && gzip tophat2.1.1-docker.tar # = IMAGE_ID of tophat image
docker run -v "$PWD":/data --rm -it singularity:1.1.5 bash -c "singularity build /data/tophat2.1.1.sif docker-archive:///data/tophat2.1.1-docker.tar.gz"
```
NB: On Apple M1/M2 machines ensure Singularity image is built with x86_64 architecture or sif may get built with arm64

Next, transfer the tophat2.1.1.sif file to the system on which you want to run TopHat2 from the Singularity container

### 5. Test singularity container on (HPC) system with Singularity/Apptainer available
``` bash
# set up path to the Singularity container
TOPHAT2_SIF=path/to/tophat2.1.1.sif

# Test that tophat2 can run from Singularity container
singularity run $TOPHAT2_SIF tophat2 --help # depending on system/version, singularity may be called apptainer
```
11 changes: 11 additions & 0 deletions env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Using an environment name other than "base" is not recommended!
# Read https://github.com/mamba-org/micromamba-docker#multiple-environments
# if you must use a different environment name.
name: base
channels:
- bioconda
- conda-forge
- defaults
dependencies:
# - bowtie2=2.5.1 # seems to prevent mamba solving environment
- tophat=2.1.1
Binary file added test_data.tar.gz
Binary file not shown.

0 comments on commit dd184e7

Please sign in to comment.