pyensembl
Python interface to Ensembl reference genome metadata
What it is and what it does
PyEnsembl is a Python library that wraps Ensembl reference genome data—exons, transcripts, genes, and their chromosomal locations—making it queryable through a Python API. It downloads GTF (gene transfer format) and FASTA sequence files from the Ensembl FTP server, indexes them into a local database, and exposes methods to look up genes by name or ID, find transcripts, retrieve exon coordinates, and query genomic features at specific loci. It also supports custom genomes loaded from user-supplied GTF and FASTA files or remote URLs.
The package is designed for bioinformatics workflows where you need to resolve gene names to genomic coordinates, retrieve transcript structures, or annotate genomic variants against a reference. It handles the download and caching automatically and stores data in a platform-specific cache directory (configurable via environment variable). The API provides many query methods—by gene ID, gene name, transcript ID, exon ID, chromosomal position, and strand—returning Gene, Transcript, and Exon objects with associated metadata.
Use it for:
- Annotate genomic variants (SNPs, indels) by looking up overlapping genes and transcripts at their genomic coordinates.
- Retrieve transcript structures and exon boundaries for a given gene name to design primers or analyze splicing.
- Build a local reference database for a specific Ensembl release and species to support reproducible bioinformatics pipelines.
- Query the nearest gene to a genomic position when no gene directly overlaps, useful for intergenic variant classification.
- Load and index custom genome annotations (non-Ensembl GTF/FASTA) for organisms or assemblies not in the Ensembl repository.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyEnsembl provides a Python interface to query Ensembl reference genome metadata—genes, transcripts, exons, and their genomic coordinates—by downloading GTF and FASTA files and indexing them locally or loading custom genome data.
Yes. PyEnsembl is actively maintained, has low install friction, carries no known vulnerabilities, and is the standard tool for programmatic access to Ensembl genome metadata in Python. Install it if you need to query genes, transcripts, or exons by name or genomic position in a bioinformatics workflow. The main gotcha is the separate data-download step required before first use.
Install
pyensembl on PyPI
pip
pip install pyensembluv
uv add pyensemblpoetry
poetry add pyensemblInstalling pyensembl
Before you install
Low friction: pure Python wheel with 7 runtime dependencies (datacache, gtfparse, numpy, and others). Marked active with a release 37 days ago. Requires Python 3.9 or later and a separate download step (`pyensembl install`) to fetch genome data before first use.
License in practice
Apache-2.0 (permissive): you may use, modify, and distribute this package freely in commercial and private projects, provided you include a copy of the license and state any changes made.
Quickstart
pip install pyensembl
from pyensembl import EnsemblRelease
data = EnsemblRelease(77)
gene_names = data.gene_names_at_locus(contig=6, position=29945884)
Requires Python 3.9 or later. Before first use, run `pyensembl install --release <N> --species <name>` to download and index genome data.
Verify before relying
- Whether datacache, gtfparse, and other dependencies are actively maintained and free of known vulnerabilities.
- Performance characteristics when querying large genomes or handling non-Ensembl GTF formats (documentation notes this is still in development).
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — typechecks, datacache, memoized-property, tinytimer, gtfparse, serializable, numpy |
| Maintenance | actively maintained — 37 days since the last release |
| First released | |
| Downloads | 104,221/month — #12,761 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyensembl-2.10.4-py3-none-any.whl
Tags
More Bio-Informatics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
biopythonBiopython provides Python tools for…
unclear · top 5,000 on PyPI
firecrawl-pyClient library for the Firecrawl API that…
permissive · top 5,000 on PyPI
intervaltreeA self-balancing interval tree data structure…
permissive · top 5,000 on PyPI
albumentationsAlbumentations applies image transformations to…
permissive · top 5,000 on PyPI
PubChemPyPubChemPy is a Python wrapper around the…
permissive · top 5,000 on PyPI
biocommons.seqrepoSeqRepo stores and retrieves biological…
permissive · top 15,000 on PyPI
gtfparseParses GTF (gene transfer format) files into…
permissive · top 15,000 on PyPI
bioA command-line toolkit that simplifies common…
permissive · top 5,000 on PyPI
gprofiler-officialPython interface to g:Profiler toolkit for…
permissive · top 5,000 on PyPI
pyfaidxProvides fast random access to subsequences in…
permissive · top 15,000 on PyPI
pysampysam reads, manipulates, and writes genomic…
permissive · top 5,000 on PyPI
varcodeVarcode loads and analyzes genomic variant…
permissive · top 15,000 on PyPI
mygeneMygene is a Python wrapper for the MyGene.Info…
permissive · top 5,000 on PyPI
pyrangesPyRanges provides efficient querying and…
permissive · top 15,000 on PyPI
pybedtoolsWraps the BEDTools suite to perform genomic…
permissive · top 15,000 on PyPI