pybedtools
Wrapper around BEDTools for bioinformatics work
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 pybedtoolsuv
uv add pybedtoolspoetry
poetry add pybedtoolsInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pyrangesPyRanges provides efficient querying and…
permissive · top 15,000 on PyPI
pybigtoolspybigtools is a Python wrapper around a Rust…
permissive · top 15,000 on PyPI
gtfparseParses GTF (gene transfer format) files into…
permissive · top 15,000 on PyPI
pysampysam reads, manipulates, and writes genomic…
permissive · top 5,000 on PyPI
pyensemblPyEnsembl provides a Python interface to query…
permissive · top 15,000 on PyPI
bx-pythonbx-python provides Python classes and utilities…
permissive · top 15,000 on PyPI
cgcg is a clinical sequencing platform that…
unclear · top 15,000 on PyPI
bioA command-line toolkit that simplifies common…
permissive · top 5,000 on PyPI
deepbiopDeepBioP is a deep learning preprocessing…
permissive · top 15,000 on PyPI
nclsNCLS provides a fast interval overlap query…
permissive · top 15,000 on PyPI