skillfed

pybedtools

Wrapper around BEDTools for bioinformatics work

pybedtools v0.12.0 109.6K downloads/30d#12,506 on PyPI330
Permissive license MIT AGING released

What it is and what it does

pybedtools is a Python wrapper around the BEDTools suite, a widely-used toolkit for genomic interval manipulation. It lets you perform operations like subtract, intersect, and closest on genomic features directly from Python code, rather than chaining shell commands. The package supports all BEDTools-compatible file formats (BED, GFF, and others, including gzipped variants) and can stream results like Unix pipes, making it memory-efficient for large genomic datasets.

The package depends on numpy, pysam, and pandas for data handling. It's designed for bioinformaticians and computational biologists who want to avoid writing complex bash scripts for routine genomic analyses. The main trade-off is the high install friction: BEDTools itself must be available on your system as a compiled binary before pybedtools can wrap it.

Use it for:

  • Find genes within a specific distance of intergenic variants by combining subtract and closest operations on BED/GFF files.
  • Filter genomic features by intersection with regulatory regions or exclusion zones using subtract and intersect.
  • Stream large genomic datasets through multiple operations without materializing intermediate results to disk.
  • Iterate over genomic features and access their attributes (name, coordinates, scores) programmatically in Python loops.
  • Automate repetitive genomic interval analyses that would otherwise require shell script pipelines.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Wraps the BEDTools suite to perform genomic interval operations (subtract, intersect, closest, etc.) directly from Python, supporting all BEDTools-compatible formats and streaming results.

Yes, if you have BEDTools already installed and work regularly with genomic intervals in Python. The high install friction and aging maintenance status (516 days since release) are real drawbacks, but the package is stable, permissively licensed, and solves a genuine problem for bioinformaticians. Not worth installing if you lack BEDTools or only occasionally need interval operations.

Install

pybedtools on PyPI

pip

pip install pybedtools

uv

uv add pybedtools

poetry

poetry add pybedtools

Installing pybedtools

Before you install

High install friction: requires BEDTools as a compiled system dependency. Package is aging (516 days since last release) but repo is not archived with recent activity on 2025-03-16.

License in practice

MIT license is permissive; you can use, modify, and distribute pybedtools with minimal restrictions, suitable for academic and commercial projects.

Quickstart

from pybedtools import BedTool

snps = BedTool('snps.bed.gz')
genes = BedTool('hg19.gff')
intergenic_snps = snps.subtract(genes)
nearby = genes.closest(intergenic_snps, d=True, stream=True)
for gene in nearby:
    if int(gene[-1]) < 5000:
        print(gene.name)

BEDTools must be installed and available on the system as a compiled binary before pybedtools can wrap it.

Verify before relying

  • Whether BEDTools must be pre-installed on the system or if pybedtools handles installation automatically
  • Compatibility with Python versions beyond 3.8 (classifiers list 3.6, 3.7, 3.8 but requires_python is unspecified)

Package facts

License MIT (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies 3 — numpy, pysam, pandas
Maintenance aging — 516 days since the last release
Last repo commit
First released
Downloads 109,608/month — #12,506 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pybedtools-0.12.0.tar.gz

Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Scientific/Engineering :: Bio-InformaticsTopic :: Software Development :: Libraries :: Python Modules

Tags

genomic interval manipulation pythonbedtools python wrappergenome algebra operationsbioinformatics interval operationsbed file processing pythongenomic feature comparisonintergenic region analysis
bioinformaticsgenomicsbedtools-wrapper

More Python Modules packages