Skip to main content

fast, simple interval intersection

Project description

https://img.shields.io/badge/install%20with-bioconda-brightgreen.png

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 quicksect

or

conda install -c bioconda quicksect

Use

>>> from quicksect import IntervalNode, Interval, IntervalTree

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quicksect-0.2.2.tar.gz (79.8 kB view details)

Uploaded Source

File details

Details for the file quicksect-0.2.2.tar.gz.

File metadata

  • Download URL: quicksect-0.2.2.tar.gz
  • Upload date:
  • Size: 79.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for quicksect-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d3e65b55b7f48e6105b11b1e1d6f37ccbf8caecfc7d7db7aba73dfaf6d732a9c
MD5 1fb15edbcfba1f1d093e3b1227298db3
BLAKE2b-256 40baa7ec481405e93afcc85b9e051e204d2a32b2f7cad2ae4b6c9fb60e7ecbbe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page