From ce8fc9c0a02db43e7209146d9ac7e2525ff594d3 Mon Sep 17 00:00:00 2001 From: linsalrob Date: Thu, 18 Apr 2024 16:02:51 +0930 Subject: [PATCH 1/4] first docker container --- container/Dockerfile | 57 ++++++++++++++++++++++++++++++++++++++++++++ container/README.md | 13 ++++++++++ 2 files changed, 70 insertions(+) create mode 100644 container/Dockerfile create mode 100644 container/README.md diff --git a/container/Dockerfile b/container/Dockerfile new file mode 100644 index 0000000..bf37789 --- /dev/null +++ b/container/Dockerfile @@ -0,0 +1,57 @@ + +# +# phables +# + +FROM --platform=linux/amd64 ubuntu:20.04 +FROM gurobi/optimizer:latest + +ENV DEBIAN_FRONTEND="noninteractive" + + +ARG LIBFABRIC_VERSION=1.18.1 + +# Install required packages and dependencies +RUN apt -y update \ + && apt -y install build-essential wget doxygen gnupg gnupg2 curl apt-transport-https software-properties-common \ + git vim gfortran libtool python3-venv ninja-build python3-pip \ + libnuma-dev python3-dev \ + && apt -y remove --purge --auto-remove cmake \ + && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null\ + | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \ + && apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ jammy-rc main" \ + && apt -y update + +# Build and install libfabric +RUN (if [ -e /tmp/build ]; then rm -rf /tmp/build; fi;) \ + && mkdir -p /tmp/build \ + && cd /tmp/build \ + && wget https://github.com/ofiwg/libfabric/archive/refs/tags/v${LIBFABRIC_VERSION}.tar.gz \ + && tar xf v${LIBFABRIC_VERSION}.tar.gz \ + && cd libfabric-${LIBFABRIC_VERSION} \ + && ./autogen.sh \ + && ./configure \ + && make -j 16 \ + && make install + +# +# Install miniforge +# +RUN set -eux ; \ + curl -LO https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh ; \ + bash ./Miniforge3-* -b -p /opt/miniforge3 -s ; \ + rm -rf ./Miniforge3-* +ENV PATH /opt/miniforge3/bin:$PATH +# +# Install conda environment +# +ARG PHABLES_VERSION=1.3.2 + +RUN set -eux ; \ + mamba install -y -c conda-forge -c bioconda -c defaults \ + phables=${PHABLES_VERSION} ; \ + mamba install -y -c gurobi gurobi +ENV PATH /opt/miniforge3/bin:$PATH +RUN conda clean -af -y + +RUN phables install diff --git a/container/README.md b/container/README.md new file mode 100644 index 0000000..fa6f3db --- /dev/null +++ b/container/README.md @@ -0,0 +1,13 @@ +# Docker container + +Please note that this container is hosted on [docker hub](https://hub.docker.com/r/linsalrob/phables) and we recommend you use the latest version there. + +# Running the container + +You will need to use the [Gurobi WSL]( ) license, and then you can use a command along the lines of: + +``` +sudo docker run --volume=$PWD/Sim_Phage:/Sim_Phage --volume=$PWD/gurobi.lic:/opt/gurobi/gurobi.lic:ro phables phables run --input /Sim_Phage/assembly_graph_after_simplification.gfa --reads /Sim_Phage/reads/ +``` + +We are actively making this work. From f94437494100ff3424a2ff9682e1b0acd5de6571 Mon Sep 17 00:00:00 2001 From: linsalrob Date: Thu, 18 Apr 2024 16:04:22 +0930 Subject: [PATCH 2/4] Dockerfile with all dependencies included --- container/Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/container/Dockerfile b/container/Dockerfile index bf37789..f3d6bb8 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -48,9 +48,11 @@ ENV PATH /opt/miniforge3/bin:$PATH ARG PHABLES_VERSION=1.3.2 RUN set -eux ; \ - mamba install -y -c conda-forge -c bioconda -c defaults \ - phables=${PHABLES_VERSION} ; \ - mamba install -y -c gurobi gurobi + mamba install -y -c conda-forge -c anaconda -c bioconda -c defaults \ + phables=${PHABLES_VERSION} curl "koverage>=0.1.8" minimap2 samtools \ + "mmseqs2=13.45111" biopython python-igraph pysam "networkx>=2.8.6" \ + scipy numpy pandas more-itertools tqdm click "metasnek>=0.0.3" \ + fraggenescan hmmer ENV PATH /opt/miniforge3/bin:$PATH RUN conda clean -af -y From 229dee624a1cecb9647bdeb76a8f8e2a9a1e3fa8 Mon Sep 17 00:00:00 2001 From: linsalrob Date: Thu, 18 Apr 2024 17:38:49 +0930 Subject: [PATCH 3/4] updating the dockerfile and how to use it --- container/Dockerfile | 8 +++----- container/README.md | 48 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/container/Dockerfile b/container/Dockerfile index f3d6bb8..fc012e5 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -49,11 +49,9 @@ ARG PHABLES_VERSION=1.3.2 RUN set -eux ; \ mamba install -y -c conda-forge -c anaconda -c bioconda -c defaults \ - phables=${PHABLES_VERSION} curl "koverage>=0.1.8" minimap2 samtools \ - "mmseqs2=13.45111" biopython python-igraph pysam "networkx>=2.8.6" \ - scipy numpy pandas more-itertools tqdm click "metasnek>=0.0.3" \ - fraggenescan hmmer + phables=${PHABLES_VERSION} ; ENV PATH /opt/miniforge3/bin:$PATH RUN conda clean -af -y - +RUN mkdir -p /phables /opt/gurobi +RUN ln -s /opt/miniforge3/lib/python3.10/site-packages/phables/workflow/conda /conda RUN phables install diff --git a/container/README.md b/container/README.md index fa6f3db..b4037f2 100644 --- a/container/README.md +++ b/container/README.md @@ -2,12 +2,52 @@ Please note that this container is hosted on [docker hub](https://hub.docker.com/r/linsalrob/phables) and we recommend you use the latest version there. -# Running the container +# Installing guorobi -You will need to use the [Gurobi WSL]( ) license, and then you can use a command along the lines of: +For the linear solver, you need the [Gurobi WLS](https://www.gurobi.com/features/academic-wls-license/) license. Get that file, which is called `gurobi.lic` by default, and put it in your home directory, or another location that you know where it is. + +# Running the container with singularity (recommended) + +We need to mount three locations that are writable for `phables` to work with singularity. + +1. You need to mount the `gurobi.lic` file, and that needs to end up at `/opt/gurobi/gurobi.lic`. In the example here, it is in the current working directory, `$PWD`. +2. You need a temporary directory where conda can install some files. They are installed on the first run, and reused after that. In this example, I am using `/tmp`. You need to mount this to `/conda` which is actually a symlink to the correct location under the snakemake directory. +3. You need your `.gfa` and `.fastq` files, and a location for the output. In this example, I have a directory called `Sim_Phage`. You should mount this to `/phables`. An important point here is to add the `/` to the end of your directory name, but _not_ to the `/phables`, and then the `.gfa` and `reads` will be in the `/phables` directory. + +> **NOTE:** when you specify the paths, it is important that they are absolute paths (i.e. beginning with `$PWD` or `/`), as relative paths don't work. + + +## Create the `.sif` image + +The first step is to create the .sif image in a directory. + +Check [docker hub](https://hub.docker.com/r/linsalrob/phables) for the latest version. In this example, I'm using version 0.6 but it may have been updated after that. + +``` +IMAGE_DIR= +mkdir -p $IMAGE_DIR +singularity pull --dir $IMAGE_DIR docker://linsalrob/phables:v0.5_sneaky_sleeky +``` + +You can set `IMAGE_DIR` to any path you can write to. + + +## Run the container ``` -sudo docker run --volume=$PWD/Sim_Phage:/Sim_Phage --volume=$PWD/gurobi.lic:/opt/gurobi/gurobi.lic:ro phables phables run --input /Sim_Phage/assembly_graph_after_simplification.gfa --reads /Sim_Phage/reads/ +singularity exec --bind /tmp:/conda,$PWD/Sim_Phage/:/phables,$PWD/gurobi.lic:/opt/gurobi/gurobi.lic singularity/phables_0.6_gogo phables run --input /phables/assembly_graph_after_simplification.gfa --reads /phables/reads/ --output /phables/phables --threads 32 ``` -We are actively making this work. +# Running the container with docker + +The approach is very similar, except instead of the `--bind` you need to use `--volume`. Note that you will need to have root access for this to work. + +``` +docker pull linsalrob/phables:v0.6_gogo + +sudo docker run --volume=$PWD/Sim_Phage/:/phables --volume=/tmp:/conda --volume=$PWD/gurobi.lic:/opt/gurobi/gurobi.lic:ro phables phables run --input /phables/assembly_graph_after_simplification.gfa --reads /phables/reads/ --output /phables/phables --threads 32 +``` + + + +singularity exec --bind /scratch/pawsey1018/edwa0468/tmp:/opt/miniforge3/lib/python3.10/site-packages/phables/workflow/conda,$PWD/testy/Sim_Phage/:/phables,$PWD/gurobi.lic:/opt/gurobi/gurobi.lic testy/phables_v0.5_sneaky_sleeky.sif phables run --input /phables/assembly_graph_after_simplification.gfa --reads /phables/reads/ --output /phables/phables --threads 32 From 50029bd727319f87dab1ce344682a7d0bbe77caa Mon Sep 17 00:00:00 2001 From: Vijini Mallawaarachchi Date: Mon, 6 May 2024 09:23:18 +0930 Subject: [PATCH 4/4] DOC: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fbfb37..4e08696 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ For detailed instructions on installation and usage, please refer to the [**docu Phables is available on bioconda at [https://anaconda.org/bioconda/phables](https://anaconda.org/bioconda/phables) and on PyPI at [https://pypi.org/project/phables/](https://pypi.org/project/phables/). Feel free to pick your package manager, but we recommend that you use [`conda`](https://docs.conda.io/en/latest/). -**NEW:** Phables can now resolve bacteriophage genomes from long-read assemblies. +**NEW:** Phables is now available as a Docker container from [Docker hub](https://hub.docker.com/r/linsalrob/phables). Click [here](https://github.com/Vini2/phables/tree/develop/container) for more details. ## Setting up Phables