Open tparket opened 1 year ago
Great to hear you find pybedtools useful.
Can you provide an example of the files you're using for a
and b
so I can test locally?
Thanks for getting back to me so soon. Please find the files* attached.
*these are not the original files, but randomly generated intervals. Nevertheless, I’m getting the same errors.
I'm getting the same error. Have there been any updates to fix this issue?
Bumping this. Might be a Python versioning issue.
Prior to Python 3.7, the StopIteration
raised by the generator (parallel_apply()
) would have just signaled the end of the iteration. Starting in Python 3.7, a StopIteration
raised by a generator is converted into a RuntimeError
: see https://docs.python.org/3/library/exceptions.html#StopIteration
A workaround that seems to work for now is to:
Comment out these 2 lines in the close_or_delete()
function from helpers.py
if hasattr(x.fn, "throw"):
x.fn.throw(StopIteration)
Replace the 2 instances (here and here) of raise StopIteration
in BedTool.parallel_apply()
with a simple return
.
I'm happy to submit a pull request, but this may be part of a larger issue of dealing with Python versions in pybedtools.
Hi,
First of all - thank you for your amazing work. pybedtools has been super useful for my research so far and I am very grateful.
I'm trying to run 'randomstats' with the following args:
results_dict = a.randomstats(b, iterations=1000, new=True, genome_fn=chromsizes_fn, processes=4, shuffle_kwargs={"chrom": True}, intersect_kwargs={"f": 1})
`--------------------------------------------------------------------------- StopIteration Traceback (most recent call last) ~/.local/lib/python3.7/site-packages/pybedtools/bedtool.py in parallel_apply(self, iterations, func, func_args, func_kwargs, processes, _orig_pool) 2932 for it in range(iterations): -> 2933 yield func(*func_args, **func_kwargs) 2934 raise StopIteration
~/.local/lib/python3.7/site-packages/pybedtools/stats.py in random_intersection(x, y, genome_fn, shuffle_kwargs, intersect_kwargs) 16 result = len(zz) ---> 17 helpers.close_or_delete(z, zz) 18 return result
~/.local/lib/python3.7/site-packages/pybedtools/helpers.py in close_or_delete(*args) 547 if hasattr(x.fn, "throw"): --> 548 x.fn.throw(StopIteration) 549
StopIteration:
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)