ncls
A fast interval tree-like implementation in C, wrapped for the Python ecosystem.
What it is and what it does
NCLS is a Nested Containment List data structure for interval overlap queries, originally from the defunct PyGr library and revived as a standalone tool. It builds on the algorithm described in the original paper and is optimized for speed and memory efficiency compared to traditional interval trees. The package wraps a C implementation with Python bindings and depends only on numpy.
You use NCLS by constructing an index from arrays of interval start and end positions, then query it to find overlaps with new intervals. It supports both single-query (slower, Python-based) and batch-query (faster, C-based) modes. The package is designed for genomic and bioinformatics workflows but works for any interval overlap problem.
Use it for:
- Finding all genomic features that overlap a given region in a genome annotation database.
- Batch-querying multiple query intervals against a large reference set of intervals to identify all pairwise overlaps.
- Building interval indices for read alignment or variant annotation pipelines where speed is critical.
- Detecting overlaps in time-series or coordinate-based data where traditional tree structures are too slow.
- Memory-constrained environments where interval tree memory overhead is prohibitive.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
NCLS provides a fast interval overlap query data structure implemented in C, designed to find which intervals overlap with a given range much faster than traditional interval trees.
Yes, if you need fast interval overlap queries and are comfortable with a compiled dependency. The package is stable, has no known vulnerabilities, and offers significant speed and memory advantages. However, note the deprecation notice recommending an alternative for new projects and the aging maintenance status—evaluate whether that better suits your long-term needs.
Install
ncls on PyPI
pip
pip install nclsuv
uv add nclspoetry
poetry add nclsInstalling ncls
Before you install
Medium install friction due to compiled C extensions; however, pre-built wheels are available for common Python versions and platforms (macOS ARM64, Linux x86_64, i686, musllinux). Last release was recent (2025-07-04), but the package is marked as aging with no commits since then.
License in practice
MIT license is permissive and poses no restrictions on commercial or private use, modification, or redistribution.
Quickstart
pip install ncls
from ncls import NCLS
import numpy as np
starts = np.array([0, 1, 2])
ends = np.array([100, 101, 102])
ids = np.array([0, 1, 2])
ncls = NCLS(starts, ends, ids)
results = ncls.find_overlap(0, 2)
for interval in results:
print(interval)
Requires a C compiler and build tools to compile the extension from source if a pre-built wheel is not available for your Python version and platform.
Verify before relying
- Whether the package's aging maintenance status affects long-term compatibility with future Python versions.
- The deprecation notice recommends ruranges as an alternative; whether NCLS remains the right choice for new projects.
- Minimum Python version requirement, as requires_python is unspecified in the metadata.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | aging — 406 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 104,335/month — #12,753 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ncls-0.0.70-cp310-cp310-macosx_11_0_arm64.whl; ncls-0.0.70-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl; ncls-0.0.70-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ncls-0.0.70-cp310-cp310-musllinux_1_1_i686.whl; ncls-0.0.70-cp310-cp310-musllinux_1_1_x86_64.whl; ncls-0.0.70-cp311-cp311-macosx_11_0_arm64.whl; ncls-0.0.70-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl; ncls-0.0.70-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ncls-0.0.70-cp311-cp311-musllinux_1_1_i686.whl; ncls-0.0.70-cp311-cp311-musllinux_1_1_x86_64.whl; ncls-0.0.70-cp312-cp312-macosx_11_0_arm64.whl; ncls-0.0.70-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl; ncls-0.0.70-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ncls-0.0.70-cp312-cp312-musllinux_1_1_i686.whl; ncls-0.0.70-cp312-cp312-musllinux_1_1_x86_64.whl; ncls-0.0.70-cp39-cp39-macosx_11_0_arm64.whl; ncls-0.0.70-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl; ncls-0.0.70-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; ncls-0.0.70-cp39-cp39-musllinux_1_1_i686.whl; ncls-0.0.70-cp39-cp39-musllinux_1_1_x86_64.whl
Keywords: ncls, interval-tree, genomics
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
intervaltreeA self-balancing interval tree data structure…
permissive · top 5,000 on PyPI
pyrangesPyRanges provides efficient querying and…
permissive · top 15,000 on PyPI
portionportion provides data structures and operations…
copyleft · top 5,000 on PyPI
intervalsProvides Python classes for representing and…
permissive · top 15,000 on PyPI
awkwardAwkward Array provides NumPy-like operations on…
permissive · top 5,000 on PyPI
igwn-segmentsProvides segment, segmentlist, and…
copyleft · top 15,000 on PyPI
pybedtoolsWraps the BEDTools suite to perform genomic…
permissive · top 15,000 on PyPI
bx-pythonbx-python provides Python classes and utilities…
permissive · top 15,000 on PyPI
multiqcMultiQC scans bioinformatics analysis…
copyleft · top 15,000 on PyPI
jenkspyComputes optimal class boundaries for numerical…
permissive · top 15,000 on PyPI