From cb5f3e90d00888b64549b579399326e4563c3442 Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Tue, 14 Jul 2026 17:32:41 -0500 Subject: [PATCH 1/7] Added dockerfile setup. --- .dockerignore | 4 +++ Dockerfile | 67 +++++++++++++++++++++++++++++++++++++++++ strvctvre_entrypoint.sh | 31 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 strvctvre_entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8946e6b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +images +.gitignore +LICENSE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..98d7b37 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +FROM mambaorg/micromamba:ubuntu24.04 AS micromamba + +FROM ubuntu:24.04 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + wget \ + curl \ + ca-certificates \ + && apt-get clean autoclean \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* \ + && rm -f /var/cache/apt/archives/*.deb + +############################################################# +######################### General ########################### +############################################################# +RUN mkdir -p /software; chmod a+rwx -R /software; mkdir /software/strvctvre + +WORKDIR /software/strvctvre + +COPY . . + +# Update CERTs if on VPN +# RUN wget -P /tmp/ +# ARG CURL_CA_BUNDLE=/tmp/ + +# Install micromamba first +# Adding micromamba to existing image: https://micromamba-docker.readthedocs.io/en/latest/advanced_usage.html#adding-micromamba-to-an-existing-docker-image +# https://github.com/mamba-org/micromamba-docker/blob/main/debian.Dockerfile + +# if your image defaults to a non-root user, then you may want to make the +# next 3 ARG commands match the values in your image. You can get the values +# by running: docker run --rm -it my/image id -a +ARG MAMBA_USER=root +ARG MAMBA_USER_ID=0 +ARG MAMBA_USER_GID=0 +ENV MAMBA_USER=$MAMBA_USER +ENV MAMBA_ROOT_PREFIX="/software/conda" +ENV MAMBA_EXE="/bin/micromamba" +## conda env name (must match `name:` in environment_py3.yml) +ENV ENV_NAME=StrVCTVRE_py_3 +#ENV MAMBA_SKIP_ACTIVATE=1; We want to activate, but just not the base + +COPY --from=micromamba "$MAMBA_EXE" "$MAMBA_EXE" +COPY --from=micromamba /usr/local/bin/_activate_current_env.sh /usr/local/bin/_activate_current_env.sh +COPY --from=micromamba /usr/local/bin/_dockerfile_shell.sh /usr/local/bin/_dockerfile_shell.sh +COPY --from=micromamba /usr/local/bin/_entrypoint.sh /usr/local/bin/_entrypoint.sh +COPY --from=micromamba /usr/local/bin/_dockerfile_initialize_user_accounts.sh /usr/local/bin/_dockerfile_initialize_user_accounts.sh +COPY --from=micromamba /usr/local/bin/_dockerfile_setup_root_prefix.sh /usr/local/bin/_dockerfile_setup_root_prefix.sh + +RUN /usr/local/bin/_dockerfile_initialize_user_accounts.sh && \ + /usr/local/bin/_dockerfile_setup_root_prefix.sh + +RUN --mount=type=cache,target=/software/conda/pkgs \ + micromamba create -y -f /software/strvctvre/environment_py3.yml && \ + micromamba clean --all --yes + +############################################################# +############################################################# +############################################################# + +ENV PATH=/software/strvctvre:/software:$PATH + +RUN chmod +x /software/strvctvre/strvctvre_entrypoint.sh + +ENTRYPOINT ["/software/strvctvre/strvctvre_entrypoint.sh"] \ No newline at end of file diff --git a/strvctvre_entrypoint.sh b/strvctvre_entrypoint.sh new file mode 100755 index 0000000..6587dd0 --- /dev/null +++ b/strvctvre_entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# StrVCTVRE container entrypoint. +# Activates the conda environment, then warns if the required phyloP +# conservation file is missing (it is ~9.2GB and is NOT baked into the image). + +IGreen='\033[0;92m' # Green +On_Red='\033[41m' # Red +Color_Off='\033[0m' # Text Reset + +# Path StrVCTVRE.py checks by default; override at runtime with -p. +PHYLOP_FILE="${PHYLOP_FILE:-/software/strvctvre/data/hg38.phyloP100way.bw}" + +# env setup +source /usr/local/bin/_activate_current_env.sh + +if [ ! -s "${PHYLOP_FILE}" ]; then + echo -e "${IGreen}The phyloP conservation file was not found at:\n ${PHYLOP_FILE}${Color_Off}" + echo -e "${IGreen}StrVCTVRE requires hg38.phyloP100way.bw (~9.2GB). Download it from UCSC:${Color_Off}" + echo -e "${IGreen} https://hgdownload.cse.ucsc.edu/goldenpath/hg38/phyloP100way/hg38.phyloP100way.bw${Color_Off}" + echo -e "${On_Red}\tMount it into the container (e.g. -v /host/data:/software/strvctvre/data)${Color_Off}" + echo -e "${On_Red}\tor pass its path to StrVCTVRE.py with -p.${Color_Off}" +fi + +# Run whatever command was passed to the container (e.g. python StrVCTVRE.py ...), +# or drop into an interactive shell if none was given. +if [ "$#" -gt 0 ]; then + exec "$@" +else + exec /bin/bash +fi From 037acc4ba45017b14cb01229d7993f7df0824f08 Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Tue, 14 Jul 2026 17:35:40 -0500 Subject: [PATCH 2/7] Added Docker section to README. --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 106498c..2cb8705 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,23 @@ Structural variant impact predictor developed by Andrew Sharo, Zhiqiang Hu, and ### \*\*New\*\*: Visit our [Web Server](https://strvctvre.berkeley.edu) to annotate vcf or bed files with StrVCTVRE scores, or query a single SV +## Run with Docker (optional) + +A `Dockerfile` is provided as an alternative to installing Python, conda, and the required packages manually (i.e. it replaces steps 1–4 below). From the cloned repository, build the image with: +``` +docker build --platform linux/amd64 -t strvctvre:v1.10 . +``` +The `--platform linux/amd64` flag is required, including on Apple Silicon / ARM machines, where it builds under emulation. + +The image does **not** include the 9.2GB `hg38.phyloP100way.bw` file (see step 3). Download it separately and mount the folder containing it (and a folder for your input/output) into the container. For example, to annotate a vcf file: +``` +docker run --rm --platform linux/amd64 \ + -v /path/to/phylop/folder:/software/strvctvre/data \ + -v /path/to/your/files:/io \ + strvctvre:v1.10 python StrVCTVRE.py -i /io/input.vcf -o /io/output.vcf +``` +GRCh37 input additionally requires a LiftOver executable (see steps 6 and 8); mount it into the container and pass its path with `-a GRCh37 -l /path/to/liftOver`. + ## To run StrVCTVRE, follow these steps: ### 1. Download and install Python 3 (if not done already) From d37fc17a7df0dd53a86f489f19e1318a70961b9f Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Mon, 20 Jul 2026 13:57:55 -0500 Subject: [PATCH 3/7] Updated .dockerignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 8946e6b..62a5f8f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ images .gitignore LICENSE +hg38.phyloP100way.bw \ No newline at end of file From e9e446356600aa4debf225349be9352497660fe8 Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Mon, 20 Jul 2026 13:58:23 -0500 Subject: [PATCH 4/7] Added pyproject.toml to create a console script for the Dockerfile. --- pyproject.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..18b251c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "StrVCTVRE" +version = "0.1.0" +dependencies = [] # your dependencies here + +[project.scripts] +StrVCTVRE = "StrVCTVRE:main" \ No newline at end of file From 31696d9983cf45f45eb05d60cc942ee604e84bfb Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Mon, 20 Jul 2026 13:58:53 -0500 Subject: [PATCH 5/7] Updated the entrypoint script. --- strvctvre_entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/strvctvre_entrypoint.sh b/strvctvre_entrypoint.sh index 6587dd0..b6a328a 100755 --- a/strvctvre_entrypoint.sh +++ b/strvctvre_entrypoint.sh @@ -9,22 +9,20 @@ On_Red='\033[41m' # Red Color_Off='\033[0m' # Text Reset # Path StrVCTVRE.py checks by default; override at runtime with -p. -PHYLOP_FILE="${PHYLOP_FILE:-/software/strvctvre/data/hg38.phyloP100way.bw}" - -# env setup -source /usr/local/bin/_activate_current_env.sh +PHYLOP_FILE="${PHYLOP_FILE:-data/hg38.phyloP100way.bw}" if [ ! -s "${PHYLOP_FILE}" ]; then echo -e "${IGreen}The phyloP conservation file was not found at:\n ${PHYLOP_FILE}${Color_Off}" echo -e "${IGreen}StrVCTVRE requires hg38.phyloP100way.bw (~9.2GB). Download it from UCSC:${Color_Off}" echo -e "${IGreen} https://hgdownload.cse.ucsc.edu/goldenpath/hg38/phyloP100way/hg38.phyloP100way.bw${Color_Off}" - echo -e "${On_Red}\tMount it into the container (e.g. -v /host/data:/software/strvctvre/data)${Color_Off}" + echo -e "${On_Red}\tMount it into the container (e.g. docker: -v /host/data; apptainer: --bind /host/data)${Color_Off}" echo -e "${On_Red}\tor pass its path to StrVCTVRE.py with -p.${Color_Off}" fi # Run whatever command was passed to the container (e.g. python StrVCTVRE.py ...), # or drop into an interactive shell if none was given. if [ "$#" -gt 0 ]; then + source /usr/local/bin/_activate_current_env.sh exec "$@" else exec /bin/bash From 1812b05b874eea880037defe81e88758c2640b7f Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Mon, 20 Jul 2026 13:59:40 -0500 Subject: [PATCH 6/7] Updated the Dockerfile. --- Dockerfile | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 98d7b37..2297dd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +# This Dockerfile builds a container image for StrVCTVRE, a tool for structural variant classification. +# It uses micromamba to manage dependencies and sets up the environment for running StrVCTVRE. +# It's also been built for use with Docker and Apptainer, so it can be run on HPC clusters. FROM mambaorg/micromamba:ubuntu24.04 AS micromamba FROM ubuntu:24.04 @@ -21,7 +24,18 @@ WORKDIR /software/strvctvre COPY . . -# Update CERTs if on VPN +# The console script (`StrVCTVRE = "StrVCTVRE:main"`) imports `main` from the +# module, but the committed StrVCTVRE.py runs argparse + all logic at module +# level and defines no `main()`. Wrap the entire script in `def main():` and add +# a `__main__` guard, in-place in the image so the repo source stays untouched. +RUN awk '\ +BEGIN { print "def main():" } \ +{ if ($0 ~ /^[[:space:]]*$/) print $0; else print " " $0 } \ +END { print ""; print "if __name__ == \"__main__\":"; print " main()" } \ +' /software/strvctvre/StrVCTVRE.py > /tmp/StrVCTVRE.py \ + && mv /tmp/StrVCTVRE.py /software/strvctvre/StrVCTVRE.py + +# Update CERTs if building on VPN # RUN wget -P /tmp/ # ARG CURL_CA_BUNDLE=/tmp/ @@ -56,12 +70,32 @@ RUN --mount=type=cache,target=/software/conda/pkgs \ micromamba create -y -f /software/strvctvre/environment_py3.yml && \ micromamba clean --all --yes +# Install StrVCTVRE in editable mode so that it's available as a console script (e.g. `StrVCTVRE --help` vs `python StrVCTVRE.py --help`) +RUN --mount=type=cache,target=/software/conda/pkgs \ + micromamba run -n $ENV_NAME pip --trusted-host pypi.org --trusted-host files.pythonhosted.org install -e . + +WORKDIR /software/ ############################################################# ############################################################# ############################################################# +# Add the micromamba activation script to the system-wide bashrc so that the environment is activated for all users on run/exec for apptainer and docker. +RUN echo "source /usr/local/bin/_activate_current_env.sh" >> /etc/bash.bashrc && \ + echo "source /usr/local/bin/_activate_current_env.sh" >> .bash_env && \ + echo "source /etc/bash.bashrc" >> .bash_env -ENV PATH=/software/strvctvre:/software:$PATH +# any calls to bash will load this environment (e.g. docker/apptainer exec bash -c "cmd") +ENV BASH_ENV=/software/.bash_env RUN chmod +x /software/strvctvre/strvctvre_entrypoint.sh -ENTRYPOINT ["/software/strvctvre/strvctvre_entrypoint.sh"] \ No newline at end of file +ENV PATH=/software/strvctvre:/software:$PATH + +# The `pip install -e .` above installs the `StrVCTVRE` console script, but +# setuptools flat-layout auto-discovery picks up the `data/` dir as the package +# instead of the top-level StrVCTVRE.py module, so `from StrVCTVRE import main` +# fails at runtime. Put the repo on PYTHONPATH so the module is importable. +ENV PYTHONPATH=/software/strvctvre + +ENTRYPOINT ["/software/strvctvre/strvctvre_entrypoint.sh"] + +CMD ["/bin/bash"] \ No newline at end of file From 79ac729f1ab9d1b0f29877accbcb3106582e83aa Mon Sep 17 00:00:00 2001 From: Robert Gilmore Date: Mon, 20 Jul 2026 14:54:09 -0500 Subject: [PATCH 7/7] Updated the Dockerfile and README. --- .dockerignore | 2 +- Dockerfile | 1 + README.md | 23 ++++++++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 62a5f8f..f093e9e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,4 @@ images .gitignore LICENSE -hg38.phyloP100way.bw \ No newline at end of file +data/hg38.phyloP100way.bw \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2297dd3..7d87985 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,6 +90,7 @@ RUN chmod +x /software/strvctvre/strvctvre_entrypoint.sh ENV PATH=/software/strvctvre:/software:$PATH +WORKDIR /software/strvctvre # The `pip install -e .` above installs the `StrVCTVRE` console script, but # setuptools flat-layout auto-discovery picks up the `data/` dir as the package # instead of the top-level StrVCTVRE.py module, so `from StrVCTVRE import main` diff --git a/README.md b/README.md index 2cb8705..bfc0ed5 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,32 @@ Structural variant impact predictor developed by Andrew Sharo, Zhiqiang Hu, and ## Run with Docker (optional) A `Dockerfile` is provided as an alternative to installing Python, conda, and the required packages manually (i.e. it replaces steps 1–4 below). From the cloned repository, build the image with: -``` +```bash +git clone --depth 1 https://github.com/andrewSharo/StrVCTVRE +cd StrVCTVRE docker build --platform linux/amd64 -t strvctvre:v1.10 . ``` +This docker image creates a console script that can be run with the command `StrVCTVRE`. + The `--platform linux/amd64` flag is required, including on Apple Silicon / ARM machines, where it builds under emulation. The image does **not** include the 9.2GB `hg38.phyloP100way.bw` file (see step 3). Download it separately and mount the folder containing it (and a folder for your input/output) into the container. For example, to annotate a vcf file: -``` +```bash +cd data +wget http://hgdownload.cse.ucsc.edu/goldenpath/hg38/phyloP100way/hg38.phyloP100way.bw +cd .. + +# Try the test data docker run --rm --platform linux/amd64 \ - -v /path/to/phylop/folder:/software/strvctvre/data \ + -v $(pwd)/data:/software/strvctvre/data \ -v /path/to/your/files:/io \ - strvctvre:v1.10 python StrVCTVRE.py -i /io/input.vcf -o /io/output.vcf + strvctvre:v1.10 StrVCTVRE -i data/test.vcf.gz -o /io/output.vcf ``` -GRCh37 input additionally requires a LiftOver executable (see steps 6 and 8); mount it into the container and pass its path with `-a GRCh37 -l /path/to/liftOver`. + +## Run with apptainer/snakemake (optional) +Snakemake runs apptainer exec mode. By default apptainer will mount the current working directory and use it as in the container +as the current working directory. This means that you should have the data folder system linked in snakemake's working directory +for the StrVCTVRE console script (or StrVCTVRE.py) to find the hg38.phyloP100way.bw file. ## To run StrVCTVRE, follow these steps: