{ "info": { "author": "Chaim-Leib Halbert, Konstantin Tretyakov", "author_email": "kt@ut.ee", "bugtrack_url": null, "classifiers": [ "Development Status :: 7 - Inactive", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Programming Language :: Python", "Topic :: Scientific/Engineering :: Bio-Informatics", "Topic :: Software Development :: Libraries" ], "description": "==============\nPyIntervalTree\n==============\n\n NB: This package **is deprecated**. Please, use the ``intervaltree`` package instead (available via `Github `__ or `PyPI `__).\n \n The genome-related functionality is extracted to the ``intervaltree-bio`` package (`Github `__, `PyPI `__).\n \n **No future versions of this package are planned. Do not file issues.**\n\nA mutable, self-balancing interval tree. Queries may be by point, by range \noverlap, or by range envelopment.\n\nThis library was designed to allow tagging text and time intervals, where the\nintervals include the lower bound but not the upper bound.\n\nInstallation\n------------\n\nThe easiest way to install most Python packages is via ``easy_install`` or ``pip``::\n\n $ pip install PyIntervalTree\n\nFeatures\n--------\n\n* Initialize blank or from an iterable of Intervals in O(n * log n).\n* Insertions\n\n * ``tree[begin:end] = data``\n * ``tree.add(interval)``\n * ``tree.addi(begin, end, data)``\n * ``tree.extend(list_of_interval_objs)``\n\n* Deletions\n\n * ``tree.remove(interval)`` (raises ``ValueError`` if not present)\n * ``tree.discard(interval)`` (quiet if not present)\n * ``tree.removei(begin, end, data)``\n * ``tree.discardi(begin, end, data)``\n * ``tree.remove_overlap(point)``\n * ``tree.remove_overlap(begin, end)`` (removes all overlapping the range)\n * ``tree.remove_envelop(begin, end)`` (removes all enveloped in the range)\n\n* Overlap queries:\n\n * ``tree[point]``\n * ``tree[begin:end]``\n * ``tree.search(point)``\n * ``tree.search(begin, end)``\n\n* Envelop queries:\n\n * ``tree.search(begin, end, strict = True)``\n\n* Membership queries:\n\n * ``interval_obj in tree`` (this is fastest, O(1))\n * ``tree.containsi(begin, end, data)``\n * ``tree.overlaps(point)``\n * ``tree.overlaps(begin, end)``\n\n* Iterable:\n\n * ``for interval_obj in tree:``\n * ``tree.items()``\n\n* Sizing:\n\n * ``len(tree)``\n * ``tree.is_empty()``\n * ``not tree``\n * ``tree.begin()`` (the smallest coordinate of the leftmost interval)\n * ``tree.end()`` (the ``end`` coordinate of the rightmost interval)\n\n* Restructuring\n\n * ``split_overlaps()``\n\n* Copy- and typecast-able:\n\n * ``IntervalTree(tree)`` (``Interval`` objects are same as those in tree)\n * ``tree.copy()`` (``Interval`` objects are shallow copies of those in tree)\n * ``set(tree)`` (can later be fed into ``IntervalTree()``)\n * ``list(tree)`` (ditto)\n\n* Equal-able\n* Pickle-friendly\n* Automatic AVL balancing\n \nExamples\n--------\n\n* Getting started::\n\n from intervaltree import Interval, IntervalTree\n t = IntervalTree()\n\n* Adding intervals - you don't have to use strings!::\n\n t[1:2] = \"1-2\"\n t[4:7] = \"4-7\"\n t[5:9] = \"5-9\"\n\n* Query by point::\n\n ivs = t[6] # set([Interval(4, 7, '4-7'), Interval(5, 9, '5-9')])\n iv = sorted(ivs)[0] # Interval(4, 7, '4-7')\n \n* Accessing an ``Interval`` object::\n\n iv.begin # 4\n iv.end # 7\n iv.data # \"4-7\"\n \n* Query by range:\n\n Note that ranges are inclusive of the lower limit, but non-inclusive of the\n upper limit. So::\n\n t[2:4] # set([])\n\n But::\n\n t[1:5] # set([Interval(1, 2, '1-2'), Interval(4, 7, '4-7')])\n\n* Constructing from lists of ``Interval``'s:\n\n We could have made the same tree this way::\n\n ivs = [ [1,2], [4,7], [5,9] ]\n ivs = map( lambda begin,end: Interval(begin, end, \"%d-%d\" % (begin,end), \n *zip(*ivs) )\n \n t = IntervalTree(ivs)\n\n* Removing intervals::\n\n t.remove( Interval(1, 2, \"1-2\") )\n list(t) # [Interval(4, 7, '4-7'), Interval(5, 9, '5-9')]\n \n t.remove( Interval(500, 1000, \"Doesn't exist\") # raises ValueError\n t.discard(Interval(500, 1000, \"Doesn't exist\") # quietly does nothing\n \n t.remove_overlap(5) \n list(t) # []\n\n We could also empty a tree by removing all intervals, from the lowest bound\n to the highest bound of the ``IntervalTree``::\n \n t.remove_overlap(t.begin(), t.end())\n\nUsage with Genomic Data\n-----------------------\n\nInterval trees are especially commonly used in bioinformatics, where intervals correspond to genes or various features along the genome. Such intervals are commonly stored in ``BED``-format files. To simplify working with such data, the package ``intervaltree.bio`` provides a ``GenomeIntervalTree`` class.\n\n``GenomeIntervalTree`` is essentially a ``dict`` of ``IntervalTree``-s, indexed by chromosome names::\n\n gtree = GenomeIntervalTree()\n gtree['chr1'].addi(10000, 20000)\n \nThere is a convenience function for adding intervals::\n\n gtree.addi('chr2', 20000, 30000)\n \nYou can create a ``GenomeIntervalTree`` instance from a ``BED`` file::\n\n test_url = 'http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgTfbsUniform/wgEncodeAwgTfbsBroadDnd41Ezh239875UniPk.narrowPeak.gz'\n data = zlib.decompress(urlopen(test_url).read(), 16+zlib.MAX_WBITS)\n gtree = GenomeIntervalTree.from_bed(StringIO(data))\n \nIn addition, special functions are offered to read in `UCSC tables of gene positions `_:\n\n* Load the UCSC ``knownGene`` table with each interval corresponding to gene's transcribed region::\n\n knownGene = GenomeIntervalTree.from_table()\n \n* Load the UCSC ``refGene`` table with each interval corresponding to gene's coding region::\n\n url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/refGene.txt.gz'\n refGene = GenomeIntervalTree.from_table(url=url, parser=UCSCTable.REF_GENE, mode='cds')\n \n* Load the UCSC ``ensGene`` table with each interval corresponding to a gene's exon::\n\n url = 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/database/ensGene.txt.gz'\n ensGene = GenomeIntervalTree.from_table(url=url, parser=UCSCTable.ENS_GENE, mode='exons') \n\nYou may add methods for parsing your own tabular files with genomic intervals, see the documentation for ``GenomeIntervalTree.from_table``.\n\nBased on\n--------\n\n * Eternally Confuzzled's `AVL tree `_\n * Wikipedia's `Interval Tree `_\n * Heavily modified from Tyler Kahn's `Interval Tree implementation in Python `_ (`GitHub project `_)\n\nCopyright\n---------\n\n * `Chaim-Leib Halbert `_\n * This particular fork by `Konstantin Tretyakov `_. See changes in CHANGELOG.txt.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/konstantint/PyIntervalTree", "keywords": "interval-tree data-structure intervals tree", "license": "LGPL", "maintainer": null, "maintainer_email": null, "name": "PyIntervalTree", "package_url": "https://pypi.org/project/PyIntervalTree/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/PyIntervalTree/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/konstantint/PyIntervalTree" }, "release_url": "https://pypi.org/project/PyIntervalTree/0.5/", "requires_dist": null, "requires_python": null, "summary": "Mutable, self-balancing interval tree", "version": "0.5" }, "last_serial": 1383866, "releases": { "0.2.3": [ { "comment_text": "", "digests": { "md5": "9763b1f7d1b3bda2e3177fea1c66adea", "sha256": "21ac05d074e5eb850af16080ba7017fa407dfeb3aa5877d682fe55a8f532e9dc" }, "downloads": -1, "filename": "PyIntervalTree-0.2.3.zip", "has_sig": false, "md5_digest": "9763b1f7d1b3bda2e3177fea1c66adea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28509, "upload_time": "2014-06-17T20:02:25", "url": "https://files.pythonhosted.org/packages/5b/7d/c685968a7b4e15e795cc1109bdda2e4ee0b2a872225dd5f18c86f929f0ec/PyIntervalTree-0.2.3.zip" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "a9ce6cd439fb67ce5ac94318a8e17193", "sha256": "922a5a6f86efcc6e27a6bfb12ec0d4b7c7dc205f93ee85ab4471bd6e9a7a2453" }, "downloads": -1, "filename": "PyIntervalTree-0.3.zip", "has_sig": false, "md5_digest": "a9ce6cd439fb67ce5ac94318a8e17193", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29345, "upload_time": "2014-11-18T14:38:47", "url": "https://files.pythonhosted.org/packages/fd/d0/4e56ba42c8b8b01ae1c923fd31eb5547f151ed8b307d35a86000f83f1e8f/PyIntervalTree-0.3.zip" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "8ff7b324df87656d20ed39203a5a1789", "sha256": "268b6b68c72b5c206f7eb0010eed443162577f58884edb4ea5fe01159e675144" }, "downloads": -1, "filename": "PyIntervalTree-0.4.zip", "has_sig": false, "md5_digest": "8ff7b324df87656d20ed39203a5a1789", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29518, "upload_time": "2014-12-02T01:12:24", "url": "https://files.pythonhosted.org/packages/f2/7e/ece0dca1422371a67f0610d174879544fcbbe29c83b4f5fae39d9d8a36e3/PyIntervalTree-0.4.zip" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "d7c970ae01a94eed856a49063edf1a1f", "sha256": "e2558a26595e7af52f411d0c137fad58c95c4eb9fc7c19ac1c2fed6455fb46af" }, "downloads": -1, "filename": "PyIntervalTree-0.5.zip", "has_sig": false, "md5_digest": "d7c970ae01a94eed856a49063edf1a1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34113, "upload_time": "2015-01-15T18:05:50", "url": "https://files.pythonhosted.org/packages/aa/53/dbdb521c8e36301108114878ff1620255c559c12ba8fe0ce2eaf9b65cbef/PyIntervalTree-0.5.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d7c970ae01a94eed856a49063edf1a1f", "sha256": "e2558a26595e7af52f411d0c137fad58c95c4eb9fc7c19ac1c2fed6455fb46af" }, "downloads": -1, "filename": "PyIntervalTree-0.5.zip", "has_sig": false, "md5_digest": "d7c970ae01a94eed856a49063edf1a1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34113, "upload_time": "2015-01-15T18:05:50", "url": "https://files.pythonhosted.org/packages/aa/53/dbdb521c8e36301108114878ff1620255c559c12ba8fe0ce2eaf9b65cbef/PyIntervalTree-0.5.zip" } ] }