skillfed

pyensembl

Python interface to Ensembl reference genome metadata

pyensembl v2.10.4 104.2K downloads/30d#12,761 on PyPI
Permissive license Apache-2.0 Active released

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 pyensembl

uv

uv add pyensembl

poetry

poetry add pyensembl

Installing 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

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Bio-Informatics

Tags

ensembl genome reference data pythonquery genes transcripts exonsgenomic annotation lookupgtf fasta genome parserreference genome metadata api
bioinformaticsgenomicsreference-data

More Bio-Informatics packages