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

Cannot create a BedTool object from list of regions that uses np.int64 coordinates #390

Closed
aksarkar opened this issue Jun 30, 2023 · 0 comments

Comments

@aksarkar
Copy link

The following minimal example raises an exception

mamba create -yqn test conda-forge::python=3.9 bioconda::pybedtools=0.9.0 conda-forge::numpy=1.19
## Preparing transaction: ...working... done
## Verifying transaction: ...working... done
## Executing transaction: ...working... done
conda run -n test python -c "import numpy as np, pybedtools; pybedtools.BedTool([['chr1', np.int64(1), np.int64(2)]])"
## Traceback (most recent call last):
##   File "<string>", line 1, in <module>
##   File "/home/ec2-user/mambaforge3/envs/test/lib/python3.9/site-packages/pybedtools/bedtool.py", line 589, in __init__
##     fn = BedTool(iter(fn)).saveas().fn
##   File "/home/ec2-user/mambaforge3/envs/test/lib/python3.9/site-packages/pybedtools/bedtool.py", line 923, in decorated
##     result = method(self, *args, **kwargs)
##   File "/home/ec2-user/mambaforge3/envs/test/lib/python3.9/site-packages/pybedtools/bedtool.py", line 3362, in saveas
##     fn = self._collapse(
##   File "/home/ec2-user/mambaforge3/envs/test/lib/python3.9/site-packages/pybedtools/bedtool.py", line 1422, in _collapse
##     for i in iterable:
##   File "pybedtools/cbedtools.pyx", line 793, in pybedtools.cbedtools.IntervalIterator.__next__
##   File "pybedtools/cbedtools.pyx", line 657, in pybedtools.cbedtools.create_interval_from_list
##   File "pybedtools/cbedtools.pyx", line 579, in pybedtools.cbedtools.isdigit
## AttributeError: 'numpy.int64' object has no attribute 'isdigit'
## 
## ERROR conda.cli.main_run:execute(47): `conda run python -c import numpy as np,pybedtools; pybedtools.BedTool([['chr1', np.int64(1), np.int64(2)]])` failed. (See above for error)

The reason appears to be that numpy integer types are not correctly handled https://github.com/daler/pybedtools/blob/master/pybedtools/cbedtools.pyx#L576

I ran into the same problem as #362 and I think this is the root cause.

@daler daler closed this as completed in 936f10a Aug 13, 2023
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

1 participant