From 9e04758edb97b241642800891f8b6b8613970e00 Mon Sep 17 00:00:00 2001 From: "Zeng, Wen-Feng" Date: Thu, 28 Oct 2021 14:46:02 +0200 Subject: [PATCH] quick fix for save_hdf codes --- alphabase/speclib/decoy_library.py | 12 +- alphabase/speclib/library_base.py | 9 +- nbdev_nbs/speclib/decoy_library.ipynb | 232 +++++++++++++------------- nbdev_nbs/speclib/library_base.ipynb | 11 +- 4 files changed, 133 insertions(+), 131 deletions(-) diff --git a/alphabase/speclib/decoy_library.py b/alphabase/speclib/decoy_library.py index daa4d9d0..d042d057 100644 --- a/alphabase/speclib/decoy_library.py +++ b/alphabase/speclib/decoy_library.py @@ -29,7 +29,7 @@ def _decoy_meta(self): def _decoy_mod(self): """ - Decoy for modifications and modification sits + Decoy for modifications and modification sites """ pass @@ -65,11 +65,11 @@ def save_hdf(self, hdf_file): truncate=True, delete_existing=False ) - _hdf_lib = _hdf.library - _hdf_lib.add_group('decoy',{}) - _hdf_lib.decoy.precursor_df = self._precursor_df - _hdf_lib.decoy.fragment_mass_df = self._fragment_mass_df - _hdf_lib.decoy.fragment_inten_df = self._fragment_inten_df + _hdf.library.decoy = { + 'precursor_df': self._precursor_df, + 'fragment_mass_df': self._fragment_mass_df, + 'fragment_inten_df': self._fragment_inten_df, + } def load_hdf(self, hdf_file): _hdf = HDF_File( diff --git a/alphabase/speclib/library_base.py b/alphabase/speclib/library_base.py index dc06e331..9a78d256 100644 --- a/alphabase/speclib/library_base.py +++ b/alphabase/speclib/library_base.py @@ -140,10 +140,11 @@ def save_hdf(self, hdf_file): truncate=True, delete_existing=True ) - _hdf.add_group('library',{}) - _hdf.library.precursor_df = self._precursor_df - _hdf.library.fragment_mass_df = self._fragment_mass_df - _hdf.library.fragment_inten_df = self._fragment_inten_df + _hdf.library = { + 'precursor_df': self._precursor_df, + 'fragment_mass_df': self._fragment_mass_df, + 'fragment_inten_df': self._fragment_inten_df, + } def load_hdf(self, hdf_file): _hdf = HDF_File( diff --git a/nbdev_nbs/speclib/decoy_library.ipynb b/nbdev_nbs/speclib/decoy_library.ipynb index 05626c17..49c2e8e1 100644 --- a/nbdev_nbs/speclib/decoy_library.ipynb +++ b/nbdev_nbs/speclib/decoy_library.ipynb @@ -42,7 +42,7 @@ "\n", " def _decoy_mod(self):\n", " \"\"\"\n", - " Decoy for modifications and modification sits\n", + " Decoy for modifications and modification sites\n", " \"\"\"\n", " pass\n", "\n", @@ -78,11 +78,11 @@ " truncate=True,\n", " delete_existing=False\n", " )\n", - " _hdf_lib = _hdf.library\n", - " _hdf_lib.add_group('decoy',{})\n", - " _hdf_lib.decoy.precursor_df = self._precursor_df\n", - " _hdf_lib.decoy.fragment_mass_df = self._fragment_mass_df\n", - " _hdf_lib.decoy.fragment_inten_df = self._fragment_inten_df\n", + " _hdf.library.decoy = {\n", + " 'precursor_df': self._precursor_df,\n", + " 'fragment_mass_df': self._fragment_mass_df,\n", + " 'fragment_inten_df': self._fragment_inten_df,\n", + " }\n", "\n", " def load_hdf(self, hdf_file):\n", " _hdf = HDF_File(\n", @@ -305,38 +305,38 @@ " \n", " \n", " 0\n", - " 114.054950\n", - " 57.531113\n", - " 1091.439662\n", - " 546.223469\n", + " 114.054954\n", + " 57.531115\n", + " 1091.439711\n", + " 546.223494\n", " \n", " \n", " 1\n", - " 171.076411\n", - " 86.041843\n", - " 1034.418201\n", - " 517.712738\n", + " 171.076418\n", + " 86.041847\n", + " 1034.418247\n", + " 517.712762\n", " \n", " \n", " 2\n", - " 308.135317\n", - " 154.571296\n", - " 897.359295\n", - " 449.183285\n", + " 308.135330\n", + " 154.571303\n", + " 897.359336\n", + " 449.183306\n", " \n", " \n", " 3\n", - " 468.165958\n", - " 234.586617\n", - " 737.328653\n", - " 369.167965\n", + " 468.165979\n", + " 234.586627\n", + " 737.328687\n", + " 369.167981\n", " \n", " \n", " 4\n", - " 597.208546\n", - " 299.107911\n", - " 608.286066\n", - " 304.646671\n", + " 597.208572\n", + " 299.107924\n", + " 608.286094\n", + " 304.646685\n", " \n", " \n", " ...\n", @@ -347,38 +347,38 @@ " \n", " \n", " 58\n", - " 1071.449834\n", - " 536.228555\n", - " 561.262688\n", - " 281.134982\n", + " 1071.449882\n", + " 536.228579\n", + " 561.262715\n", + " 281.134996\n", " \n", " \n", " 59\n", - " 1142.486944\n", - " 571.747110\n", - " 490.225578\n", - " 245.616427\n", + " 1142.486996\n", + " 571.747136\n", + " 490.225602\n", + " 245.616439\n", " \n", " \n", " 60\n", - " 1213.524054\n", - " 607.265665\n", - " 419.188468\n", - " 210.097872\n", + " 1213.524110\n", + " 607.265693\n", + " 419.188488\n", + " 210.097882\n", " \n", " \n", " 61\n", - " 1328.550993\n", - " 664.779134\n", - " 304.161529\n", - " 152.584403\n", + " 1328.551053\n", + " 664.779164\n", + " 304.161545\n", + " 152.584410\n", " \n", " \n", " 62\n", - " 1457.593580\n", - " 729.300428\n", - " 175.118941\n", - " 88.063109\n", + " 1457.593646\n", + " 729.300461\n", + " 175.118952\n", + " 88.063114\n", " \n", " \n", "\n", @@ -387,17 +387,17 @@ ], "text/plain": [ " b_1 b_2 y_1 y_2\n", - "0 114.054950 57.531113 1091.439662 546.223469\n", - "1 171.076411 86.041843 1034.418201 517.712738\n", - "2 308.135317 154.571296 897.359295 449.183285\n", - "3 468.165958 234.586617 737.328653 369.167965\n", - "4 597.208546 299.107911 608.286066 304.646671\n", + "0 114.054954 57.531115 1091.439711 546.223494\n", + "1 171.076418 86.041847 1034.418247 517.712762\n", + "2 308.135330 154.571303 897.359336 449.183306\n", + "3 468.165979 234.586627 737.328687 369.167981\n", + "4 597.208572 299.107924 608.286094 304.646685\n", ".. ... ... ... ...\n", - "58 1071.449834 536.228555 561.262688 281.134982\n", - "59 1142.486944 571.747110 490.225578 245.616427\n", - "60 1213.524054 607.265665 419.188468 210.097872\n", - "61 1328.550993 664.779134 304.161529 152.584403\n", - "62 1457.593580 729.300428 175.118941 88.063109\n", + "58 1071.449882 536.228579 561.262715 281.134996\n", + "59 1142.486996 571.747136 490.225602 245.616439\n", + "60 1213.524110 607.265693 419.188488 210.097882\n", + "61 1328.551053 664.779164 304.161545 152.584410\n", + "62 1457.593646 729.300461 175.118952 88.063114\n", "\n", "[63 rows x 4 columns]" ] @@ -461,7 +461,7 @@ " 0;4;8\n", " 9\n", " 2\n", - " 602.747306\n", + " 602.747333\n", " 0\n", " 8\n", " \n", @@ -472,7 +472,7 @@ " 0;4;8\n", " 9\n", " 2\n", - " 602.747306\n", + " 602.747333\n", " 8\n", " 16\n", " \n", @@ -483,7 +483,7 @@ " 0;4;8\n", " 9\n", " 2\n", - " 602.747306\n", + " 602.747333\n", " 16\n", " 24\n", " \n", @@ -494,7 +494,7 @@ " \n", " 14\n", " 2\n", - " 816.356261\n", + " 816.356299\n", " 24\n", " 37\n", " \n", @@ -505,7 +505,7 @@ " \n", " 14\n", " 2\n", - " 816.356261\n", + " 816.356299\n", " 37\n", " 50\n", " \n", @@ -516,7 +516,7 @@ " \n", " 14\n", " 2\n", - " 816.356261\n", + " 816.356299\n", " 50\n", " 63\n", " \n", @@ -534,12 +534,12 @@ "5 EDAAKMQWECHGAR \n", "\n", " mod_sites nAA charge precursor_mz frag_start_idx frag_end_idx \n", - "0 0;4;8 9 2 602.747306 0 8 \n", - "1 0;4;8 9 2 602.747306 8 16 \n", - "2 0;4;8 9 2 602.747306 16 24 \n", - "3 14 2 816.356261 24 37 \n", - "4 14 2 816.356261 37 50 \n", - "5 14 2 816.356261 50 63 " + "0 0;4;8 9 2 602.747333 0 8 \n", + "1 0;4;8 9 2 602.747333 8 16 \n", + "2 0;4;8 9 2 602.747333 16 24 \n", + "3 14 2 816.356299 24 37 \n", + "4 14 2 816.356299 37 50 \n", + "5 14 2 816.356299 50 63 " ] }, "execution_count": null, @@ -598,7 +598,7 @@ " 0;4;8\n", " 9\n", " 2\n", - " 621.800394\n", + " 621.800422\n", " 0\n", " 8\n", " \n", @@ -609,7 +609,7 @@ " 0;4;8\n", " 9\n", " 2\n", - " 621.800394\n", + " 621.800422\n", " 8\n", " 16\n", " \n", @@ -620,7 +620,7 @@ " 0;4;8\n", " 9\n", " 2\n", - " 621.800394\n", + " 621.800422\n", " 16\n", " 24\n", " \n", @@ -631,7 +631,7 @@ " \n", " 14\n", " 2\n", - " 837.379735\n", + " 837.379774\n", " 24\n", " 37\n", " \n", @@ -642,7 +642,7 @@ " \n", " 14\n", " 2\n", - " 837.379735\n", + " 837.379774\n", " 37\n", " 50\n", " \n", @@ -653,7 +653,7 @@ " \n", " 14\n", " 2\n", - " 837.379735\n", + " 837.379774\n", " 50\n", " 63\n", " \n", @@ -671,12 +671,12 @@ "5 ALHCEWQMKAADDR \n", "\n", " mod_sites nAA charge precursor_mz frag_start_idx frag_end_idx \n", - "0 0;4;8 9 2 621.800394 0 8 \n", - "1 0;4;8 9 2 621.800394 8 16 \n", - "2 0;4;8 9 2 621.800394 16 24 \n", - "3 14 2 837.379735 24 37 \n", - "4 14 2 837.379735 37 50 \n", - "5 14 2 837.379735 50 63 " + "0 0;4;8 9 2 621.800422 0 8 \n", + "1 0;4;8 9 2 621.800422 8 16 \n", + "2 0;4;8 9 2 621.800422 16 24 \n", + "3 14 2 837.379774 24 37 \n", + "4 14 2 837.379774 37 50 \n", + "5 14 2 837.379774 50 63 " ] }, "execution_count": null, @@ -737,7 +737,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 602.747306\n", + " 602.747333\n", " AGHCEWQMK\n", " \n", " \n", @@ -748,7 +748,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 602.747306\n", + " 602.747333\n", " AGHCEWQMK\n", " \n", " \n", @@ -759,7 +759,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 602.747306\n", + " 602.747333\n", " AGHCEWQMK\n", " \n", " \n", @@ -770,7 +770,7 @@ " \n", " \n", " 14\n", - " 816.356261\n", + " 816.356299\n", " AGHCEWQMKAADER\n", " \n", " \n", @@ -781,7 +781,7 @@ " \n", " \n", " 14\n", - " 816.356261\n", + " 816.356299\n", " AGHCEWQMKAADER\n", " \n", " \n", @@ -792,7 +792,7 @@ " \n", " \n", " 14\n", - " 816.356261\n", + " 816.356299\n", " AGHCEWQMKAADER\n", " \n", " \n", @@ -809,12 +809,12 @@ "5 2 63 50 \n", "\n", " mods nAA precursor_mz \\\n", - "0 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 602.747306 \n", - "1 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 602.747306 \n", - "2 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 602.747306 \n", - "3 14 816.356261 \n", - "4 14 816.356261 \n", - "5 14 816.356261 \n", + "0 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 602.747333 \n", + "1 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 602.747333 \n", + "2 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 602.747333 \n", + "3 14 816.356299 \n", + "4 14 816.356299 \n", + "5 14 816.356299 \n", "\n", " sequence \n", "0 AGHCEWQMK \n", @@ -881,7 +881,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 621.800394\n", + " 621.800422\n", " ALHCEWQLK\n", " \n", " \n", @@ -892,7 +892,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 621.800394\n", + " 621.800422\n", " ALHCEWQLK\n", " \n", " \n", @@ -903,7 +903,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 621.800394\n", + " 621.800422\n", " ALHCEWQLK\n", " \n", " \n", @@ -914,7 +914,7 @@ " \n", " \n", " 14\n", - " 837.379735\n", + " 837.379774\n", " ALHCEWQMKAADDR\n", " \n", " \n", @@ -925,7 +925,7 @@ " \n", " \n", " 14\n", - " 837.379735\n", + " 837.379774\n", " ALHCEWQMKAADDR\n", " \n", " \n", @@ -936,7 +936,7 @@ " \n", " \n", " 14\n", - " 837.379735\n", + " 837.379774\n", " ALHCEWQMKAADDR\n", " \n", " \n", @@ -953,12 +953,12 @@ "5 2 63 50 \n", "\n", " mods nAA precursor_mz \\\n", - "0 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800394 \n", - "1 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800394 \n", - "2 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800394 \n", - "3 14 837.379735 \n", - "4 14 837.379735 \n", - "5 14 837.379735 \n", + "0 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800422 \n", + "1 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800422 \n", + "2 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800422 \n", + "3 14 837.379774 \n", + "4 14 837.379774 \n", + "5 14 837.379774 \n", "\n", " sequence \n", "0 ALHCEWQLK \n", @@ -1024,7 +1024,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 621.800394\n", + " 621.800422\n", " ALHCEWQLK\n", " \n", " \n", @@ -1035,7 +1035,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 621.800394\n", + " 621.800422\n", " ALHCEWQLK\n", " \n", " \n", @@ -1046,7 +1046,7 @@ " 0;4;8\n", " Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat...\n", " 9\n", - " 621.800394\n", + " 621.800422\n", " ALHCEWQLK\n", " \n", " \n", @@ -1057,7 +1057,7 @@ " \n", " \n", " 14\n", - " 837.379735\n", + " 837.379774\n", " ALHCEWQMKAADDR\n", " \n", " \n", @@ -1068,7 +1068,7 @@ " \n", " \n", " 14\n", - " 837.379735\n", + " 837.379774\n", " ALHCEWQMKAADDR\n", " \n", " \n", @@ -1079,7 +1079,7 @@ " \n", " \n", " 14\n", - " 837.379735\n", + " 837.379774\n", " ALHCEWQMKAADDR\n", " \n", " \n", @@ -1096,12 +1096,12 @@ "5 2 63 50 \n", "\n", " mods nAA precursor_mz \\\n", - "0 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800394 \n", - "1 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800394 \n", - "2 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800394 \n", - "3 14 837.379735 \n", - "4 14 837.379735 \n", - "5 14 837.379735 \n", + "0 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800422 \n", + "1 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800422 \n", + "2 Acetyl@Protein N-term;Carbamidomethyl@C;Oxidat... 9 621.800422 \n", + "3 14 837.379774 \n", + "4 14 837.379774 \n", + "5 14 837.379774 \n", "\n", " sequence \n", "0 ALHCEWQLK \n", diff --git a/nbdev_nbs/speclib/library_base.ipynb b/nbdev_nbs/speclib/library_base.ipynb index fb5652da..2fe65103 100644 --- a/nbdev_nbs/speclib/library_base.ipynb +++ b/nbdev_nbs/speclib/library_base.ipynb @@ -153,11 +153,12 @@ " truncate=True,\n", " delete_existing=True\n", " )\n", - " _hdf.add_group('library',{})\n", - " _hdf.library.precursor_df = self._precursor_df\n", - " _hdf.library.fragment_mass_df = self._fragment_mass_df\n", - " _hdf.library.fragment_inten_df = self._fragment_inten_df\n", - "\n", + " _hdf.library = {\n", + " 'precursor_df': self._precursor_df,\n", + " 'fragment_mass_df': self._fragment_mass_df,\n", + " 'fragment_inten_df': self._fragment_inten_df,\n", + " }\n", + " \n", " def load_hdf(self, hdf_file):\n", " _hdf = HDF_File(\n", " hdf_file,\n",