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 Distribution
Built Distributions
Hashes for quicksectx-0.2.2b2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | def674d9445c6e0d8eb5f1582da9e4dc32e4a6a514b2391ac2e65c5489390e95 |
|
MD5 | 5c2d1085cbd4542b6270839e51111121 |
|
BLAKE2b-256 | 2adc8312dfc93d2d627b7b90fd7e9e7af4f117d1b5d84fa78447d8f3c437fd42 |
Hashes for quicksectx-0.2.2b2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7dc1914827888fc84c4e176b2b0e96fbc60cf03a7141ec98c61a51d04e7df19 |
|
MD5 | b30bcb902443f49ad05256f9bd69633c |
|
BLAKE2b-256 | aa56886a38e2abccafb8d7b2a89bfb85d4dd917713b8544ed26fde1fa7f3186e |
Hashes for quicksectx-0.2.2b2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbfa3e3909c63154e9025ead226fccf86a19c3e43b17ab5dc3be24aa75f29e23 |
|
MD5 | 2332b8ce98db0652ee2c283c46285491 |
|
BLAKE2b-256 | b8f6b83cf86d990e1f5282a21de7d3ab1b470418ba51d454d7cc530e520946c5 |
Hashes for quicksectx-0.2.2b2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b857d659d112543765ba89c5862add665d25e4362243d1535ee4599a3d990156 |
|
MD5 | 22245b147dc4115d786520080e94df26 |
|
BLAKE2b-256 | f42cc32043a1f22a9f1ae502aba2a05c8a5eaa0c67ec42da5d2adb65d99fa27f |
Hashes for quicksectx-0.2.2b2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a62b02e851f0c4bb52e6109cb494744ee72c66afc188f7baeaa98c567a7c08e2 |
|
MD5 | 11a04f73f0ed1f602a662283ec9adb72 |
|
BLAKE2b-256 | b7f36a67bfbef8bac763a9ae4856b729352de45c3334c3c76826463d79e9d197 |
Hashes for quicksectx-0.2.2b2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa861c504ff8c78a0ddb59e0ccad2188982edf8bf100daa598f826b146285a8f |
|
MD5 | daafef0504ec29c175391a27cf0cafb8 |
|
BLAKE2b-256 | bdc9e1a7c10caf6b0eefd04bfc8e518b7dfbf4f6b2aa5c61e075e6906ff135de |
Hashes for quicksectx-0.2.2b2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b5b7d6ce738a612a61f50e6a561c489c17843babc1ba03cdc4cd29b1cde77b2 |
|
MD5 | 6e019fb5fb61922ee66b5aa6e4ca74c9 |
|
BLAKE2b-256 | 72391acdbedc573791071dd9c91f82989abae17cc052f707a03954cbb5441964 |
Hashes for quicksectx-0.2.2b2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c84e36c3a53439ed61e4b0e430b08bc36dac6b584f72e9f20f329e84337e0d0a |
|
MD5 | 4ca011d0784a9ae6ddcb79ee15665fee |
|
BLAKE2b-256 | 8427ef666e680db14969298060475d9f8ba8cba9547d1ded1b56860c37ad2fa6 |
Hashes for quicksectx-0.2.2b2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44d2e899835a448753fdfc328703fdb72c0acf49d98fd6b023cda21ed725e51a |
|
MD5 | e7b0df3083b7074858c814acc60130b0 |
|
BLAKE2b-256 | 86392144cec256bc489b911a877d06f688545c169781b18b3b09028c11c578ec |