Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: Maximum Recursion Depth Exceeded in mk_prepare_ligand.py #269

Closed
hezhizhang-269 opened this issue Dec 8, 2024 · 4 comments
Closed
Assignees

Comments

@hezhizhang-269
Copy link

Hello,

When I was running mk_prepare_ligand.py to process a large .sdf file, the script encounters a RecursionError, indicating that the maximum recursion depth has been exceeded. This error appears to occur during the molecule's ring perception process, preventing successful preparation of the ligand.

The input .sdf file is attached here 3v7e_model1_aptamer_Model_1_with_heterogeneous_atoms_removedH_no_valence_issue_3.sdf.txt.

The command I used to run the script and the outputs were as follows:

caomq@cscigpu06:~/3v7e$ mk_prepare_ligand.py -i 3v7e_model1_aptamer_Model_1_with_heterogeneous_atoms_removedH_no_valence_issue_3.sdf -o 3v7e_model1_aptamer_Model_1_with_heterogeneous_atoms_removedH_no_valence_issue_3.pdbqt
/home/caomq/.local/lib/python3.8/site-packages/scipy/fft/__init__.py:97: DeprecationWarning: The module numpy.dual is deprecated.  Instead of using dual, use the functions directly from numpy or scipy.
  from numpy.dual import register_func
/home/caomq/.local/lib/python3.8/site-packages/scipy/special/orthogonal.py:81: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  from numpy import (exp, inf, pi, sqrt, floor, sin, cos, around, int,
/home/caomq/.local/lib/python3.8/site-packages/pandas/core/computation/expressions.py:20: UserWarning: Pandas requires version '2.7.3' or newer of 'numexpr' (version '2.7.1' currently installed).
  from pandas.core.computation.check import NUMEXPR_INSTALLED
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, imp, stat
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (2.0.4) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
/usr/lib/python3/dist-packages/requests/__init__.py:95: DeprecationWarning: 'urllib3.contrib.pyopenssl' module is deprecated and will be removed in urllib3 v2.1.0. Read more in this issue: https://github.com/urllib3/urllib3/issues/2680
  from urllib3.contrib import pyopenssl
Traceback (most recent call last):
  File "/home/caomq/.local/bin/mk_prepare_ligand.py", line 354, in <module>
    molsetups = preparator.prepare(mol)
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/preparation.py", line 139, in prepare
    setup = setup_class.from_mol(mol,
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/molsetup.py", line 543, in from_mol
    molsetup.perceive_rings(keep_chorded_rings, keep_equivalent_rings)
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/molsetup.py", line 461, in perceive_rings
    graph[atom_idx] = self.walk_recursive(atom_idx, collected=[], exclude=list(ring_atom_idxs))
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/molsetup.py", line 387, in walk_recursive
    self.walk_recursive(neigh, collected, exclude)
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/molsetup.py", line 387, in walk_recursive
    self.walk_recursive(neigh, collected, exclude)
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/molsetup.py", line 387, in walk_recursive
    self.walk_recursive(neigh, collected, exclude)
  [Previous line repeated 992 more times]
  File "/home/caomq/.local/lib/python3.8/site-packages/meeko/molsetup.py", line 382, in walk_recursive
    for neigh in self.get_neigh(idx):
RecursionError: maximum recursion depth exceeded

Appreciate in advance for any guidance or recommendations you could provide.

@rwxayheee
Copy link
Contributor

Hi @hezhizhang-269
As @diogomart said in the other issue, first you might need the latest version of Meeko. Next, run mk_prepare_ligand.py will suggest that "RDKit molecule has implicit Hs. Need explicit Hs.". Your input is a sanitizable SDF file but there is one carbon atom (id 261) that is missing two hydrogens. After adding hydrogens, you might have to increase the system's recursion limit to be able to generate the PDBQT file. Adding this line to the command-line script mk_prepare_ligand.py
worked for me to process this input file.

sys.setrecursionlimit(3000)

@hezhizhang-269
Copy link
Author

Thank you so much for your help! This line of code solves the recursion error.

@diogomart
Copy link
Contributor

@rwxayheee we might be able to remove those lines of code. They compute a graph that is stored in instances of Ring. I think those graphs are never used, along with other attributes that are probably also never used, see #109 (comment)

@rwxayheee
Copy link
Contributor

Sounds great! I will take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants