opentargets-database
google-deepmind/science-skills
Query Open Targets Platform for target-disease associations, drug discovery, and therapeutic target identification.
What is opentargets-database?
Access the Open Targets Platform GraphQL API to aggregate multi-modal evidence from genetics, pathways, animal models, and clinical trials. Use this skill to rank target-disease associations, identify druggable genes, and discover therapeutic candidates for disease research.
- Query GWAS studies and credible sets for disease-variant associations
- Retrieve Locus-to-Gene (L2G) predictions to identify causal genes at genetic loci
- Fetch drug and clinical candidate information for diseases and targets
- Access target druggability and tractability data (small molecule, antibody, etc.)
- Search diseases by name and find associated targets and variants
- Query QTL credible sets and perform custom GraphQL queries for advanced analysis
How to install opentargets-database
npx skills add https://github.com/google-deepmind/science-skills --skill opentargets-database- uv package manager installed and on PATH
- License acknowledgment: check https://platform-docs.opentargets.org/licence and create .licenses/opentargets_database_LICENSE.txt in workspace root
How to use opentargets-database
- 1.Run the helper script with a command and required output flag: uv run scripts/query_opentargets.py --output /path/to/results.json COMMAND [ARGS]
- 2.Choose a command such as get-gwas-studies, get-l2g, get-target-druggability, or get-disease-drugs based on your research question
- 3.Use optional flags like --limit to control result size and --page-size for API pagination
- 4.Process the JSON output file with jq or custom code to extract and analyze results
- 5.For advanced queries not covered by built-in commands, use custom-query with raw GraphQL
Use cases
- Identify the most likely causal gene for a disease-associated genetic variant
- Find all drugs in clinical trials for a specific disease and filter by development stage
- Assess whether a gene target is druggable (small molecule vs. antibody vs. other modalities)
- Discover new therapeutic targets by finding genes associated with a disease through multiple evidence types
- Retrieve fine-mapped credible sets from GWAS studies to prioritize variants for functional validation
- Computational biologists and geneticists conducting target discovery
- Drug discovery researchers evaluating therapeutic candidates
- Bioinformaticians analyzing GWAS and QTL data
- Clinical researchers identifying new treatment options for diseases
opentargets-database FAQ
Variant-only mode (get-l2g <variant_id>) returns L2G predictions from all credible sets across all studies where that variant is the lead variant, useful for broad locus-to-gene views. Variant+study mode (get-l2g <variant_id> --study-id <study_id>) narrows results to a specific GWAS study, useful when analyzing a particular study or when you need fewer results.
Use the search-disease command with a query string (e.g., search-disease "rheumatoid arthritis") to find the disease ID and metadata, then use that ID in other commands like get-associated-targets or get-disease-drugs.
Confidence ratings (1-4 stars) indicate the quality of fine-mapping: 4 stars = SuSiE with in-sample LD (highest confidence), 3 stars = SuSiE with out-of-sample LD, 2 stars = PICS from summary statistics, 1 star = PICS from top hit only. Match user requests for "N-star confidence" to the corresponding API confidence string.
The --output flag is required because Open Targets queries can return very large JSON responses. Writing to a file allows you to manage the data efficiently and process it separately with jq or custom code rather than printing to stdout.
Check if the API response count is higher than the number of rows returned. If so, increase the --page-size parameter (default 200) to retrieve more results, or inform the user that only a subset was retrieved due to API limits.
Full instructions (SKILL.md)
Source of truth, from google-deepmind/science-skills.
name: opentargets-database description: > Query Open Targets Platform for target-disease associations, drug target discovery, tractability/safety data, genetics/omics evidence, known drugs, for therapeutic target identification.
Open Targets Database Skill
Overview
This skill provides access to the Open Targets Platform GraphQL API. It aggregates multi-modal evidence from genetics (GWAS/eQTL), pathways, animal models, and clinical trials to rank target-disease associations and identify druggable genes.
Prerequisites
uv: Read theuvskill and follow its Setup instructions to ensureuvis installed and on PATH.- User Notification: If .licenses/opentargets_database_LICENSE.txt does not already exist in the workspace root directory then (1) prominently notify the user to check the terms at https://platform-docs.opentargets.org/licence, then (2) create the file recording the notification text and timestamp.
Core Rules
- Use the Wrapper: ALWAYS execute the provided helper scripts to query the database rather than accessing the database directly. The scripts automatically enforce fair use and implement retry logic.
- Output Flag: The
--outputflag is always required as output can be very large. Usejqor write your own code to process this JSON file. - Notification: If this skill is used, ensure this is mentioned in the output.
Quick Reference
Always use the provided Python script scripts/query_opentargets.py to quickly
query the database. It handles API communication, retries, formatting, and
automatically truncates overly large responses. NEVER write your own curl or
similar requests.
Usage:
uv run scripts/query_opentargets.py --output /tmp/opentargets_results.json [OPTIONS] COMMAND [ARGS]...
Common Options:
--output PATH: Required. Path to write the JSON output file.--limit N: Limit the number of items returned in arrays (default is 50). Use a smaller number like 10 when doing preliminary exploration.--page-size N: Set the API pagination size (default is 200). Increase if you need more results (e.g., a study with many credible sets).
Available Commands:
get-gwas-studiesdisease_id: Fetches all GWAS studies associated with a specific disease ID (e.g.MONDO_0008383for Rheumatoid Arthritis).get-study-credible-setsstudy_id: Fetches all credible sets for a given study ID (e.g.FINNGEN_R12_RX_CROHN_2NDLINE). Returns confidence, finemapping method, variant, and p-value info.get-qtl-credible-setsvariant_id: Retrieves QTL credible sets for a specific variant ID (e.g.19_44908822_C_T).get-l2gvariant_id [--study-id ID]: Returns Locus-to-Gene (L2G) predictions/scores for a locus to identify the most likely causal gene. Onlyvariant_idis required; use--study-idto filter to a specific study. Acceptschrprefix (e.g.chr1_113834946_A_G).get-target-druggabilityensembl_id: Provides tractability data (small molecule, antibody, etc.) and clinical trial safety info for a gene/target.get-associated-targetsdisease_id: Find all target genes associated with a specific disease ID (EFO or MONDO).get-disease-drugsdisease_id [--min-stage STAGE]: Find all drugs and clinical candidates associated with a disease. Use--min-stageto filter (e.g.,PHASE_3for Phase III or Approved).get-associated-diseasesensembl_id: Find all diseases associated with a specific target Ensembl ID.search-diseasequery_string: Search for a disease by name to find its ID and other metadata.get-credible-sets-near-targetensembl_id [--window N]: Fetches credible sets for a target and filters them to those within a genomic window around the target. Useful for finding variants "nearby" a gene.custom-queryquery [--variables '{}']: Run a raw GraphQL query for any other Open Targets data.
L2G Query Usage
The get-l2g command has two modes:
- Variant only (
get-l2g <variant_id>): Returns L2G predictions from all credible sets across all studies where that variant is the lead variant. This can return a large number of results (e.g., hundreds). Use this when the user wants a broad view of which gene is most likely causal at a locus, or when no specific study is mentioned. - Variant + study (
get-l2g <variant_id> --study-id <study_id>): Returns L2G predictions only for credible sets from that specific study. Use this when the user asks about a specific GWAS study or when you need to narrow down the results.
Incomplete results warning: The variant-only mode can return hundreds of credible sets. The default
--page-sizeis 200, so if the API reports acounthigher than the number ofrowsreturned, you are seeing incomplete results. Always comparecountto the actual number of rows. If they differ, either increase--page-sizeor inform the user that only a subset was retrieved.
Querying by Region
To find studies with variants "nearby" a gene, use
get-credible-sets-near-target, which improves upon the base API by performing
a flexible search based on genomic position: uv run scripts/query_opentargets.py --output /tmp/results.json get-credible-sets-near-target ENSG00000156515 --window 500000
Note that the Open Targets GraphQL schema includes a regions parameter for
credibleSets, however it performs an exact match against pre-computed region
strings (e.g., chr10:68769984-69903496) and there is some missing data. Use
get-credible-sets-near-target as it allows a genomic range overlap search.
This fetches credible sets associated with the target and filters them in Python based on the variant's genomic position.
Advanced GraphQL Queries
If you need to query endpoints or fields not exposed by the built-in
subcommands, use the custom-query subcommand.
Before writing a custom query: Read the reference documentation to understand the API schema, types, and see example queries. See references/OpenTargets_GraphQL_Guide.md for full schema details, endpoints, and examples.
Example: Finding drugs for a disease
uv run scripts/query_opentargets.py custom-query \
query drugsForDisease($id: String!) {
disease(efoId: $id) {
name
drugAndClinicalCandidates {
count
rows {
maxClinicalStage
drug {
id
name
}
}
}
}
}' \
--variables '{"id": "EFO_1001006"}'
--output '/tmp/opentargets_result.json'
Confidence Star Ratings
The Open Targets Platform assigns a confidence level to each credible set based on the fine-mapping method and quality checks. These correspond to star ratings displayed in the platform UI:
| Stars | Confidence String (API value) |
|---|---|
| ★★★★ (4 stars) | SuSiE fine-mapped credible set with in-sample LD |
| ★★★ (3 stars) | SuSiE fine-mapped credible set with out-of-sample LD |
| ★★ (2 stars) | `PICS fine-mapped credible set extracted from summary |
| : : statistics` : | |
| ★ (1 star) | PICS fine-mapped credible set based on reported top hit |
| None | Unknown confidence |
When users ask about "N-star confidence", match their request to the
corresponding string in the confidence field of the API response.
Tips and Common Mistakes
- ID Formats:
- Disease IDs are typically MONDO IDs (e.g.
MONDO_0008383for Rheumatoid Arthritis) or EFO IDs (e.g.EFO_0009460). Use thesearch-diseasecommand to find the correct ID. - Target IDs must be Ensembl IDs (e.g.
ENSG00000169083), not HGNC symbols. If you only have a gene symbol, you may need to map it first using a custom GraphQLsearchquery. - Variant IDs are formatted as
chromosome_position_ref_alt(e.g.,1_154426264_C_T). Achrprefix (e.g.chr1_154426264_C_T) is automatically stripped by the tool. - Study IDs can be GWAS Catalog IDs (e.g.
GCST90204201) or project-specific IDs (e.g.FINNGEN_R12_RX_CROHN_2NDLINE).
- Disease IDs are typically MONDO IDs (e.g.
- Truncation: The tool truncates arrays longer than
--limitto protect the context window. If you see"_truncated", you can run the query again with a higher limit if you specifically need more data, but be cautious with large limit values. Always use the--outputflag to save the result to a file and avoid terminal output truncation. - Pagination and incomplete results: The
--page-sizeoption (default: 200) controls how many items are fetched from the API. Always check thecountfield in the response and compare it to the number ofrowsactually returned. Ifcount> number of rows, you have incomplete data — either increase--page-sizeto fetch more, or inform the user that only a partial result set was returned. This is especially important forget-l2gwithout--study-id, which can return hundreds of credible sets.
Related skills
More from google-deepmind/science-skills and the wider catalog.

pdb-database
Search and download experimentally-determined 3D biomolecule structures from the RCSB Protein Data Bank.

protein-sequence-msa
Align multiple protein sequences with EBI Clustal Omega to assess similarity and conservation.

protein-sequence-similarity-search
Search for homologous protein sequences using MMseqs2 or BLAST to find matches and infer function.

pubchem-database
Query PubChem for chemical properties, structures, and bioactivity data via safe wrapper scripts.

pubmed-database
Search PubMed, fetch abstracts and full text, link to biological databases (genes, proteins, compounds).

pymol
Visualize, analyze, and render protein and molecular structures using PyMOL.