skillfed

ncls

A fast interval tree-like implementation in C, wrapped for the Python ecosystem.

ncls v0.0.70 104.3K downloads/30d#12,753 on PyPI224
Permissive license MIT AGING released

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 ncls

uv

uv add ncls

poetry

poetry add ncls

Installing 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

Development Status :: 4 - BetaEnvironment :: Other EnvironmentIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Topic :: Scientific/Engineering

Tags

interval overlap queriesinterval tree alternativefast range intersectiongenomic interval lookupnested containment listinterval databaseoverlap detection
genomicsinterval-queriesperformance-critical

More Scientific/Engineering packages