ete icon indicating copy to clipboard operation
ete copied to clipboard

RecursionError: maximum recursion depth exceeded while pickling an object

Open lafranco opened this issue 3 years ago • 2 comments

Hi, I'm trying to use the ete3 evol tool to calculate dN/dS for some samples. I was trying to use etetoolkit because of the multithread option. But when I try to run this error appears: Running CodeML/Slr (4 CPUs)

  • processing model XX.codeml.ctl (XX.codeml.ct~4aca7950c372eceb5afbfc6622e9cb35) Traceback (most recent call last): File "/home/augfranco/anaconda3/envs/ete3/lib/python3.6/site-packages/ete3", line 33, in sys.exit(load_entry_point('ete3==3.1.2', 'console_scrips', 'ete3')()) File "/home/augfranco/anaconda3/envs/ete3/lib/python3.6/site-packages/ete3/tools/ete.py", line 95, in main_main(sys.argv) File "/home/augfranco/anaconda3/envs/ete3/lib/python3.6/site-packages/ete3/tools/ete.py", line 269, in _mainargs.func(args) File "/home/augfranco/anaconda3/envs/ete3/lib/python3.6/site-packages/ete3/tools/ete_evol.py", line 899, in run models.update(run_all_models(tree,nodes,marks, args, **params)) File "/home/augfranco/anaconda3/envs/ete3/lib/python3.6/site-packages/ete3/tools/ete_evol.py", line 542, in run_all_models local_run_model, args=(tree.copy(),model, binary), File "/home/augfranco/anaconda3/envs/ete3/lib/python3.6/site-packages/ete3/coretype&tree.py", line 1440, in copy new_node= six.moves.cPickle.loads(six.modes.cPickle.dumps(self,2)) ReursionError: maximum recursion depth exceeded while pickling an object

I want to know how can I solve this, or if this is a dependency problem. Thank you for your help.

AF

lafranco avatar Feb 07 '22 11:02 lafranco

Hi! RecursionError means that some recursive function exceeded the recursion limit. You can check, how big this limit is by running:

import sys
print(sys.getrecursionlimit())

You may increase it by running sys.setrecursionlimit(5000) (or any other number) and then run the code again. Be careful, as the memory usage can grow

VladimirShitov avatar Feb 16 '22 12:02 VladimirShitov

Had the same question, and this solved it! Thanks so much.

As a follow-up question, this error occurs for me when I make a copy of a tree. I have 50 trees that are built on identical sequences (same number of leaves, n=6052) but differ in topology (low signal dataset). The following code works for the first 48 trees, then triggers the recursion error for tree 49:

>>> from ete3 import Tree
>>> tree_node = Tree("plausible_tree49.newick")
>>> tree_node_copy = tree_node.copy()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../ete3/coretype/tree.py", line 1440, in copy
    new_node = six.moves.cPickle.loads(six.moves.cPickle.dumps(self, 2))
RecursionError: maximum recursion depth exceeded while pickling an object

Thus, I want to query your wisdom on what specifically causes this, particularly given it works for other trees with the same number of leaves? My best guess is that it must be the particular branching pattern of the tree, e.g., it happens to have a greater maximum leaf-to-root node depth?

Thanks so much for any insight! Chase

singing-scientist avatar Dec 12 '22 04:12 singing-scientist