{"id":47835920,"url":"https://github.com/pyranges/ncls","last_synced_at":"2026-04-03T20:31:51.677Z","repository":{"id":44999158,"uuid":"132329167","full_name":"pyranges/ncls","owner":"pyranges","description":"NCLS. Basically a static interval-tree that is silly fast for both construction and lookups. Deprecated but maintained.","archived":false,"fork":false,"pushed_at":"2025-07-04T14:48:35.000Z","size":1482,"stargazers_count":223,"open_issues_count":16,"forks_count":24,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-02-20T18:32:46.367Z","etag":null,"topics":["interval-tree","ncls","numpy","overlap-queries","python"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyranges.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-05-06T10:42:21.000Z","updated_at":"2026-02-18T13:51:05.000Z","dependencies_parsed_at":"2024-11-15T03:11:47.963Z","dependency_job_id":"6c558394-9e98-48dd-b686-92473fcf6187","html_url":"https://github.com/pyranges/ncls","commit_stats":null,"previous_names":["pyranges/ncls","biocore-ntnu/ncls","endrebak/ncls"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pyranges/ncls","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyranges%2Fncls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyranges%2Fncls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyranges%2Fncls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyranges%2Fncls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyranges","download_url":"https://codeload.github.com/pyranges/ncls/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyranges%2Fncls/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31375769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:53:18.093Z","status":"ssl_error","status_checked_at":"2026-04-03T17:53:17.617Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interval-tree","ncls","numpy","overlap-queries","python"],"created_at":"2026-04-03T20:31:50.641Z","updated_at":"2026-04-03T20:31:51.580Z","avatar_url":"https://github.com/pyranges.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nested containment list\n\n## Deprecation notice\n\nWhile I'll continue maintaining this library I suggest you change to [ruranges](https://github.com/pyranges/ruranges/) which is a more lightweight and faster library with many more operations than NCLS.\n\n## NCLS\n\n[![Build Status](https://travis-ci.org/biocore-ntnu/ncls.svg?branch=master)](https://travis-ci.org/hunt-genes/ncls) [![PyPI version](https://badge.fury.io/py/ncls.svg)](https://badge.fury.io/py/ncls)\n\nThe Nested Containment List is a datastructure for interval overlap queries,\nlike the interval tree. It is usually an order of magnitude faster than the\ninterval tree both for building and query lookups.\n\nThe implementation here is a revived version of the one used in the now defunct\nPyGr library, which died of bitrot. I have made it less memory-consuming and\ncreated wrapper functions which allows batch-querying the NCLS for further speed\ngains.\n\nIt was implemented to be the cornerstone of the PyRanges project, but I have made\nit available to the Python community as a stand-alone library. Enjoy.\n\nOriginal Paper: https://academic.oup.com/bioinformatics/article/23/11/1386/199545\nCite: http://dx.doi.org/10.1093/bioinformatics/btz615\n\n## Cite\n\nIf you use this library in published research cite\n\nhttp://dx.doi.org/10.1093/bioinformatics/btz615\n\n## Install\n\n```\npip install ncls\n```\n\n## Usage\n\n```python\nfrom ncls import NCLS\n\nimport pandas as pd\n\nstarts = pd.Series(range(0, 5))\nends = starts + 100\nids = starts\n\nsubject_df = pd.DataFrame({\"Start\": starts, \"End\": ends}, index=ids)\n\nprint(subject_df)\n#    Start  End\n# 0      0  100\n# 1      1  101\n# 2      2  102\n# 3      3  103\n# 4      4  104\n\nncls = NCLS(starts.values, ends.values, ids.values)\n\n# python API, slower\nit = ncls.find_overlap(0, 2)\nfor i in it:\n    print(i)\n# (0, 100, 0)\n# (1, 101, 1)\n\nstarts_query = pd.Series([1, 3])\nends_query = pd.Series([52, 14])\nindexes_query = pd.Series([10000, 100])\n\nquery_df = pd.DataFrame({\"Start\": starts_query.values, \"End\": ends_query.values}, index=indexes_query.values)\n\nquery_df\n#        Start  End\n# 10000      1   52\n# 100        3   14\n\n\n# everything done in C/Cython; faster\nl_idxs, r_idxs = ncls.all_overlaps_both(starts_query.values, ends_query.values, indexes_query.values)\nl_idxs, r_idxs\n# (array([10000, 10000, 10000, 10000, 10000,   100,   100,   100,   100,\n#          100]), array([0, 1, 2, 3, 4, 0, 1, 2, 3, 4]))\n\nprint(query_df.loc[l_idxs])\n#        Start  End\n# 10000      1   52\n# 10000      1   52\n# 10000      1   52\n# 10000      1   52\n# 10000      1   52\n# 100        3   14\n# 100        3   14\n# 100        3   14\n# 100        3   14\n# 100        3   14\nprint(subject_df.loc[r_idxs])\n#    Start  End\n# 0      0  100\n# 1      1  101\n# 2      2  102\n# 3      3  103\n# 4      4  104\n# 0      0  100\n# 1      1  101\n# 2      2  102\n# 3      3  103\n# 4      4  104\n\n# return intervals in python (slow/mem-consuming)\nintervals = ncls.intervals()\nintervals\n# [(0, 100, 0), (1, 101, 1), (2, 102, 2), (3, 103, 3), (4, 104, 4)]\n```\n\nThere is also an experimental floating point version of the NCLS called FNCLS.\nSee the examples folder.\n\n## Benchmark\n\nTest file of 100 million intervals (created by subsetting gencode gtf with replacement):\n\n| Library | Function | Time (s) | Memory (GB) |\n| --- | --- | --- | --- |\n| bx-python | build | 161.7 | 2.5 |\n| ncls | build | 3.15 | 0.5 |\n| bx-python | overlap | 148.4 | 4.3 |\n| ncls | overlap | 7.2 | 0.5 |\n\nBuilding is 50 times faster and overlap queries are 20 times faster. Memory\nusage is one fifth and one ninth.\n\n## Original paper\n\n\u003e Alexander V. Alekseyenko, Christopher J. Lee; Nested Containment List (NCList): a new algorithm for accelerating interval query of genome alignment and interval databases, Bioinformatics, Volume 23, Issue 11, 1 June 2007, Pages 1386–1393, https://doi.org/10.1093/bioinformatics/btl647\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyranges%2Fncls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyranges%2Fncls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyranges%2Fncls/lists"}