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_interaction_types(...) List interaction claim-type metadata.
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

Metadata

Release files for dgipy 0.2.1

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.1
File Size Uploaded Provenance Actions
dgipy-0.2.1.tar.gz 326.3 kB With provenance Details for dgipy-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 348.7 kB

Release files / dgipy-0.2.1.tar.gz

Download URL dgipy-0.2.1.tar.gz
Size 326.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2bea68d97ebe690f685478b5679f900b49a42231a684df1f7904198aeee1b994
BLAKE2b-256 checksum
How to use checksums
64d1f871d875c2eb6ceec237d2e9b1401b452c68b1c2dbc00e34216ff88ef368
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 Oct 15, 2026.

Transparency log

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

Download URL dgipy-0.2.1-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f533cdc218a8477f815ce69884213c00bfdc15eab699a7d1e392200c193616d
BLAKE2b-256 checksum
How to use checksums
18af199bb4f9a6d5270b683d3954b979fef6f2df2faf7b2e17239d29e40ee169
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 Oct 15, 2026.

Transparency log

Security for dgipy 0.2.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dgipy-0.2.1.tar.gz

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 Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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