From edd1867550cb8ced74bc319055135c8d76474333 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Javier=20Gonz=C3=A1lez-Delgado?= <jgonzalezd@laas.fr>
Date: Mon, 6 Nov 2023 10:05:44 +0000
Subject: [PATCH] Add error messages for missing atoms.

---
 wario/get_coordinates.ipynb | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/wario/get_coordinates.ipynb b/wario/get_coordinates.ipynb
index 4c935ad..09c3727 100644
--- a/wario/get_coordinates.ipynb
+++ b/wario/get_coordinates.ipynb
@@ -14,6 +14,7 @@
     "import itertools\n",
     "import pandas as pd \n",
     "from Bio import PDB \n",
+    "import sys\n",
     "import warnings #Optional\n",
     "warnings.filterwarnings(\"ignore\") #Optional"
    ]
@@ -120,9 +121,20 @@
     "    # 1. Definition of the reference frame on every sequence position\n",
     "\n",
     "    CA_coor = df.loc[ (df.Atom == 'CA') , ['coor_x','coor_y','coor_z']].to_numpy() # CA coordinates \n",
+    "   \n",
+    "    if np.shape(CA_coor)[0] != L:\n",
+    "        sys.exit('The number of CA atoms does not match the number of residues.')\n",
+    "               \n",
     "    N_coor = df.loc[ (df.Atom == 'N')  , ['coor_x','coor_y','coor_z']].to_numpy() # N coordinates \n",
+    "    \n",
+    "    if np.shape(N_coor)[0] != L:\n",
+    "        sys.exit('The number of N atoms does not match the number of residues.')\n",
+    "    \n",
     "    C_coor = df.loc[ (df.Atom == 'C')  , ['coor_x','coor_y','coor_z']].to_numpy() # C coordinates \n",
     "    \n",
+    "    if np.shape(C_coor)[0] != L:\n",
+    "        sys.exit('The number of C atoms does not match the number of residues.')\n",
+    " \n",
     "    N_CA_coor = N_coor - CA_coor; N_CA_coor = N_CA_coor / np.linalg.norm(N_CA_coor, axis = 1)[:, None]\n",
     "    C_CA_coor = C_coor - CA_coor; C_CA_coor = C_CA_coor / np.linalg.norm(C_CA_coor, axis = 1)[:, None]\n",
     "    CxN_coor = np.cross(C_CA_coor, N_CA_coor); CxN_coor = CxN_coor / np.linalg.norm(CxN_coor, axis = 1)[:, None]\n",
@@ -166,6 +178,14 @@
     "    \n",
     "    return positions_and_frames"
    ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "58692e89-a456-40c1-8b76-254696b702d4",
+   "metadata": {},
+   "outputs": [],
+   "source": []
   }
  ],
  "metadata": {
@@ -184,7 +204,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.16"
+   "version": "3.10.9"
   }
  },
  "nbformat": 4,
-- 
GitLab