Skip to main content

DGIpy

image image image Actions status

Python wrapper for querying a Drug-Gene Interaction Database (DGIdb) GraphQL API. DGIpy provides drug and gene records, drug-gene interactions, gene categories, source metadata, and FDA drug application information.

Installation

Install from PyPI:

python3 -m pip install dgipy

Usage

DGIpy is built around query functions that fetch data from the public DGIdb API. Results use a column-oriented dictionary: each key is a column name and each value is a list containing that column's values. The examples below show representative output; the contents of the live DGIdb database may change.

>>> from dgipy import get_genes
>>> results = get_genes(["BRAF"])
>>> results["gene_name"][0], results["gene_concept_id"][0], results["gene_aliases"][0][:5]
('BRAF', 'hgnc:1097', ['B-RAF PROTO-ONCOGENE, SERINE/THREONINE KINASE', 'BRAF1', 'BRAF-1', 'UCSC:UC003VWC.5', 'VEGA:OTTHUMG00000157457'])

This orientation enables easy use with the dataframe library of your choosing:

>>> import pandas as pd
>>> pd.DataFrame(results)[["gene_name", "gene_concept_id"]]
  gene_name gene_concept_id
0      BRAF        hgnc:1097
>>>
>>> import polars as pl  # not included in DGIpy dependencies
>>> pl.DataFrame(results).select("gene_name", "gene_concept_id")
shape: (1, 2)
┌───────────┬─────────────────┐
│ gene_name ┆ gene_concept_id │
│ ---       ┆ ---             │
│ str       ┆ str             │
╞═══════════╪═════════════════╡
│ BRAF      ┆ hgnc:1097       │
└───────────┴─────────────────┘

Available queries

Function Description
get_drugs(terms, ...) Look up drug records by name.
get_genes(terms, ...) Look up gene records by name.
get_interactions(terms, ...) Find drug-gene interactions by gene or drug name.
get_categories(terms, ...) Find category annotations for genes.
get_sources(source_type=None, ...) List DGIdb source metadata, optionally filtered by SourceType.
get_all_genes(...) List all gene names and concept identifiers.
get_all_drugs(...) List all drug names and concept identifiers. Import this function from dgipy.dgidb.
get_drug_applications(terms, ...) Combine DGIdb application identifiers with Drugs@FDA product data.

The query functions accept an optional api_url argument when querying a DGIdb v5 instance other than the public endpoint:

from dgipy import get_genes

genes = get_genes(["BRAF"], api_url="https://example.org/api/graphql")

Development

Clone the repo and create a virtual environment:

git clone https://github.com/genomicmedlab/dgipy
cd dgipy
python3 -m virtualenv venv
source venv/bin/activate

Install development dependencies and pre-commit:

python3 -m pip install -e '.[dev,tests]'
pre-commit install

Check style with ruff:

python3 -m ruff format . && python3 -m ruff check --fix .

Run tests with pytest:

pytest

Release files for dgipy 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dgipy 0.2.0
File Size Uploaded
dgipy-0.2.0.tar.gz 324.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dgipy 0.2.0
File Interpreter ABI Platform
dgipy-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 346.7 kB

Release files / dgipy-0.2.0.tar.gz

Download URL dgipy-0.2.0.tar.gz
Size 324.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1230c777c032f791b7d816e64e809840dcb1d2321c16c37b927b7adab79c7245
BLAKE2b-256 checksum
How to use checksums
bcba32df74c733bf184c7cdebcb9da73c37d1ab768658c6aa308204978b28bd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / dgipy-0.2.0-py3-none-any.whl

Download URL dgipy-0.2.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
718a6bbea1b620166c59d5e60f4852e0c8fec87a9a39b233b53c9cd906f34fea
BLAKE2b-256 checksum
How to use checksums
1549d81f102df645b5866999c3ab94e86393b6e2e7a88ed166ed8f85bd5abf73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page