Skip to content
Snippets Groups Projects
Gabriel Studer's avatar
Studer Gabriel authored
This commit doesn't make OpenStructure work with Python 3. The goal of this
commit was to perform an automated port of the Python code and make it compile.
The performed steps:

- Edited CMakeLists.txt to search for Python with 3.6 as min version 3.6 is the
  Python version shipped by default with Ubuntu 18.04 LTS
- Add version 3.6 to cmake_support/FindPython.cmake
- Adapt setup_boost macro in cmake_support/OST.cmake to prefer versioned
  libraries and not first check for boost_python.so. In the example of
  Ubuntu 18.04, libboost_python.so is specific for Python 2 but
  libboost_python3.so is the one we want.
- apply the following command: 2to3-2.7 -n -w <OST_DIR>
- adapt base/pymod/wrap_base.cc, gui/pymod/wrap_gui.cc and
  gui/pymod/export_message_widget.cc as PyString functionalities do not exist
  anymore in the Python 3 interpreter (replaced by PyUnicode)
- adapt gui/src/python_shell/python_interpreter_worker.hh to resolve issue
  discussed in https://stackoverflow.com/questions/23068700/embedding-python3-in-qt-5
  Long story short: Qt does a typedef for "slots" which causes trouble with
  other headers that are pulled in from the Python interpreter
6e60b71d
History

OST Docker

Note

For many docker installations it is required to run docker commands as root. As this depends on set up, we skip the sudo in all commands.

Build Docker image

In order to build OST image:

cd <PATH TO OST>/docker
docker build --tag <IMAGE NAME> -f Dockerfile .

or if you downloaded the Dockerfile directly:

docker build --tag <IMAGE NAME> -f <DOCKERFILE NAME> <PATH TO DOCKERFILE DIR>

You can chose any image name (tag) eg. ost. Here we only keep the recipe for the most recent version of OpenStructure. To build an image for a different version, you can either adapt the OPENSTRUCTURE_VERSION variable in the recipe or look in the git history for an older recipe.

Testing the image

One can find a exemplary script (test_docker.py) in the downloaded directory. To run it do:

cd <PATH TO OST>/docker
docker run --rm -v $(pwd):/home <IMAGE NAME> test_docker.py

As the last line you should see OST is working!.

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 above by specifying -v /home/user:/home. To run the script we thus need to provide the (relative) path to the script and (relative) path to the file eg:

docker run --rm -v /home/user:/home <IMAGE NAME> script.py pdbs/struct.pdb

or with absolute paths:

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:

docker run --rm <IMAGE NAME> -h

To run chosen action do:

docker run --rm <IMAGE NAME> <ACTION NAME>

Here is an example run of the compare-structures action:

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:

docker run --rm <IMAGE NAME> compare-structures -h

Scripts

In order to run OST script do:

docker run [DOCKER OPTIONS] --rm -v <PATH TO SCRIPT DIR>:/home <IMAGE NAME> /home/<SCRIPT NAME> [SCRIPT OPTIONS]

Run ost with utility command

One can also use provided utility bash script run_docker_ost to run basic scripts and actions:

<PATH TO OST>/docker/run_docker_ost <IMAGE_NAME> [<SCRIPT_PATH>] [SCRIPT OPTIONS]

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:

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:

cd <PATH TO OST>/docker
./run_docker_ost <IMAGE NAME> test_docker.py

To see the help for compare-structures action run:

cd <PATH TO OST>/docker
./run_docker_ost <IMAGE NAME> compare-structures

Run GUI

In order to run GUI do (tested on linux machine):

xhost +local:docker
docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --entrypoint dng <IMAGE NAME>

Running other commands

The default entrypoint of the Docker image is "ost" thus in order to run other available commands (or other commands in general) one need to override the entrypoint:

docker run --rm -ti --entrypoint <COMMAND> <IMAGE NAME> [COMMAND OPTIONS]

Eg. to run molck type:

docker run --rm -ti --entrypoint molck <IMAGE NAME> --help

Note

Note how the options to the command are specified after the image name.