Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
images
.gitignore
LICENSE
data/hg38.phyloP100way.bw
102 changes: 102 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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

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 . .

# 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/ <cert_url>
# ARG CURL_CA_BUNDLE=/tmp/<cert_file>

# 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

# 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

# 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

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`
# 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"]
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@ 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:
```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 $(pwd)/data:/software/strvctvre/data \
-v /path/to/your/files:/io \
strvctvre:v1.10 StrVCTVRE -i data/test.vcf.gz -o /io/output.vcf
```

## 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:

### 1. Download and install Python 3 (if not done already)
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
29 changes: 29 additions & 0 deletions strvctvre_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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:-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. 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
fi