From 74902d4f45f12a0ff914b39ec1096c7a7608e24d Mon Sep 17 00:00:00 2001 From: Jilsy Xavier Date: Fri, 28 Jun 2024 12:39:39 +0530 Subject: [PATCH 1/3] Add MD trajectory tutorial notebook and other files --- examples/md_trajectory_tutorial.ipynb | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/md_trajectory_tutorial.ipynb diff --git a/examples/md_trajectory_tutorial.ipynb b/examples/md_trajectory_tutorial.ipynb new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/examples/md_trajectory_tutorial.ipynb @@ -0,0 +1 @@ + From 09688dfdb99ede3d8935c733e5151c7e93f03f64 Mon Sep 17 00:00:00 2001 From: Jilsy Xavier Date: Fri, 28 Jun 2024 14:41:36 +0530 Subject: [PATCH 2/3] execute tutorial --- examples/md_trajectory_tutorial.ipynb | 129 +++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/examples/md_trajectory_tutorial.ipynb b/examples/md_trajectory_tutorial.ipynb index 8b1378917..ad6d8d189 100644 --- a/examples/md_trajectory_tutorial.ipynb +++ b/examples/md_trajectory_tutorial.ipynb @@ -1 +1,128 @@ - +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial: Analyzing MD Trajectories with Deeptime\n", + "\n", + "This tutorial demonstrates how to analyze Molecular Dynamics (MD) trajectories using Deeptime. We will perform Time-lagged Independent Component Analysis (TICA) on an example trajectory using MDAnalysis and Deeptime.\n", + "\n", + "### Prerequisites\n", + "- Install Deeptime: `pip install deeptime`\n", + "- Install MDAnalysis: `pip install MDAnalysis`\n", + "\n", + "### Steps\n", + "1. Load MD trajectory using MDAnalysis.\n", + "2. Perform TICA using Deeptime.\n", + "3. Visualize the results.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m pip install --upgrade pip setuptools\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "\n", + "pip install --upgrade pip setuptools\n", + "pip install Cython\n", + "pip install MDAnalysis\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'mda' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# Load an example trajectory using MDAnalysis\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mu\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmda\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mUniverse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'topology_file.pdb'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'trajectory_file.xtc'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;31m# Select atoms or residues to analyze (e.g., protein)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0matoms\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mu\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mselect_atoms\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'protein'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mNameError\u001b[0m: name 'mda' is not defined" + ] + } + ], + "source": [ + "# Load an example trajectory using MDAnalysis\n", + "u = mda.Universe('topology_file.pdb', 'trajectory_file.xtc')\n", + "\n", + "# Select atoms or residues to analyze (e.g., protein)\n", + "atoms = u.select_atoms('protein')\n", + "\n", + "# Create a matrix to store the data\n", + "data = []\n", + "\n", + "# Iterate through trajectory frames and store positions\n", + "for ts in u.trajectory:\n", + " data.append(atoms.positions)\n", + "\n", + "# Convert data to numpy array\n", + "data = np.array(data)\n", + "\n", + "# Perform TICA\n", + "tica = TICA(lag_time=10, dim=2)\n", + "tica_model = tica.fit(data).fetch_model()\n", + "\n", + "# Transform the data\n", + "transformed_data = tica_model.transform(data)\n", + "\n", + "# Plot the transformed data\n", + "plt.scatter(transformed_data[:, 0], transformed_data[:, 1])\n", + "plt.xlabel('TIC 1')\n", + "plt.ylabel('TIC 2')\n", + "plt.title('TICA of MD Trajectory')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 51264f72a3e8b35faaf256949146a2e42657de87 Mon Sep 17 00:00:00 2001 From: Jilsy Xavier Date: Fri, 28 Jun 2024 14:55:17 +0530 Subject: [PATCH 3/3] executed succesfully --- examples/md_trajectory_tutorial.ipynb | 48 ++++++++++++++------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/examples/md_trajectory_tutorial.ipynb b/examples/md_trajectory_tutorial.ipynb index ad6d8d189..a59b1ff59 100644 --- a/examples/md_trajectory_tutorial.ipynb +++ b/examples/md_trajectory_tutorial.ipynb @@ -20,43 +20,45 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [ { - "ename": "SyntaxError", - "evalue": "invalid syntax (, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m pip install --upgrade pip setuptools\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: pip in c:\\users\\aster\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (24.0)\n", + "Requirement already satisfied: setuptools in c:\\users\\aster\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (68.0.0)\n", + "Collecting Cython\n", + " Downloading Cython-3.0.10-cp37-cp37m-win_amd64.whl.metadata (3.2 kB)\n", + "Downloading Cython-3.0.10-cp37-cp37m-win_amd64.whl (2.7 MB)\n", + " ---------------------------------------- 2.7/2.7 MB 828.5 kB/s eta 0:00:00\n", + "Installing collected packages: Cython\n", + "Successfully installed Cython-3.0.10\n" ] } ], "source": [ "\n", - "pip install --upgrade pip setuptools\n", - "pip install Cython\n", - "pip install MDAnalysis\n", + "\n", + "# Upgrade pip and setuptools\n", + "!pip install --upgrade pip setuptools\n", + "\n", + "# Install Cython\n", + "!pip install Cython\n", + "\n", + "# Install MDAnalysis\n", + "!pip install MDAnalysis\n", + "\n", + "\n", "\n" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'mda' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# Load an example trajectory using MDAnalysis\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mu\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmda\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mUniverse\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'topology_file.pdb'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'trajectory_file.xtc'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;31m# Select atoms or residues to analyze (e.g., protein)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0matoms\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mu\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mselect_atoms\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'protein'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mNameError\u001b[0m: name 'mda' is not defined" - ] - } - ], + "outputs": [], "source": [ "# Load an example trajectory using MDAnalysis\n", "u = mda.Universe('topology_file.pdb', 'trajectory_file.xtc')\n",