Skip to content

new pandas breaks function "get_monomer_info"; fix provided #18

@Clayton-Springer

Description

@Clayton-Springer

I installed pyPept and was copy and pasting from the README into a jupyter notebook:


# PyPept modules
from pyPept.sequence import Sequence
from pyPept.sequence import correct_pdb_atoms
from pyPept.molecule import Molecule
from pyPept.converter import Converter
from pyPept.conformer import Conformer
from pyPept.conformer import SecStructPredictor

# RDKit modules
from rdkit import Chem
from rdkit.Chem import Draw

# Start the Sequence object
biln = "ac-D-T-H-F-E-I-A-am"
seq = Sequence(biln)     

I got this output:




---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 3
      1 # Start the Sequence object
      2 biln = "ac-D-T-H-F-E-I-A-am"
----> 3 seq = Sequence(biln)                         

File [~/Software/pyPept/pyPept/src/pyPept/sequence.py:103](http://192.168.50.97:8888/lab/tree/pyPept/pyPept/examples/pyPept/pyPept/src/pyPept/sequence.py#line=102), in Sequence.__init__(self, input_biln, path, monomer_lib)
    100 if monomer_df_filepath.is_file() is False:
    101     monomer_df_filepath = default_monomer_df_filepath
--> 103 self.monomer_df = get_monomer_info(str(monomer_df_filepath))
    105 try:
    106     # Parse the BILN sequence
    107     self.__parse_biln()

File [~/Software/pyPept/pyPept/src/pyPept/sequence.py:540](http://192.168.50.97:8888/lab/tree/pyPept/pyPept/examples/pyPept/pyPept/src/pyPept/sequence.py#line=539), in get_monomer_info(path)
    536             updated_change = [None if v == 'None' else int(v) for v in
    537                               change]
    538         #df_group.at[idx, group] = updated_change
    539         #was
--> 540         df_group.loc[idx, group] = updated_change
    541 df_group = df_group.set_index('symbol')
    542 df_group = df_group.rename(columns={"ROMol": "m_romol"})

File [~/miniforge3/envs/PepFuNN/lib/python3.14/site-packages/pandas/core/indexing.py:938](http://192.168.50.97:8888/home/corsa-219742/miniforge3/envs/PepFuNN/lib/python3.14/site-packages/pandas/core/indexing.py#line=937), in _LocationIndexer.__setitem__(self, key, value)
    933 self._has_valid_setitem_indexer(key)
    935 iloc: _iLocIndexer = (
    936     cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc
    937 )
--> 938 iloc._setitem_with_indexer(indexer, value, self.name)

File [~/miniforge3/envs/PepFuNN/lib/python3.14/site-packages/pandas/core/indexing.py:1953](http://192.168.50.97:8888/home/corsa-219742/miniforge3/envs/PepFuNN/lib/python3.14/site-packages/pandas/core/indexing.py#line=1952), in _iLocIndexer._setitem_with_indexer(self, indexer, value, name)
   1950 # align and set the values
   1951 if take_split_path:
   1952     # We have to operate column-wise
-> 1953     self._setitem_with_indexer_split_path(indexer, value, name)
   1954 else:
   1955     self._setitem_single_block(indexer, value, name)

File [~/miniforge3/envs/PepFuNN/lib/python3.14/site-packages/pandas/core/indexing.py:2009](http://192.168.50.97:8888/home/corsa-219742/miniforge3/envs/PepFuNN/lib/python3.14/site-packages/pandas/core/indexing.py#line=2008), in _iLocIndexer._setitem_with_indexer_split_path(self, indexer, value, name)
   2004     if len(value) == 1 and not is_integer(info_axis):
   2005         # This is a case like df.iloc[:3, [1]] = [0]
   2006         #  where we treat as df.iloc[:3, 1] = 0
   2007         return self._setitem_with_indexer((pi, info_axis[0]), value[0])
-> 2009     raise ValueError(
   2010         "Must have equal len keys and value when setting with an iterable"
   2011     )
   2013 elif lplane_indexer == 0 and len(value) == len(self.obj.index):
   2014     # We get here in one case via .loc with an all-False mask
   2015     pass

ValueError: Must have equal len keys and value when setting with an iterable

my fix was to set the type explicitly on line 526 of 'sequence.py' and use "at" instead of "loc" for the pandas dataframe

def get_monomer_info(path):
....
    df_group = PandasTools.LoadSDF(sdf_file).astype(object)
    #  was df_group = PandasTools.LoadSDF(sdf_file)
...
    df_group.at[idx, group] = updated_change
     # was df_group.loc[idx, group] = updated_change

here is my mamba environment:

$ mamba list
List of packages in environment: "/home/corsa-219742/miniforge3/envs/PepFuNN"

  Name                           Version       Build                 Channel
──────────────────────────────────────────────────────────────────────────────────
  _openmp_mutex                  4.5           20_gnu                conda-forge
  _python_abi3_support           1.0           hd8ed1ab_2            conda-forge
  anyio                          4.12.1        pyhcf101f3_0          conda-forge
  argon2-cffi                    25.1.0        pyhd8ed1ab_0          conda-forge
  argon2-cffi-bindings           25.1.0        py314h5bd0f2a_2       conda-forge
  arrow                          1.4.0         pyhcf101f3_0          conda-forge
  asttokens                      3.0.1         pyhd8ed1ab_0          conda-forge
  async-lru                      2.2.0         pyhcf101f3_0          conda-forge
  attrs                          25.4.0        pyhcf101f3_1          conda-forge
  babel                          2.18.0        pyhcf101f3_1          conda-forge
  backports.zstd                 1.3.0         py314h680f03e_0       conda-forge
  beautifulsoup4                 4.14.3        pyha770c72_0          conda-forge
  biopython                      1.86          py314h5bd0f2a_1       conda-forge
  bleach                         6.3.0         pyhcf101f3_1          conda-forge
  bleach-with-css                6.3.0         hbca2aae_1            conda-forge
  brotli                         1.2.0         hed03a55_1            conda-forge
  brotli-bin                     1.2.0         hb03c661_1            conda-forge
  brotli-python                  1.2.0         py314h3de4e8d_1       conda-forge
  bzip2                          1.0.8         hda65f42_9            conda-forge
  ca-certificates                2026.2.25     hbd8a1cb_0            conda-forge
  cached-property                1.5.2         hd8ed1ab_1            conda-forge
  cached_property                1.5.2         pyha770c72_1          conda-forge
  cairo                          1.18.4        he90730b_1            conda-forge
  certifi                        2026.2.25     pyhd8ed1ab_0          conda-forge
  cffi                           2.0.0         py314h4a8dc5f_1       conda-forge
  charset-normalizer             3.4.6         pyhd8ed1ab_0          conda-forge
  comm                           0.2.3         pyhe01879c_0          conda-forge
  contourpy                      1.3.3         py314h97ea11e_4       conda-forge
  cpython                        3.14.3        py314hd8ed1ab_101     conda-forge
  cycler                         0.12.1        pyhcf101f3_2          conda-forge
  cyrus-sasl                     2.1.28        hac629b4_1            conda-forge
  debugpy                        1.8.20        py314h42812f9_0       conda-forge
  decorator                      5.2.1         pyhd8ed1ab_0          conda-forge
  defusedxml                     0.7.1         pyhd8ed1ab_0          conda-forge
  docutils                       0.22.4        pypi_0                pypi
  eigen-abi                      3.4.0.100     h3bcb7cf_2            conda-forge
  et_xmlfile                     2.0.0         pypi_0                pypi
  exceptiongroup                 1.3.1         pyhd8ed1ab_0          conda-forge
  executing                      2.2.1         pyhd8ed1ab_0          conda-forge
  font-ttf-dejavu-sans-mono      2.37          hab24e00_0            conda-forge
  font-ttf-inconsolata           3.000         h77eed37_0            conda-forge
  font-ttf-source-code-pro       2.038         h77eed37_0            conda-forge
  font-ttf-ubuntu                0.83          h77eed37_3            conda-forge
  fontconfig                     2.17.1        h27c8c51_0            conda-forge
  fonts-conda-ecosystem          1             0                     conda-forge
  fonts-conda-forge              1             hc364b38_1            conda-forge
  fonttools                      4.62.0        pyh7db6752_0          conda-forge
  fqdn                           1.5.1         pyhd8ed1ab_1          conda-forge
  freetype                       2.14.2        ha770c72_0            conda-forge
  freetype-py                    2.3.0         pyhd8ed1ab_0          conda-forge
  greenlet                       3.3.2         py314h42812f9_0       conda-forge
  h11                            0.16.0        pyhcf101f3_1          conda-forge
  h2                             4.3.0         pyhcf101f3_0          conda-forge
  hpack                          4.1.0         pyhd8ed1ab_0          conda-forge
  httpcore                       1.0.9         pyh29332c3_0          conda-forge
  httpx                          0.28.1        pyhd8ed1ab_0          conda-forge
  hyperframe                     6.1.0         pyhd8ed1ab_0          conda-forge
  icu                            78.2          h33c6efd_0            conda-forge
  idna                           3.11          pyhd8ed1ab_0          conda-forge
  igraph                         1.0.0         pypi_0                pypi
  importlib-metadata             8.7.0         pyhe01879c_1          conda-forge
  importlib_resources            6.5.2         pyhd8ed1ab_0          conda-forge
  ipykernel                      7.2.0         pyha191276_1          conda-forge
  ipython                        9.11.0        pyhecfbec7_0          conda-forge
  ipython_pygments_lexers        1.1.1         pyhd8ed1ab_0          conda-forge
  ipywidgets                     8.1.8         pyhd8ed1ab_0          conda-forge
  isoduration                    20.11.0       pyhd8ed1ab_1          conda-forge
  jedi                           0.19.2        pyhd8ed1ab_1          conda-forge
  jinja2                         3.1.6         pyhcf101f3_1          conda-forge
  joblib                         1.5.3         pyhd8ed1ab_0          conda-forge
  json5                          0.13.0        pyhd8ed1ab_0          conda-forge
  jsonpointer                    3.0.0         pyhcf101f3_3          conda-forge
  jsonschema                     4.26.0        pyhcf101f3_0          conda-forge
  jsonschema-specifications      2025.9.1      pyhcf101f3_0          conda-forge
  jsonschema-with-format-nongpl  4.26.0        hcf101f3_0            conda-forge
  jupyter                        1.1.1         pyhd8ed1ab_1          conda-forge
  jupyter-lsp                    2.3.0         pyhcf101f3_0          conda-forge
  jupyter_client                 8.8.0         pyhcf101f3_0          conda-forge
  jupyter_console                6.6.3         pyhd8ed1ab_1          conda-forge
  jupyter_core                   5.9.1         pyhc90fa1f_0          conda-forge
  jupyter_events                 0.12.0        pyhe01879c_0          conda-forge
  jupyter_server                 2.17.0        pyhcf101f3_0          conda-forge
  jupyter_server_terminals       0.5.4         pyhcf101f3_0          conda-forge
  jupyterlab                     4.5.6         pyhd8ed1ab_0          conda-forge
  jupyterlab_pygments            0.3.0         pyhd8ed1ab_2          conda-forge
  jupyterlab_server              2.28.0        pyhcf101f3_0          conda-forge
  jupyterlab_widgets             3.0.16        pyhcf101f3_1          conda-forge
  keyutils                       1.6.3         hb9d3cd8_0            conda-forge
  kiwisolver                     1.5.0         py314h97ea11e_0       conda-forge
  krb5                           1.22.2        ha1258a1_0            conda-forge
  lark                           1.3.1         pyhd8ed1ab_0          conda-forge
  lcms2                          2.18          h0c24ade_0            conda-forge
  ld_impl_linux-64               2.45.1        default_hbd61a6d_101  conda-forge
  lerc                           4.1.0         hdb68285_0            conda-forge
  libblas                        3.11.0        5_h4a7cf45_openblas   conda-forge
  libboost                       1.86.0        hd24cca6_5            conda-forge
  libboost-python                1.86.0        py314h3a4f467_5       conda-forge
  libbrotlicommon                1.2.0         hb03c661_1            conda-forge
  libbrotlidec                   1.2.0         hb03c661_1            conda-forge
  libbrotlienc                   1.2.0         hb03c661_1            conda-forge
  libcblas                       3.11.0        5_h0358290_openblas   conda-forge
  libdeflate                     1.25          h17f619e_0            conda-forge
  libedit                        3.1.20250104  pl5321h7949ede_0      conda-forge
  libexpat                       2.7.4         hecca717_0            conda-forge
  libffi                         3.5.2         h3435931_0            conda-forge
  libfreetype                    2.14.2        ha770c72_0            conda-forge
  libfreetype6                   2.14.2        h73754d4_0            conda-forge
  libgcc                         15.2.0        he0feb66_18           conda-forge
  libgcc-ng                      15.2.0        h69a702a_18           conda-forge
  libgfortran                    15.2.0        h69a702a_18           conda-forge
  libgfortran5                   15.2.0        h68bc16d_18           conda-forge
  libglib                        2.86.4        h6548e54_1            conda-forge
  libgomp                        15.2.0        he0feb66_18           conda-forge
  libiconv                       1.18          h3b78370_2            conda-forge
  libjpeg-turbo                  3.1.2         hb03c661_0            conda-forge
  liblapack                      3.11.0        5_h47877c9_openblas   conda-forge
  liblzma                        5.8.2         hb03c661_0            conda-forge
  libmpdec                       4.0.0         hb03c661_1            conda-forge
  libntlm                        1.8           hb9d3cd8_0            conda-forge
  libopenblas                    0.3.30        pthreads_h94d23a6_4   conda-forge
  libpng                         1.6.55        h421ea60_0            conda-forge
  libpq                          18.3          h9abb657_0            conda-forge
  librdkit                       2025.09.6     h4dfd318_1            conda-forge
  libsodium                      1.0.21        h280c20c_3            conda-forge
  libsqlite                      3.52.0        hf4e2dac_0            conda-forge
  libstdcxx                      15.2.0        h934c35e_18           conda-forge
  libstdcxx-ng                   15.2.0        hdf11a46_18           conda-forge
  libtiff                        4.7.1         h9d88235_1            conda-forge
  libuuid                        2.41.3        h5347b49_0            conda-forge
  libwebp-base                   1.6.0         hd42ef1d_0            conda-forge
  libxcb                         1.17.0        h8a09558_0            conda-forge
  libxcrypt                      4.4.36        hd590300_1            conda-forge
  libzlib                        1.3.1         hb9d3cd8_2            conda-forge
  markupsafe                     3.0.3         py314h67df5f8_1       conda-forge
  matplotlib-base                3.10.8        py314h1194b4b_0       conda-forge
  matplotlib-inline              0.2.1         pyhd8ed1ab_0          conda-forge
  mistune                        3.2.0         pyhcf101f3_0          conda-forge
  munkres                        1.1.4         pyhd8ed1ab_1          conda-forge
  nbclient                       0.10.4        pyhd8ed1ab_0          conda-forge
  nbconvert-core                 7.17.0        pyhcf101f3_0          conda-forge
  nbformat                       5.10.4        pyhd8ed1ab_1          conda-forge
  ncurses                        6.5           h2d0b736_3            conda-forge
  nest-asyncio                   1.6.0         pyhd8ed1ab_1          conda-forge
  networkx                       3.6.1         pypi_0                pypi
  notebook                       7.5.5         pyhcf101f3_0          conda-forge
  notebook-shim                  0.2.4         pyhd8ed1ab_1          conda-forge
  numpy                          2.4.2         py314h2b28147_1       conda-forge
  openjpeg                       2.5.4         h55fea9a_0            conda-forge
  openldap                       2.6.10        hbde042b_1            conda-forge
  openpyxl                       3.1.5         pypi_0                pypi
  openssl                        3.6.1         h35e630c_1            conda-forge
  overrides                      7.7.0         pyhd8ed1ab_1          conda-forge
  packaging                      26.0          pyhcf101f3_0          conda-forge
  pandas                         3.0.1         py314hb4ffadd_0       conda-forge
  pandocfilters                  1.5.0         pyhd8ed1ab_0          conda-forge
  parso                          0.8.6         pyhcf101f3_0          conda-forge
  patsy                          1.0.2         pyhcf101f3_0          conda-forge
  pcre2                          10.47         haa7fec5_0            conda-forge
  pepfunn                        1.0.0         pypi_0                pypi
  pexpect                        4.9.0         pyhd8ed1ab_1          conda-forge
  pillow                         12.1.1        py314h8ec4b1a_0       conda-forge
  pip                            26.0.1        pyh145f28c_0          conda-forge
  pixman                         0.46.4        h54a6638_1            conda-forge
  platformdirs                   4.9.4         pyhcf101f3_0          conda-forge
  prometheus_client              0.24.1        pyhd8ed1ab_0          conda-forge
  prompt-toolkit                 3.0.52        pyha770c72_0          conda-forge
  prompt_toolkit                 3.0.52        hd8ed1ab_0            conda-forge
  psutil                         7.2.2         py314h0f05182_0       conda-forge
  pthread-stubs                  0.4           hb9d3cd8_1002         conda-forge
  ptyprocess                     0.7.0         pyhd8ed1ab_1          conda-forge
  pure_eval                      0.2.3         pyhd8ed1ab_1          conda-forge
  pyPept                         1.0.0         pypi_0                pypi
  pycairo                        1.29.0        py314h9cd037b_1       conda-forge
  pycparser                      2.22          pyh29332c3_1          conda-forge
  pygments                       2.19.2        pyhd8ed1ab_0          conda-forge
  pyparsing                      3.3.2         pyhcf101f3_0          conda-forge
  pysocks                        1.7.1         pyha55dd90_7          conda-forge
  python                         3.14.3        h32b2ec7_101_cp314    conda-forge
  python-dateutil                2.9.0.post0   pyhe01879c_2          conda-forge
  python-fastjsonschema          2.21.2        pyhe01879c_0          conda-forge
  python-gil                     3.14.3        h4df99d1_101          conda-forge
  python-json-logger             2.0.7         pyhd8ed1ab_0          conda-forge
  python-tzdata                  2025.3        pyhd8ed1ab_0          conda-forge
  python_abi                     3.14          8_cp314               conda-forge
  pyyaml                         6.0.3         py314h67df5f8_1       conda-forge
  pyzmq                          27.1.0        py312hda471dd_2       conda-forge
  qhull                          2020.2        h434a139_5            conda-forge
  rdkit                          2025.09.6     py314h13cd500_1       conda-forge
  readline                       8.3           h853b02a_0            conda-forge
  referencing                    0.37.0        pyhcf101f3_0          conda-forge
  reportlab                      4.4.10        pyhcf101f3_1          conda-forge
  requests                       2.32.5        pyhcf101f3_1          conda-forge
  rfc3339-validator              0.1.4         pyhd8ed1ab_1          conda-forge
  rfc3986-validator              0.1.1         pyh9f0ad1d_0          conda-forge
  rfc3987-syntax                 1.1.0         pyhe01879c_1          conda-forge
  rlpycairo                      0.4.0         pyh6c17108_0          conda-forge
  rpds-py                        0.30.0        py314h2e6c369_0       conda-forge
  scikit-learn                   1.8.0         np2py314hf09ca88_1    conda-forge
  scipy                          1.17.1        py314hf07bd8e_0       conda-forge
  seaborn                        0.13.2        hd8ed1ab_3            conda-forge
  seaborn-base                   0.13.2        pyhd8ed1ab_3          conda-forge
  send2trash                     2.1.0         pyha191276_1          conda-forge
  setuptools                     82.0.1        pyh332efcf_0          conda-forge
  six                            1.17.0        pyhe01879c_1          conda-forge
  sniffio                        1.3.1         pyhd8ed1ab_2          conda-forge
  soupsieve                      2.8.3         pyhd8ed1ab_0          conda-forge
  sphinx-jsonschema              1.19.2        pypi_0                pypi
  sqlalchemy                     2.0.48        py314h0f05182_0       conda-forge
  stack_data                     0.6.3         pyhd8ed1ab_1          conda-forge
  statsmodels                    0.14.6        py314hc02f841_0       conda-forge
  terminado                      0.18.1        pyhc90fa1f_1          conda-forge
  texttable                      1.7.0         pypi_0                pypi
  threadpoolctl                  3.6.0         pyhecae5ae_0          conda-forge
  tinycss2                       1.4.0         pyhd8ed1ab_0          conda-forge
  tk                             8.6.13        noxft_h366c992_103    conda-forge
  tomli                          2.4.0         pyhcf101f3_0          conda-forge
  tornado                        6.5.4         py314h7b0bd38_0       conda-forge
  traitlets                      5.14.3        pyhd8ed1ab_1          conda-forge
  typing-extensions              4.15.0        h396c80c_0            conda-forge
  typing_extensions              4.15.0        pyhcf101f3_0          conda-forge
  typing_utils                   0.1.0         pyhd8ed1ab_1          conda-forge
  tzdata                         2025c         hc9c84f9_1            conda-forge
  unicodedata2                   17.0.1        py314h5bd0f2a_0       conda-forge
  uri-template                   1.3.0         pyhd8ed1ab_1          conda-forge
  urllib3                        2.6.3         pyhd8ed1ab_0          conda-forge
  wcwidth                        0.6.0         pyhd8ed1ab_0          conda-forge
  webcolors                      25.10.0       pyhd8ed1ab_0          conda-forge
  webencodings                   0.5.1         pyhd8ed1ab_3          conda-forge
  websocket-client               1.9.0         pyhd8ed1ab_0          conda-forge
  widgetsnbextension             4.0.15        pyhd8ed1ab_0          conda-forge
  xorg-libice                    1.1.2         hb9d3cd8_0            conda-forge
  xorg-libsm                     1.2.6         he73a12e_0            conda-forge
  xorg-libx11                    1.8.13        he1eb515_0            conda-forge
  xorg-libxau                    1.0.12        hb03c661_1            conda-forge
  xorg-libxdmcp                  1.1.5         hb03c661_1            conda-forge
  xorg-libxext                   1.3.7         hb03c661_0            conda-forge
  xorg-libxrender                0.9.12        hb9d3cd8_0            conda-forge
  yaml                           0.2.5         h280c20c_3            conda-forge
  zeromq                         4.3.5         h41580af_10           conda-forge
  zipp                           3.23.0        pyhcf101f3_1          conda-forge
  zlib-ng                        2.3.3         hceb46e0_1            conda-forge
  zstd                           1.5.7         hb78ec9c_6            conda-forge

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions