diff --git a/docker/Dockerfile b/docker/Dockerfile index cb10dcb845f4ddb1dc23d771018fb8cda2b9b05e..c3fa238362271d281a3416bac646b77ea1ea6be5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,28 @@ FROM ubuntu:16.04 +# ARGUMENTS +########### + +# OBLIGATORY +ARG OPENSTRUCTURE_VERSION +RUN if [ -z "${OPENSTRUCTURE_VERSION}" ]; then \ + echo "OPENSTRUCTURE_VERSION argument is obligatory. Run with --build-arg OPENSTRUCTURE_VERSION=<VERSION>"; \ + exit 1; \ + else : ; fi + +# OPTIONAL +ARG SRC_FOLDER="/usr/local/src" +ARG CPUS_FOR_MAKE=8 +ARG PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" +ARG OPENSTRUCTURE_SHARE="/usr/local/share/ost" +ARG MSMS_VERSION="2.6.1" +ARG OPENMM_VERSION="7.1.1" +ARG DSSP_VERSION="2.2.1" +ARG OPENMM_INCLUDE_PATH="/usr/local/openmm/include/" +ARG OPENMM_LIB_PATH="/usr/local/openmm/lib/" + +# INSTALL SYSTEM DEPS +##################### RUN apt-get update -y && apt-get install -y cmake \ sip-dev \ libtiff-dev \ @@ -17,97 +40,138 @@ RUN apt-get update -y && apt-get install -y cmake \ wget \ git \ gfortran \ - libeigen3-dev \ python-pip \ tar \ libbz2-dev \ doxygen \ swig \ - clustalw - - -# Install MSMS -WORKDIR / -RUN mkdir -p /msms -WORKDIR /msms -RUN wget http://mgltools.scripps.edu/downloads/tars/releases/MSMSRELEASE/REL2.6.1/msms_i86_64Linux2_2.6.1.tar.gz -RUN tar -xvzf msms_i86_64Linux2_2.6.1.tar.gz -RUN ln -s /msms/msms.x86_64Linux2.2.6.1 /usr/bin/msms -RUN ln -s /msms/pdb_to_xyzr /usr/bin/pdb_to_xyzr -RUN ln -s /msms/pdb_to_xyzrn /usr/bin/pdb_to_xyzrn - - -# Install OpenMM -WORKDIR / -RUN git clone https://github.com/pandegroup/openmm -WORKDIR /openmm -RUN git checkout -b 7.1.1 tags/7.1.1 -RUN cmake . -RUN make -j4 -RUN make install - -# Install DSSP -WORKDIR / -RUN wget ftp://ftp.cmbi.ru.nl/pub/software/dssp/dssp-2.2.1.tgz -RUN tar -xvzf dssp-2.2.1.tgz -WORKDIR /dssp-2.2.1 -RUN make -RUN ln -s /dssp-2.2.1/mkdssp /usr/bin/mkdssp - -# Install some python packages -WORKDIR / -RUN pip install --upgrade pip && pip install numpy==1.10.4 \ - scipy==1.0.0 \ - pandas==0.22.0 \ - jupyter==1.0.0 - + clustalw \ + python-virtualenv \ + locales && \ + # CLEANUP + rm -rf /var/lib/apt/lists/* +# INSTALL SOME PYTHON PACKAGES GLOBALY +###################################### +RUN pip install -U pip==9.0.3 && \ + pip install -U setuptools==39.0.1 && \ + pip install --no-cache-dir numpy==1.10.4 \ + scipy==1.0.0 \ + pandas==0.22.0 + +# SET LOCALE +############ +# RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment +# RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +# RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf +# RUN locale-gen en_US.UTF-8 + +# DOWNLOAD AND INSTALL MSMS +########################### +RUN cd ${SRC_FOLDER} && \ + mkdir -p msms && \ + cd ${SRC_FOLDER}/msms && \ + wget http://mgltools.scripps.edu/downloads/tars/releases/MSMSRELEASE/REL${MSMS_VERSION}/msms_i86_64Linux2_${MSMS_VERSION}.tar.gz && \ + tar -xvzf msms_i86_64Linux2_${MSMS_VERSION}.tar.gz && \ + cp -v ${SRC_FOLDER}/msms/msms.x86_64Linux2.${MSMS_VERSION} /usr/local/bin/msms && \ + cp -v ${SRC_FOLDER}/msms/pdb_to_xyzr /usr/local/bin/pdb_to_xyzr && \ + cp -v ${SRC_FOLDER}/msms/pdb_to_xyzrn /usr/local/bin/pdb_to_xyzrn && \ + rm -rf ${SRC_FOLDER}/msms + +# COMPILE OPENMM FROM SOURCES. INSTALL TO /usr/local +#################################################### +RUN cd ${SRC_FOLDER} && \ + wget -O openmm-${OPENMM_VERSION}.tar.gz -nc https://github.com/pandegroup/openmm/archive/${OPENMM_VERSION}.tar.gz && \ + mkdir ${SRC_FOLDER}/openmm-${OPENMM_VERSION} && \ + tar xf openmm-${OPENMM_VERSION}.tar.gz -C ${SRC_FOLDER}/openmm-${OPENMM_VERSION} --strip-components=1 && \ + mkdir -p ${SRC_FOLDER}/openmm-${OPENMM_VERSION}/build && \ + cd ${SRC_FOLDER}/openmm-${OPENMM_VERSION}/build && \ + cmake .. && make -j $CPUS_FOR_MAKE && make install && \ + cd ${SRC_FOLDER}/openmm-${OPENMM_VERSION}/build/python && \ + python setup.py build && python setup.py install && \ + rm -rf ${SRC_FOLDER}/openmm-${OPENMM_VERSION}.tar.gz && \ + rm -rf ${SRC_FOLDER}/openmm-${OPENMM_VERSION} + + +# COMPILE AND INSTALL DSSP +########################## +RUN cd ${SRC_FOLDER} && \ + wget ftp://ftp.cmbi.ru.nl/pub/software/dssp/dssp-${DSSP_VERSION}.tgz && \ + tar -xvzf dssp-${DSSP_VERSION}.tgz && \ + cd dssp-${DSSP_VERSION} && \ + make -j ${CPUS_FOR_MAKE} && \ + make install && \ + rm -rf ${SRC_FOLDER}/dssp-${DSSP_VERSION}.tgz && \ + rm -rf ${SRC_FOLDER}/dssp-${DSSP_VERSION} + +# INSTALL OST +############# +RUN cd ${SRC_FOLDER} && \ # copy ost release -WORKDIR /opt/ost - -RUN git clone https://git.scicore.unibas.ch/schwede/openstructure.git /opt/ost && git checkout -b develop origin/develop - -# compile ost -RUN cmake . -DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython2.7.so \ - -DOPTIMIZE=ON \ - -DENABLE_MM=ON \ - -DCOMPILE_TMTOOLS=1 \ - -DUSE_NUMPY=1 \ - -DOPEN_MM_LIBRARY=/usr/local/openmm/lib/libOpenMM.so \ - -DOPEN_MM_INCLUDE_DIR=/usr/local/openmm/include \ - -DOPEN_MM_PLUGIN_DIR=/usr/local/openmm/lib/plugins - -# Build chemdict_tool -RUN make -j4 chemdict_tool + wget -O openstructure-${OPENSTRUCTURE_VERSION}.tar.gz -nc https://git.scicore.unibas.ch/schwede/openstructure/repository/${OPENSTRUCTURE_VERSION}/archive.tar.gz && \ + mkdir openstructure-${OPENSTRUCTURE_VERSION} && \ + tar xf openstructure-${OPENSTRUCTURE_VERSION}.tar.gz -C ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION} --strip-components=1 && \ + mkdir -p ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build +WORKDIR ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build + +# cmake ost +RUN cmake .. -DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython2.7.so \ + -DOPTIMIZE=ON \ + -DENABLE_MM=ON \ + -DCOMPILE_TMTOOLS=1 \ + -DUSE_NUMPY=1 \ + -DOPEN_MM_LIBRARY=$OPENMM_LIB_PATH/libOpenMM.so \ + -DOPEN_MM_INCLUDE_DIR=$OPENMM_INCLUDE_PATH \ + -DOPEN_MM_PLUGIN_DIR=$OPENMM_LIB_PATH/plugins \ + -DENABLE_GFX=ON \ + -DENABLE_GUI=ON && \ + # Build chemdict_tool + make -j ${CPUS_FOR_MAKE} chemdict_tool # get the compound library RUN wget ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz -RUN stage/bin/chemdict_tool create components.cif.gz compounds.chemlib pdb -RUN stage/bin/chemdict_tool update modules/conop/data/charmm.cif compounds.chemlib charmm - -# Reconfigure OST -RUN cmake . -DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython2.7.so \ - -DOPTIMIZE=ON \ - -DENABLE_MM=ON \ - -DOPEN_MM_LIBRARY=/usr/local/openmm/lib/libOpenMM.so \ - -DOPEN_MM_INCLUDE_DIR=/usr/local/openmm/include \ - -DOPEN_MM_PLUGIN_DIR=/usr/local/openmm/lib/plugins \ - -DCOMPOUND_LIB=/opt/ost/compounds.chemlib - -# Build OST -RUN make -j4 -RUN make check - -# go back home +RUN stage/bin/chemdict_tool create components.cif.gz compounds.chemlib pdb && stage/bin/chemdict_tool update modules/conop/data/charmm.cif compounds.chemlib charmm +RUN mkdir -p $OPENSTRUCTURE_SHARE && chmod a+rw -R $OPENSTRUCTURE_SHARE && mv compounds.chemlib $OPENSTRUCTURE_SHARE + +# Build and install OST +RUN cmake .. -DPYTHON_LIBRARIES=/usr/lib/x86_64-linux-gnu/libpython2.7.so \ + -DOPTIMIZE=ON \ + -DENABLE_MM=ON \ + -DCOMPILE_TMTOOLS=1 \ + -DUSE_NUMPY=1 \ + -DOPEN_MM_LIBRARY=$OPENMM_LIB_PATH/libOpenMM.so \ + -DOPEN_MM_INCLUDE_DIR=$OPENMM_INCLUDE_PATH \ + -DOPEN_MM_PLUGIN_DIR=$OPENMM_LIB_PATH/plugins \ + -DENABLE_GFX=ON \ + -DENABLE_GUI=ON \ + -DCOMPOUND_LIB=$OPENSTRUCTURE_SHARE/compounds.chemlib && \ + # Build OST with compound library + make -j ${CPUS_FOR_MAKE} && make check && make install + +# GO HOME AND CLEANUP +##################### +# RUN apt-get purge -y cmake \ +# wget \ +# git \ +# gfortran \ +# python-pip \ +# libbz2-dev \ +# doxygen \ +# swig +# RUN apt-get clean +# RUN apt-get autoremove -y +# +# WORKDIR $SRC_FOLDER +# RUN rm -rf $SRC_FOLDER/* + WORKDIR /home -# Set the environment -# - for GUI -ENV QT_X11_NO_MITSHM 1 -# - for Python -ENV PYTHONPATH="/opt/ost/stage/lib64/python2.7/site-packages:${PYTHONPATH}" -# - for PATH -ENV PATH="/opt/ost/stage/bin:${PATH}" +# ENVIRONMENT +############################################################################## +ENV OST_ROOT="/usr/local" +ENV OPENSTRUCTURE_VERSION="1.7.1" +ENV PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" +ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64" +ENV QT_X11_NO_MITSHM=1 ENTRYPOINT ["ost"] CMD ["-i"] - diff --git a/docker/README.rst b/docker/README.rst index 3bd25884aa85561a2b185a7ea8f4294ac88a68a9..4700eb156cad0663893a957ff0eb42aafbffac7e 100644 --- a/docker/README.rst +++ b/docker/README.rst @@ -9,27 +9,44 @@ OST Docker Build Docker image ------------------ + In order to build OST image: .. code-block:: bash - cd <OST ROOT>/docker - docker build --tag <TAG> . + cd <PATH TO OST>/docker + docker build --tag <IMAGE NAME> --build-arg OPENSTRUCTURE_VERSION=<VERSION> -f Dockerfile . -One can chose any tag eg. ost. +or if you downloaded the Dockerfile directly: -Run script with OST -------------------- +.. code-block:: bash -In order to run OST script do: + docker build --tag <IMAGE NAME> --build-arg OPENSTRUCTURE_VERSION=<VERSION> -f <DOCKERFILE NAME> <PATH TO DOCKERFILE DIR> -.. code-block:: bash +You can chose any image name (tag) eg. ost. The `OPENSTRUCTURE_VERSION` +build argument is mandatory and image will not built without it. See +`CHANGELOG <https://git.scicore.unibas.ch/schwede/openstructure/blob/master/CHANGELOG.txt>`_ +for current list of available releases. - docker run [DOCKER OPTIONS] --rm -v <PATH TO SCRIPT DIR>:/home <IMAGE NAME> /home/<SCRIPT NAME> [SCRIPT OPTIONS] +Testing the image +----------------- + +One can find a exemplary script (`test_docker.py`) in the downloaded directory. +To run it do: + +.. code-block:: + + cd <PATH TO OST>/docker + docker run --rm -v $(pwd):/home <IMAGE NAME> test_docker.py -.. warning:: +As the last line you should see `OST is working!`. - If script requires some external files eg. PDBs, they have to be located in the +Run script and action with OST +------------------------------ + +.. note:: + + If script or action requires some external files eg. PDBs, they have to be located in the path accessible via mounted volume and should be accessed via docker (NOT LOCAL) path. Eg. assuming that we have a struc.pdb file in /home/user/pdbs directory and a script.py in /home/user we could mount the /home/user to /home in docker as @@ -45,39 +62,95 @@ In order to run OST script do: .. code-block:: bash docker run --rm -v /home/user:/home <IMAGE NAME> home/script.py /home/pdbs/struct.pdb + + An easy solution to mount a CWD is to use $(pwd) command in the -v option + of the Docker. For an example see the action exemplary run. + The same reasoning is valid for the output files. + +Actions +####### + +To see the list of available actions do: + + .. code-block:: + + docker run --rm <IMAGE NAME> -h + +To run chosen action do: -One can find a exemplary script (`test_docker.py`) in the <OST ROOT>/docker -directory. To run it do: + .. code-block:: + + docker run --rm <IMAGE NAME> <ACTION NAME> + + +Here is an example run of compare-structures action mimicking CAMEO evaluation: + +.. code-block:: + + docker run --rm -v $(pwd):/home <IMAGE NAME> compare-structures \ + --model model.pdb \ + --reference reference.pdb \ + --output output.json \ + --qs-score \ + --residue-number-alignment \ + --lddt \ + --structural-checks \ + --consistency-checks \ + --inclusion-radius 15.0 \ + --bond-tolerance 15.0 \ + --angle-tolerance 15.0 \ + --molck \ + --remove oxt hyd unk \ + --clean-element-column \ + --map-nonstandard-residues + + +In order to see all available options for this action run: .. code-block:: - cd <OST ROOT>/docker - docker run --rm -v <OST ROOT>/docker:/home <IMAGE NAME> test_docker.py + docker run --rm <IMAGE NAME> compare-structures -h + +Scripts +####### + +In order to run OST script do: + +.. code-block:: bash + + docker run [DOCKER OPTIONS] --rm -v <PATH TO SCRIPT DIR>:/home <IMAGE NAME> /home/<SCRIPT NAME> [SCRIPT OPTIONS] -Run script with utility command +Run ost with utility command ############################### One can also use provided utility bash script `run_docker_ost` to run basic -scripts: +scripts and actions: .. code-block:: bash - <OST ROOT>/docker/run_docker_ost <IMAGE_NAME> [<SCRIPT_PATH>] [SCRIPT OPTIONS] + <PATH TO OST>/docker/run_docker_ost <IMAGE_NAME> [<SCRIPT_PATH>] [SCRIPT OPTIONS] -One just needs to provide image name and optionally a script and its options. It -is useful to link the command to the binary directory eg. in linux: +One just needs to provide image name and optionally a script/action and its +options. It is useful to link the command to the binary directory eg. in linux: .. code-block:: bash - ln -s <OST ROOT>/docker/run_docker_ost /usr/bin/run_docker_ost + ln -s <PATH TO OST>/docker/run_docker_ost /usr/bin/run_docker_ost In order to run an exemplary script (`test_docker.py`) do: .. code-block:: - cd <OST ROOT>/docker + cd <PATH TO OST>/docker ./run_docker_ost <IMAGE NAME> test_docker.py +To see the help for compare-structures action run: + +.. code-block:: + + cd <PATH TO OST>/docker + ./run_docker_ost <IMAGE NAME> compare-structures + Run GUI ------- diff --git a/docker/run_docker_ost b/docker/run_docker_ost index f7d14df286fd1970137b42f24d48fcc1cbd09ec3..9930329a2a6b6d8f0ebf381287c2c38deda8925d 100755 --- a/docker/run_docker_ost +++ b/docker/run_docker_ost @@ -12,12 +12,17 @@ if [[ ${#@} -lt 1 ]]; then fi if [[ -z ${script_path} ]]; then - docker run -ti --rm ${image_name} + docker run -ti --rm -v $(pwd):/home ${image_name} else - abspath=$(readlink -f $script_path) - dirpath=$(dirname $abspath) - name=$(basename $script_path) - docker run --rm -v ${dirpath}:/home ${image_name} /home/${name} ${@:3} + if [[ -e $script_path ]]; then + abspath=$(readlink -f $script_path) + dirpath=$(dirname $abspath) + name=$(basename $script_path) + docker run --rm -v ${dirpath}:/home ${image_name} /home/${name} ${@:3} + else + # it is maybe an action if it does not exist + docker run --rm -v $(pwd):/home ${image_name} ${script_path} ${@:3} + fi fi