fast, simple interval intersection
Project description
Description
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 quicksectx
or
conda install -c bioconda quicksectx
Use
>>> from quicksectx 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.
Most 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.
Most 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.
Most 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.
Most 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.
Most 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.
Most 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.
Most 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)]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for quicksectx-0.2.2a9-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4813f17bf41934c73c947c57664f156eafe3486e40e49d39378080d95dec426f |
|
MD5 | c9a1b74f39923b82d7e23afc9fa72ca8 |
|
BLAKE2b-256 | f477d34f4391677691e33a1f3121002fa19c21a2df83d63ae608e1ba0086dc0d |
Hashes for quicksectx-0.2.2a9-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dee6dc7dede57a9c0e571440ac6a90da8b79f303df507bc93ebbb096491238d |
|
MD5 | 2fc6002cf8db030496be1cdcd9821d4e |
|
BLAKE2b-256 | f83432e4c861cd3af2202925a8c9870c9c044090353604df8bf4d5df6b9bf4e0 |
Hashes for quicksectx-0.2.2a9-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e2241bd4544edf6d23e0107c231c30b0a1a60b40c7b6218e7591d0301cff2cf |
|
MD5 | 12dc79d91a435c15d57065c51cd45c93 |
|
BLAKE2b-256 | 8792068f35a96d024f0e1fff746870f53b7f6288fbbb17259f62cbf3cc41dbdf |
Hashes for quicksectx-0.2.2a9-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e46264830ca97db767c12866c35de4fa1e419ce0649512321985dc285af5bbd |
|
MD5 | 04c930be6de091fbd562a6ddcdc9ad42 |
|
BLAKE2b-256 | 081c1b742e1bddca0e24a928f1ddbabd61791cd95938d434e6a00c3aeef9d0cb |
Hashes for quicksectx-0.2.2a9-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 115ada094a000c1ca6734e76937e809c6f56e6818b3ccce8fb790d44e1f08de2 |
|
MD5 | 529841a761e71d492304456a34a95b54 |
|
BLAKE2b-256 | 8b89632b089c7f29f7e3bef0fc081570f65f21bbb0ea8eccd257b16a626e4e49 |
Hashes for quicksectx-0.2.2a9-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79ce370da1cef7b2926c17a04e9c9103020a57f95b64502b4d06c459069f1686 |
|
MD5 | cc1561dec5ca4a23a110a3a4e737e20a |
|
BLAKE2b-256 | 9b6fc974d15d6324128af80b026356765493d30122b1dfd0c3559b75de1f4835 |
Hashes for quicksectx-0.2.2a9-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f5881835a5aad716d64a519d73b606c5e0da3b026667a4ad8ce015ac0f3b985 |
|
MD5 | d0c582dcac1f46681e9b4b3442109f4c |
|
BLAKE2b-256 | b349f1d928ae0fd1b08caf7270c17e34b7e1bf617b3f148537b4e03f064ae8e3 |
Hashes for quicksectx-0.2.2a9-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10548d6d63ada4860b231b69627d87c35f42e425d5a293532574f1d35d1a8082 |
|
MD5 | 6f4082cef6743b15220924f34b24611f |
|
BLAKE2b-256 | 67f9ff2689d9ffc00f08f602b756cea2d1e528bdc3b381493cd9932f48ae8336 |
Hashes for quicksectx-0.2.2a9-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 153a66f240823c48cad4e574084133a7cb211272c7b1bfa76fe9d521ced9317a |
|
MD5 | 7906fba87d7c0b381772f5d10e08d86d |
|
BLAKE2b-256 | f8d1eb0bf42f3a9ede8c18716afb4497fb0052d1459b7ba200636698ec94e421 |