{ "cells": [ { "cell_type": "markdown", "id": "eb5aec69-ec86-4e36-8a73-5f4e36933210", "metadata": {}, "source": [ "# Publication Figure 2\n", "\n", "This jupyter notebook contains the Analysis code for an upcoming publication.\n", "\n", "Authors: Kevin Sawade (kevin.sawade@uni-konstanz.de), Tobias Lemke, Christine Peter (christine.peter@uni-konstanz.de)\n", "\n", "EncoderMap's featurization was inspired by the (no longer maintained) PyEMMA library. Consider citing it (https://dx.doi.org/10.1021/acs.jctc.5b00743), if you are using EncoderMap:\n", "\n", "## Imports\n", "\n", "We start with the imports." ] }, { "cell_type": "code", "execution_count": 1, "id": "913c57c6-8ead-467e-ac56-fd9cb956b2fd", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/kevin/git/encoder_map_private/encodermap/__init__.py:194: GPUsAreDisabledWarning: EncoderMap disables the GPU per default because most tensorflow code runs with a higher compatibility when the GPU is disabled. If you want to enable GPUs manually, set the environment variable 'ENCODERMAP_ENABLE_GPU' to 'True' before importing EncoderMap. To do this in python you can run:\n", "\n", "import os; os.environ['ENCODERMAP_ENABLE_GPU'] = 'True'\n", "\n", "before importing encodermap.\n", " _warnings.warn(\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1b1649a04ff247919304d16aed4cc23e", "version_major": 2, "version_minor": 0 }, "text/plain": [] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Future imports at the top\n", "from __future__ import annotations\n", "\n", "# Import EncoderMap\n", "import encodermap as em\n", "from encodermap.plot import plotting\n", "from encodermap.plot.plotting import _plot_free_energy\n", "\n", "# Builtin packages\n", "import re\n", "import io\n", "import warnings\n", "import os\n", "import json\n", "import contextlib\n", "import time\n", "from copy import deepcopy\n", "from types import SimpleNamespace\n", "from pathlib import Path\n", "\n", "# Math\n", "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "\n", "# ML\n", "import tensorflow as tf\n", "\n", "# Plotting\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "import plotly.io as pio\n", "from plotly.subplots import make_subplots\n", "import plotly.io as pio\n", "\n", "# MD\n", "import mdtraj as md\n", "import MDAnalysis as mda\n", "import nglview as nv\n", "\n", "# dates\n", "from dateutil import parser" ] }, { "cell_type": "markdown", "id": "d53853ab-4621-4d9e-8d20-c4362dd2788a", "metadata": {}, "source": [ "Using Autoreload we can make changes in the EncoderMap source code and use the new code, without needing to restart the Kernel." ] }, { "cell_type": "code", "execution_count": 2, "id": "72a51593-f805-47a1-8a05-6d9f92997c68", "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "markdown", "id": "5dc62d2f-b097-4439-adb5-30777ec9420a", "metadata": {}, "source": [ "## Trained network weights\n", "\n", "EncoderMap's Neural Network is initialized with random weights and biases. While the training is deterministic with pre-defined training weights, and the inferences that can be made from two trained models are qualitatively similar, the numerical exact output depends on the starting weights.\n", "\n", "For this reason, the trained network weights are available from the corresponding authors upon reasonable request or by raising an issue on GitHub: https://github.com/AG-Peter/encodermap/issues\n", "\n", "For this figure, data from Berg et al. is used.\n", "\n", "```\n", "@article{berg2018towards,\n", " title={Towards a molecular basis of ubiquitin signaling: A dual-scale simulation study of ubiquitin dimers},\n", " author={Berg, Andrej and Kukharenko, Oleksandra and Scheffner, Martin and Peter, Christine},\n", " journal={PLoS computational biology},\n", " volume={14},\n", " number={11},\n", " pages={e1006589},\n", " year={2018},\n", " publisher={Public Library of Science San Francisco, CA USA}\n", "}\n", "```\n", "\n", "### Load MD data from KonDATA\n", "\n", "The necessary simulations have also been uploaded to KonDATA and can be obtained from there." ] }, { "cell_type": "code", "execution_count": 3, "id": "d87c871b-4471-46c1-bb64-aee864d2ed0d", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n" ], "text/plain": [] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "figure_2_data_dir = Path.cwd() / \"analysis/figure_2\"\n", "figure_2_data_dir = em.get_from_kondata(\n", " \"linear_dimers\",\n", " figure_2_data_dir,\n", " mk_parentdir=True,\n", " silence_overwrite_message=True,\n", ")" ] }, { "cell_type": "markdown", "id": "8e13fef0-c6d8-472c-a905-9d1a6616bd0b", "metadata": {}, "source": [ "From the downloaded files, a trajectory ensemble can be constructed." ] }, { "cell_type": "code", "execution_count": 4, "id": "575767af-5241-4120-92fc-36b9add3b8bb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "analysis/figure_2/11.xtc\n", "analysis/figure_2/02.xtc\n", "analysis/figure_2/06.xtc\n", "analysis/figure_2/03.xtc\n", "analysis/figure_2/12.xtc\n", "analysis/figure_2/10.xtc\n", "analysis/figure_2/07.xtc\n", "analysis/figure_2/05.xtc\n", "analysis/figure_2/04.xtc\n", "analysis/figure_2/01.xtc\n", "analysis/figure_2/09.xtc\n", "analysis/figure_2/08.xtc\n" ] }, { "data": { "text/plain": [ "