import multiprocessing as mp
def make_tags(pysam_segment)
read = Seq(pysam_segment.query_sequence)
# do stuff
return(tags)
bam_file = pysam.AlignmentFile(in_file, "rb", check_sq=False)sam_iter = islice(bam_file.fetch(until_eof=True), None, None, 2)with mp.Pool(4) as pool: results = pool.map(make_tags, sam_iter)
TypeError: self._delegate cannot be converted to a Python object for pickling
pool = mp.Pool(1)
results = pool.imap(make_tags, sam_iter)
reads = (x.query_sequence for x in in_bam_iter)with Pool(cores) as pool: tags = pool.map(make_tags, reads)
File "/opt/venv/specter/lib/python3.6/site-packages/dill/dill.py", line 871, in save_module_dict StockPickler.save_dict(pickler, obj) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 821, in save_dict self._batch_setitems(obj.items()) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 847, in _batch_setitems save(v) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 496, in save rv = reduce(self.proto) File "stringsource", line 2, in pysam.libcalignedsegment.AlignedSegment.__reduce_cython__TypeError: self._delegate cannot be converted to a Python object for pickling
from pathos.multiprocessing import Poolfrom pathos.helpers import mpimport pysamfrom itertools import islice
def make_tags(pysam_segment): read = Seq(pysam_segment.query_sequence) # do stuff return(read)
in_file = "test.bam"
bam_file = pysam.AlignmentFile(in_file, "rb", check_sq=False)sam_iter = islice(bam_file.fetch(until_eof=True), None, None, 2)with Pool(4) as pool: results = pool.map(make_tags, sam_iter)
Traceback (most recent call last): File "./test_mp.py", line 16, in <module> results = pool.map(make_tags, sam_iter) File "/opt/venv/specter/lib/python3.6/site-packages/multiprocess/pool.py", line 260, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/opt/venv/specter/lib/python3.6/site-packages/multiprocess/pool.py", line 608, in get raise self._value File "/opt/venv/specter/lib/python3.6/site-packages/multiprocess/pool.py", line 385, in _handle_tasks put(task) File "/opt/venv/specter/lib/python3.6/site-packages/multiprocess/connection.py", line 209, in send self._send_bytes(ForkingPickler.dumps(obj)) File "/opt/venv/specter/lib/python3.6/site-packages/multiprocess/reduction.py", line 53, in dumps cls(buf, protocol).dump(obj) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 409, in dump self.save(obj) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 476, in save f(self, obj) # Call unbound method with explicit self File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 751, in save_tuple save(element) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 476, in save f(self, obj) # Call unbound method with explicit self File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 736, in save_tuple save(element) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 476, in save f(self, obj) # Call unbound method with explicit self File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 736, in save_tuple save(element) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 476, in save f(self, obj) # Call unbound method with explicit self File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 736, in save_tuple save(element) File "/opt/rh/rh-python36/root/usr/lib64/python3.6/pickle.py", line 496, in save rv = reduce(self.proto) File "stringsource", line 2, in pysam.libcalignedsegment.AlignedSegment.__reduce_cython__TypeError: self._delegate cannot be converted to a Python object for pickling
--
You received this message because you are subscribed to the Google Groups "Pysam User group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-gro...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-gro...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-group+unsubscribe@googlegroups.com.
Yes, that is the one. I was specifically thinking of the last comment. I did not try it though. I changed my code so that each job gets the region coordinates and then opens the bam file and fetches the data. It does slow everything down when doing this for hundreds of regions.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Pysam User group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Pysam User group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pysam-user-group+unsubscribe@googlegroups.com.