Skip to content

Commit

Permalink
Update README/workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgalbraith committed May 5, 2023
1 parent 4c8f145 commit f18338a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 41 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
File renamed without changes.
76 changes: 42 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
[![Docker Image CI](https://github.com/mattgalbraith/homer-docker-singularity/actions/workflows/docker-image.yml/badge.svg)](https://github.com/mattgalbraith/homer-docker-singularity/actions/workflows/docker-image.yml)

# homer-docker-singularity
Build Docker container for homer software and (optionally) convert to Apptainer/Singularity
Dockerfile modified from https://github.com/chrisamiller/docker-homer

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

HOMER (Hypergeometric Optimization of Motif EnRichment) is a suite of tools for Motif Discovery and next-gen sequencing analysis. It is a collection of command line programs for UNIX-style operating systems written in Perl and C++. HOMER was primarily written as a de novo motif discovery algorithm and is well suited for finding 8-20 bp motifs in large scale genomics data. HOMER contains many useful tools for analyzing ChIP-Seq, GRO-Seq, RNA-Seq, DNase-Seq, Hi-C and numerous other types of functional genomics sequencing data sets.
http://homer.ucsd.edu/homer/


### Requirements:
gcc
g++
make
perl
zip/unzip
gzip/gunzip
wget
samtools (optional)
R (optional)

## Build docker container:

### 1. For homer installation instructions:
http://homer.ucsd.edu/homer/introduction/install.html
http://homer.ucsd.edu/homer/download.html

### 2. Build the Docker Image

#### To build your image from the command line:
* Can do this on [Google shell](https://shell.cloud.google.com) - docker is installed and available

```bash
WORKING_DIR=`pwd` # capture current working directory (should be the top-level homer-docker-singularity directory)
cd homer-docker
docker build -t homer .
### 2. Build the Docker Image
``` bash
# Assumes current working directory is the top-level tophat2-docker-singularity directory
docker build -t homer:4.11.1 . # tag should match software version (configureHomer.pl can specify version version)
```

Due to space limitations, especially on Google Cloud Shell, need to symlink to external Homer annotation directory
* Can do this on [Google shell](https://shell.cloud.google.com)

#### To test this tool from the command line:
Mount and use your current directory and call the tool now encapsulated within the container
```bash
docker run --rm -it -v $PWD:$PWD -w $PWD homer homer
docker run --rm -it homer:4.11.1 homer
docker run --rm -it homer:4.11.1 perl /opt/homer/configureHomer.pl -list | grep homer
docker run --rm -it homer:4.11.1 perl /opt/homer/configureHomer.pl -check
```

### 3. Download and mount homer data
Due to space limitations, especially on Google Cloud Shell, need to link/mount Homer annotation data from outside containers
```bash
cd $WORKING_DIR
mkdir homer_data && cd homer_data
wget http://homer.ucsd.edu/homer/configureHomer.pl
perl ./configureHomer.pl install hg38 # this will download "hg38" and "human" annotation packages
perl ./configureHomer.pl -install hg38 # this will download "hg38" and "human" annotation packages

# Optional: archive and compress for transfer to eg HPC without internet access
cd .. && tar -czvf homer_data.tar.gz homer_data
Expand All @@ -42,40 +57,33 @@ tar -xzvf homer_data.tar.gz
#### Check if homer can see mounted reference and annotation data
```bash
# first set up path to homer_data
HOMER_DATA = path/to/homer_data
HOMER_DATA=path/to/homer_data
# Mount homer data in container at /opt/homerdata (see symlinks created in Dockerfile)
docker run --rm -it -v $HOMER_DATA:/opt/homerdata -v $PWD:$PWD -w $PWD homer /usr/bin/perl /opt/homer/configureHomer.pl -list
docker run --rm -it -v $HOMER_DATA:/opt/homerdata homer:4.11.1 /usr/bin/perl /opt/homer/configureHomer.pl -list
# output should indicate that correct genome packages are installed
```

## Optional: Conversion of Docker image to Singularity

### 4. Build a Docker image to run Singularity

```bash
cd $WORKING_DIR/singularity-docker
docker build -t singularity .
```
### 4. Build a Docker image to run Singularity
(skip if this image is already on your system)
https://github.com/mattgalbraith/singularity-docker

#### Test singularity container
```bash
docker run --rm -it -v $PWD:$PWD -w $PWD singularity singularity
```

### 5. Save Docker image as tar and convert to sif (using singularity run from Docker container)
```bash
cd $WORKING_DIR
docker save <Image_ID> -o homer-docker.tar # = IMAGE_ID of homer image
docker run -v "$PWD:/out" --rm -it singularity bash -c "singularity build /out/homer.sif docker-archive:///out/homer-docker.tar"
### 5. Save Docker image as tar and convert to sif (using singularity run from Docker container)
``` bash
docker images
docker save <Image_ID> -o homer4.11.1-docker.tar && gzip homer4.11.1-docker.tar # = IMAGE_ID of tophat image
docker run -v "$PWD":/data --rm -it singularity:1.1.5 bash -c "singularity build /data/homer4.11.1.sif docker-archive:///data/homer4.11.1-docker.tar.gz"
```
NB: may build with arm64 architecture if run on M1/M2 Macbook
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 homer.sif file to the system on which you want to run Homer from the Singularity container

### 6. Test singularity container with mounted homer data on (HPC) system with Singularity/Apptainer available
```bash
# set up path to the homer Singularity container
HOMER_SIF=path/to/homer.sif
HOMER_SIF=path/to/homer4.11.1.sif
# set up path to homer_data
HOMER_DATA=path/to/homer_data

Expand Down
7 changes: 0 additions & 7 deletions singularity-docker/Dockerfile

This file was deleted.

0 comments on commit f18338a

Please sign in to comment.