{ "info": { "author": "Brent S Pedersen", "author_email": "bpederse@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Scientific/Engineering :: Bio-Informatics" ], "description": "InterLap: simple, fast interval overlap testing\n-----------------------------------------------\n[![Build Status](https://travis-ci.org/brentp/interlap.svg?branch=master)](https://travis-ci.org/brentp/interlap)\n\nInterLap is >20 times faster than doing a naive search (see: https://brentp.github.io/interlap/benchmark.html)\nwith **no memory overhead** because it operates on a sorted list. It is pure python and has no\ndependencies.\n\nIt uses binary search and a knowledge of the longest observed interval to quickly query datasets\nwith 100's of thousands of intervals.\n\nSee the documentation at [https://brentp.github.io/interlap/](https://brentp.github.io/interlap)\n\nUsage\n-----\n\nInterlap takes tuples or lists where the first 2 elements are start, end and the remaining\nelements can be anything.\n\n\n```Python\n>>> from interlap import InterLap\n>>> inter = InterLap()\n\n#Here create 10K random intervals:\n\n>>> import random\n>>> random.seed(42)\n>>> sites = random.sample(range(22, 100000000, 12), 50000)\n>>> ranges = [(i, i + random.randint(2000, 20000)) for i in sites]\n\n>>> inter.update(ranges)\n>>> inter.add((20, 22, {'info': 'hi'}))\n\n>>> [20, 21] in inter\nTrue\n\n>>> next(inter.find((21, 21)))\n(20, 22, {'info': 'hi'})\n\n>>> inter.add((2, 3, {'info': 'hello'}))\n\n*NOTE*: below shows how edge-cases are handled.\n>>> list(inter.find((2, 2)))\n[(2, 3, {'info': 'hello'})]\n>>> list(inter.find((3, 3)))\n[(2, 3, {'info': 'hello'})]\n\nTest every item in the InterLap. These 50K queries take < 0.5 seconds:\n\n>>> for s, e in ranges:\n... assert (s, e) in inter\n\nInterLap objects are iterable:\n\n>>> for seo in inter:\n... assert (seo[0], seo[1]) in inter\n\n```\n\nInstallation\n------------\n\n```Shell\n\npip install interlap\n\n```\n\nExample\n-------\n\nIn general, we will want one interlap per chromosome for genomic data.\nThe snippet below shows a simple way to do that in the process of creating\nand then querying some intervals.\n\n```Python\n\nfrom interlap import InterLap\nfrom collections import defaultdict\nimport sys\n\n# use defaultdict to key by chromosome.\ninter = defaultdict(InterLap)\n\nfor toks in (x.rstrip().split(\"\\t\") for x in open(sys.argv[1])):\n start, end = map(int, toks[1:3])\n inter[toks[0]].add((start, end, toks))\n\n# now find overlaps in another file:\n\nfor toks in (x.rstrip().split(\"\\t\") for x in open(sys.argv[2])):\n start, end = map(int, toks[1:3])\n\n print list(inter[toks[0]].find((start, end)))\n\n```\n\nWhy\n---\n\nI am aware of bx-python's interval tree (I wrote the cython version)\nbut for some projects it is nice to have a simple dependency (or no\ndependency since this can be included as a single file or 30 lines\nof code) when we just need something a bit better than naive overlap\ntesting.\n\nIn my testing, the method implemented here, using a sorted list and keeping\ntrack of the longest observed interval is the fastest *pure python* method\n*as long as the longest observed interval is does not cover a substantial \nfraction of intervals in the set*.\n\n\nIntervalSet Operations\n----------------------\n\nAs of version 0.2.0 Interlap also includes an `Interval` class that behaves\nlike what is normally called an interval set.\n\n```python\n\n# note how it merges overlapping sub-intervals.\n>>> Interval([(1, 95), (95, 100)]).add(Interval([(90, 100)]))\nInterval([(1, 100)])\n\n```\n\nSee the doctests under the Interval class for more details\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://brentp.github.io/interlap", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "interlap", "package_url": "https://pypi.org/project/interlap/", "platform": "", "project_url": "https://pypi.org/project/interlap/", "project_urls": { "Homepage": "http://brentp.github.io/interlap" }, "release_url": "https://pypi.org/project/interlap/0.2.6/", "requires_dist": null, "requires_python": "", "summary": "interlap: fast, simple interval overlap testing", "version": "0.2.6" }, "last_serial": 3153616, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ae45e85cb5981d1c462c5009c490a95b", "sha256": "64484f4d2c2457f66dda6da34377719850e29929e52e6deabca827d8554d039f" }, "downloads": -1, "filename": "interlap-0.1.tar.gz", "has_sig": false, "md5_digest": "ae45e85cb5981d1c462c5009c490a95b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4105, "upload_time": "2014-09-29T00:53:28", "url": "https://files.pythonhosted.org/packages/bd/48/a8883e149b13a38da711607bb0a6123b5e52bea8cfb0a96e5694f41a4057/interlap-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "81a26830e9b30a506ec183cdc408ac4f", "sha256": "16d8dee9ec34f3a688ac954858b02ad60a1d69522e71b33394f3a44a259b4a38" }, "downloads": -1, "filename": "interlap-0.1.1.tar.gz", "has_sig": false, "md5_digest": "81a26830e9b30a506ec183cdc408ac4f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4109, "upload_time": "2014-09-29T13:40:18", "url": "https://files.pythonhosted.org/packages/9d/fb/95bf0d41e1cfef9fa2279439bc797c9b8483c3534cee6ca114553692df67/interlap-0.1.1.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "8a558620180989f2622234346ad38203", "sha256": "07096256cd5888d2272b5075b9e7d10dcfac33568dac99bf8ae02f9e75d1b343" }, "downloads": -1, "filename": "interlap-0.1.3.tar.gz", "has_sig": false, "md5_digest": "8a558620180989f2622234346ad38203", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4604, "upload_time": "2015-08-24T02:33:59", "url": "https://files.pythonhosted.org/packages/09/53/1a8f603f82bafa74a98d1c0a23d37ed53c660314e7a435bf6ad60c5369fd/interlap-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "144e285379735006098a0274d585c7f2", "sha256": "8fcd55ebed155999b0433e6865d34178f81fd6982a0e0372acb3eda254406355" }, "downloads": -1, "filename": "interlap-0.2.0.tar.gz", "has_sig": false, "md5_digest": "144e285379735006098a0274d585c7f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5895, "upload_time": "2016-05-17T20:08:20", "url": "https://files.pythonhosted.org/packages/89/39/db158fe2041c55c9b9fbdd12a5925964bd3dca253d05060960ae635e9cfa/interlap-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "ecd36602cbecc5182fb29bf11459663d", "sha256": "a5a40f28df1c4f49c9897efd54c81eae0f2048d00fa94f599c3b21d98ecaffb8" }, "downloads": -1, "filename": "interlap-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ecd36602cbecc5182fb29bf11459663d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6041, "upload_time": "2016-05-17T21:07:00", "url": "https://files.pythonhosted.org/packages/00/7f/c9ea5ab131014098b55a6ba307e49e536e035e9b5ddf3eeed8da7b69ef5d/interlap-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "313909ab8ae6e5bb36084c237d09d95f", "sha256": "eb2c8458ab3f2f6dc3498e0fdd66c4e9e401205ac8d8ddafc7296c07d582e158" }, "downloads": -1, "filename": "interlap-0.2.2.tar.gz", "has_sig": false, "md5_digest": "313909ab8ae6e5bb36084c237d09d95f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6066, "upload_time": "2016-05-17T21:11:15", "url": "https://files.pythonhosted.org/packages/f4/f0/888791e7199f70ce1c8966d7b8de2675ccb140d9aa0fc8d7cdfb36f616b2/interlap-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "2b05898582a96baf106b601194d81128", "sha256": "d148c319273283c366c0380074204fe3952a3476ba407773510c81dde4d1390e" }, "downloads": -1, "filename": "interlap-0.2.3.tar.gz", "has_sig": false, "md5_digest": "2b05898582a96baf106b601194d81128", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6148, "upload_time": "2016-12-09T03:04:11", "url": "https://files.pythonhosted.org/packages/4d/0b/6afd990689145e9469bf4c09b86830e1340ea1af58751a2606824a4007ba/interlap-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "97563ab99b2170a011735a1b3be30b83", "sha256": "58166b72906e50ccbfa4cc2385f38aa086f595297a217916553d0f99141b0ebf" }, "downloads": -1, "filename": "interlap-0.2.4.tar.gz", "has_sig": false, "md5_digest": "97563ab99b2170a011735a1b3be30b83", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6384, "upload_time": "2017-03-29T22:04:23", "url": "https://files.pythonhosted.org/packages/39/b2/14bfe0648d503c797146023e80925adf8c4c69e649767d9b0b2c5f1a2983/interlap-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "b96a3b638a81fe95b3ab493c41073b35", "sha256": "59b8c62fc3f41763374acdfa83d270cf5661e64ea8e7501a8f9ec3478613d4c8" }, "downloads": -1, "filename": "interlap-0.2.5.tar.gz", "has_sig": false, "md5_digest": "b96a3b638a81fe95b3ab493c41073b35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5364, "upload_time": "2017-03-31T17:12:36", "url": "https://files.pythonhosted.org/packages/7b/ad/49ddd65effedb47b7ea934748f3777a2f7d8a31d0c9fe9e976726b38eacc/interlap-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "17297414f47ad7d719d232e0d79604f1", "sha256": "a8585a165bf7e94d4d262811b4cb00674059414c50afc7561c949b0feb78fa09" }, "downloads": -1, "filename": "interlap-0.2.6.tar.gz", "has_sig": false, "md5_digest": "17297414f47ad7d719d232e0d79604f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6037, "upload_time": "2017-09-06T14:05:37", "url": "https://files.pythonhosted.org/packages/fd/c6/fc16278afe4c9902a33747e6d1f29760693cb6c15904b3b0c1af99130db7/interlap-0.2.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "17297414f47ad7d719d232e0d79604f1", "sha256": "a8585a165bf7e94d4d262811b4cb00674059414c50afc7561c949b0feb78fa09" }, "downloads": -1, "filename": "interlap-0.2.6.tar.gz", "has_sig": false, "md5_digest": "17297414f47ad7d719d232e0d79604f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6037, "upload_time": "2017-09-06T14:05:37", "url": "https://files.pythonhosted.org/packages/fd/c6/fc16278afe4c9902a33747e6d1f29760693cb6c15904b3b0c1af99130db7/interlap-0.2.6.tar.gz" } ] }