diff --git a/singularity/README.rst b/singularity/README.rst new file mode 100644 index 0000000000000000000000000000000000000000..fa56b8aa6b4a637d6542f7074c00d1171f953486 --- /dev/null +++ b/singularity/README.rst @@ -0,0 +1,46 @@ +OST Singularity +=============== + +.. note:: + + In order to run some singularity commands there might be a need to run them as root (sudo). + +Build Singularity image +------------------ + +In order to build OST Singularity image: + +.. code-block:: bash + + cd <OST ROOT>/singularity + singularity build ost.img Singularity.1.7.1 + +One can chose any name for an image. For the purose of this file we will assume +that the image name is `ost.img`. + +Run script using OST +-------------------- + +In order to run OST script do: + +.. code-block:: bash + singularity run --app OST ost.img <SCRIPT NAME> [SCRIPT OPTIONS] + +.. warning:: + + If script requires some external files eg. PDBs, they have to be located in the + path accessible via mounted volume. By default Singularity mounts $HOME and + goes to CWD. Thus this sould work as expected. + +One can find a exemplary script (`test_docker.py`) in the <OST ROOT>/docker +directory. To run it do: + +.. code-block:: + + cd <OST ROOT>/singularity + singularity run --app OST ost.img ../docker/test_docker.py + +Available apps +-------------- + +TODO diff --git a/singularity/Singularity.1.7.1 b/singularity/Singularity.1.7.1 new file mode 100644 index 0000000000000000000000000000000000000000..7924c4a21237e88ea6b43244a47ec70de8e170a3 --- /dev/null +++ b/singularity/Singularity.1.7.1 @@ -0,0 +1,267 @@ +BootStrap: docker +From: ubuntu:16.04 + +%post +############################################################################## +# POST +############################################################################## + +# CHANGE DASH TO BASH +rm /bin/sh +ln -sf /bin/bash /bin/sh + +# DEFINE SOME ENV VARS USED DURING THE IMAGE BUILD +########################## +export SRC_FOLDER="/usr/local/src" +export CPUS_FOR_MAKE=8 +export PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" +export OPENSTRUCTURE_VERSION="1.7.1" +export OPENSTRUCTURE_SHARE="/usr/local/share/ost" +export MSMS_VERSION="2.6.1" +export OPENMM_VERSION="7.1.1" +export DSSP_VERSION="2.2.1" +export OPENMM_INCLUDE_PATH=/usr/local/openmm/include/ +export OPENMM_LIB_PATH=/usr/local/openmm/lib/ +export JUPYTER_CONFIG_DIR="/usr/local/etc/jupyter" +export JUPYTER_PATH="/usr/local/share/jupyter" +export JUPYTER_RUNTIME_DIR="$JUPYTER_PATH/runtime" +export VIRTUALENV_DIR="/usr/local/share/ost_venv" + + +# INSTALL SYSTEM DEPS +##################### +apt-get update -y && apt-get install -y cmake \ + sip-dev \ + libtiff-dev \ + libfftw3-dev \ + libeigen3-dev \ + libboost-all-dev \ + libpng-dev \ + python-all \ + python2.7 \ + python-qt4 \ + qt4-qtconfig \ + qt4-qmake \ + libqt4-dev \ + libpng-dev \ + wget \ + git \ + gfortran \ + python-pip \ + tar \ + libbz2-dev \ + doxygen \ + swig \ + clustalw \ + python-virtualenv + +# SET UP VIRTUALENV +################### +virtualenv --system-site-packages $VIRTUALENV_DIR +. $VIRTUALENV_DIR/bin/activate + + +# INSTALL REQUIRED PYTHON PACKAGES +################################## +pip install --upgrade pip && pip install numpy==1.10.4 \ + scipy==1.0.0 \ + pandas==0.22.0 \ + jupyter==1.0.0 \ + nglview==1.0 + +# DOWNLOAD AND INSTALL MSMS +############## +cd ${SRC_FOLDER} +if [ ! -f msms_i86_64Linux2_${MSMS_VERSION}.tar.gz ]; then + mkdir -p msms + cd 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 +fi + +# COMPILE OPENMM FROM SOURCES. INSTALL TO /usr/local +############################ +cd ${SRC_FOLDER} +if [ ! -f openmm-${OPENMM_VERSION}.tar.gz ]; then + 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 +fi + +# COMPILE AND INSTALL DSSP +############## +cd ${SRC_FOLDER} +if [ ! -f dssp-${DSSP_VERSION}.tgz ]; then + 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 +fi + +# INSTALL OST +############# + +cd ${SRC_FOLDER} +if [ ! -f openstructure-${OPENSTRUCTURE_VERSION}.tar.gz ]; then + # copy ost release + 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 && cd ${SRC_FOLDER}/openstructure-${OPENSTRUCTURE_VERSION}/build + + # cmake ost + 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 + wget ftp://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif.gz + stage/bin/chemdict_tool create components.cif.gz compounds.chemlib pdb + stage/bin/chemdict_tool update modules/conop/data/charmm.cif compounds.chemlib charmm + mkdir -p $OPENSTRUCTURE_SHARE + chmod a+rw -R $OPENSTRUCTURE_SHARE + mv compounds.chemlib $OPENSTRUCTURE_SHARE + + # Build and install OST + 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 chemdict_tool + make -j ${CPUS_FOR_MAKE} + make check + make install +fi + +# SETUP JUPYTER +############### +mkdir -p /usr/local/share/ipython +mkdir -p $JUPYTER_PATH +mkdir -p $JUPYTER_RUNTIME_DIR +mkdir -p $JUPYTER_CONFIG_DIR +mkdir -p $JUPYTER_PATH/kernels/ost-kernel +chmod a+rw -R /usr/local/share/ipython +chmod a+rw -R $JUPYTER_PATH +chmod a+rw -R $JUPYTER_CONFIG_DIR +chmod a+rw -R $JUPYTER_RUNTIME_DIR +cat > $JUPYTER_PATH/kernels/ost-kernel/kernel.json <<EOF +{ + "display_name": "OST", + "language": "python", + "argv": [ + "python", + "-m", "ipykernel", + "-f", "{connection_file}", + "--InteractiveShellApp.exec_PYTHONSTARTUP=False", + "--InteractiveShellApp.exec_files=['/usr/local/lib64/python2.7/site-packages/ost/ost_startup.py']" + ], + "env": { + } +} +EOF + +jupyter nbextension enable nglview --py --sys-prefix + +# GO HOME +######### + +cd /home + +%environment +############################################################################## +# ENVIRONMENT +############################################################################## +export OST_ROOT="/usr/local" +export PYTHONPATH="/usr/local/lib64/python2.7/site-packages:${PYTHONPATH}" +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64" +export QT_X11_NO_MITSHM=1 +export IPYTHONDIR="/usr/local/share/ipython" +export JUPYTER_CONFIG_DIR="/usr/local/etc/jupyter" +export JUPYTER_PATH="/usr/local/share/jupyter" +export JUPYTER_RUNTIME_DIR="$JUPYTER_PATH/runtime" +export VIRTUALENV_DIR="/usr/local/share/ost_venv" + +%apprun ChemdictTool +############################################################################## +# CHEMDICT TOOL APP +############################################################################## +. $VIRTUALENV_DIR/bin/activate && $OST_ROOT/bin/chemdict_tool "$@" + +%apprun lDDT +############################################################################## +# lDDT APP +############################################################################## +. $VIRTUALENV_DIR/bin/activate && $OST_ROOT/bin/lddt "$@" + +%apprun Molck +############################################################################## +# MOLCK APP +############################################################################## +. $VIRTUALENV_DIR/bin/activate && $OST_ROOT/bin/molck "$@" + +%apprun OST +############################################################################## +# OST APP +############################################################################## +$OST_ROOT/bin/ost "$@" + +%appenv Notebook +############################################################################## +# NOTEBOOK ENV +############################################################################## +export BIN_DIR=$OST_ROOT/bin +export XDG_RUNTIME_DIR="" +. $OST_ROOT/libexec/openstructure/ost_config + +%apprun Notebook +############################################################################## +# NOTEBOOK APP +############################################################################## +. $VIRTUALENV_DIR/bin/activate && jupyter notebook --NotebookApp.iopub_data_rate_limit=10000000 --no-browser "$@" + +%runscript +############################################################################## +# RUNSCRIPT +############################################################################## +cat << EOF +Singularity container for OST $OPENSTRUCTURE_VERSION. + +This container includes the following apps: + * OST - OpenStructure binary + * lDDT - The Local Distance Difference Test + * Molck - Molecular checker + * Notebook - A Jupyter notebook palyground with OST and nglview + +To see the help for each individual app run: + + $ singularity run --app APP + + +EOF + +