abyzovlab / CNVpytor

a python extension of CNVnator -- a tool for CNV analysis from depth-of-coverage by mapped reads
MIT License
179 stars 26 forks source link

AttributeError: Can't pickle local object 'Root._read_bam.<locals>.read_chromosome' #145

Closed vembuprathima closed 1 month ago

vembuprathima commented 1 year ago

I get the below error when trying to run CNVpytor on my sample

Command: cnvpytor -root NA12878.pytor -rd GM12878.bam

Output: 
[W::hts_idx_load3] The index file is older than the data file: GM12878.bai
2022-10-11 12:49:43,273 - cnvpytor.bam - INFO - File: GM12878.bam successfully open
2022-10-11 12:49:43,279 - cnvpytor.bam - INFO - Detected reference genome: hg38
2022-10-11 12:49:43,293 - cnvpytor.pool - INFO - Parallel processing using 8 cores
Traceback (most recent call last):
  File "/Users/prathimavembu/opt/anaconda3/bin/cnvpytor", line 33, in <module>
    sys.exit(load_entry_point('CNVpytor==1.2.1', 'console_scripts', 'cnvpytor')())
  File "/Users/prathimavembu/.local/lib/python3.9/site-packages/CNVpytor-1.2.1-py3.9.egg/cnvpytor/__main__.py", line 278, in main
  File "/Users/prathimavembu/.local/lib/python3.9/site-packages/CNVpytor-1.2.1-py3.9.egg/cnvpytor/root.py", line 308, in rd
  File "/Users/prathimavembu/.local/lib/python3.9/site-packages/CNVpytor-1.2.1-py3.9.egg/cnvpytor/root.py", line 90, in _read_bam
  File "/Users/prathimavembu/.local/lib/python3.9/site-packages/CNVpytor-1.2.1-py3.9.egg/cnvpytor/pool.py", line 48, in parmap
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/Users/prathimavembu/opt/anaconda3/lib/python3.9/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'Root._read_bam.<locals>.read_chromosome'

Any support would be much appreciated.

Thanks -Prathima Vembu

arpanda commented 1 year ago

By default CNVpytor uses 8 threads (default -j 8 ) to read a bam file. While reading the bam file, the error occurred. I think, the problem is related to multithreading. I am trying to find the reason.

Meanwhile, you may process your bam file in single thread (option -j 1).

Thank You Arijit

Sanat-Mishra commented 1 month ago

Hi, any update on this?

arpanda commented 1 month ago

The issue has been fixed in version 1.3.2, available now on GitHub. To update to the latest version, run the following command:

pip install git+https://github.com/abyzovlab/CNVpytor.git

Thanks Arijit