From f18338a575079cfb713cab63afe9e6a29883a1d1 Mon Sep 17 00:00:00 2001 From: Matthew Galbraith Date: Thu, 4 May 2023 21:17:37 -0600 Subject: [PATCH] Update README/workflow --- .github/workflows/docker-image.yml | 18 +++++++ .gitignore | 1 + homer-docker/Dockerfile => Dockerfile | 0 README.md | 76 +++++++++++++++------------ singularity-docker/Dockerfile | 7 --- 5 files changed, 61 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/docker-image.yml create mode 100644 .gitignore rename homer-docker/Dockerfile => Dockerfile (100%) delete mode 100644 singularity-docker/Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..5cd962e --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -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) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/homer-docker/Dockerfile b/Dockerfile similarity index 100% rename from homer-docker/Dockerfile rename to Dockerfile diff --git a/README.md b/README.md index a267860..7fc0132 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 -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 -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 diff --git a/singularity-docker/Dockerfile b/singularity-docker/Dockerfile deleted file mode 100644 index 67411b9..0000000 --- a/singularity-docker/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM centos:7 - -RUN yum -y upgrade - -RUN yum -y install bash epel-release tar - -RUN yum -y install singularity