https://github.com/brentp/quicksect
a cythonized, extended version of the interval search tree in bx
https://github.com/brentp/quicksect
Last synced: 3 months ago
JSON representation
a cythonized, extended version of the interval search tree in bx
- Host: GitHub
- URL: https://github.com/brentp/quicksect
- Owner: brentp
- License: mit
- Created: 2008-10-29T18:34:20.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2019-06-04T16:42:09.000Z (about 6 years ago)
- Last Synced: 2025-03-18T02:12:19.730Z (3 months ago)
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 30
- Watchers: 4
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Quicksect
=========.. image:: https://img.shields.io/badge/install%20with-bioconda-brightgreen.png
:target: http://bioconda.github.io/recipes/quicksect/README.htmlDescription
-----------Quicksect is a fast python / cython implementation of interval search based on the pure python version in
`bx-python `__
I pulled it out, optimized and converted to cython and James Taylor has incoporated it back into bx-python
with his improvements.I have brought this project back from the dead because I want a fast, simple, no-dependencies Interval
tree.License is MIT.
Installation
------------pip install quicksect
or
conda install -c bioconda quicksect
Use
---
>>> from quicksect import IntervalNode, Interval, IntervalTreeMost common use will be via IntervalTree:
>>> tree = IntervalTree()
>>> tree.add(23, 45)
>>> tree.add(55, 66)
>>> tree.search(46, 47)
[]
>>> tree.search(44, 56)
[Interval(55, 66), Interval(23, 45)]>>> tree.insert(Interval(88, 444))
>>> res = tree.find(Interval(99, 100))
>>> res
[Interval(88, 444)]
>>> res[0].start, res[0].end
(88, 444)Thats pretty much everything you need to know about the tree.
Test
----$ python setup.py test
Low-Level
+++++++++In some cases, users may want to utilize the lower-level interface that accesses
the nodes of the tree:>>> inter = IntervalNode(Interval(22, 33))
>>> inter = inter.insert(Interval(44, 55))
>>> inter.intersect(24, 26)
[Interval(22, 33)]>>> inter.left(Interval(34, 35), n=1)
[Interval(22, 33)]>>> inter.right(Interval(34, 35), n=1)
[Interval(44, 55)]