Reactome Pathway Database
Query the Reactome ContentService and AnalysisService APIs.
When to Use
- User asks about detailed biological pathways
- User wants pathway diagrams
- User asks about specific reactions in a pathway
- User wants to do pathway enrichment with a gene list
How to Execute
import requests
import json
CONTENT_URL = "https://reactome.org/ContentService"
ANALYSIS_URL = "https://reactome.org/AnalysisService"
# 1. Search pathways by keyword
def search_pathways(keyword, species="Homo sapiens"):
url = f"{CONTENT_URL}/search/query"
params = {"query": keyword, "species": species, "types": "Pathway", "cluster": True}
r = requests.get(url, params=params)
r.raise_for_status()
return r.json()
# 2. Get pathway details
def get_pathway(pathway_id):
url = f"{CONTENT_URL}/data/query/{pathway_id}"
r = requests.get(url, headers={"Accept": "application/json"})
r.raise_for_status()
return r.json()
# 3. Get genes/proteins in a pathway
def get_pathway_participants(pathway_id):
url = f"{CONTENT_URL}/data/participants/{pathway_id}"
r = requests.get(url, headers={"Accept": "application/json"})
r.raise_for_status()
return r.json()
# 4. Gene list pathway enrichment
def pathway_enrichment(gene_list):
url = f"{ANALYSIS_URL}/identifiers/projection"
genes_text = "\n".join(gene_list)
headers = {"Content-Type": "text/plain"}
r = requests.post(url, data=genes_text, headers=headers)
r.raise_for_status()
return r.json()
# 5. Look up a gene in Reactome
def query_gene(gene_symbol):
url = f"{CONTENT_URL}/data/query/{gene_symbol}"
r = requests.get(url, headers={"Accept": "application/json"})
r.raise_for_status()
return r.json()
# Example: DNA repair pathways
results = search_pathways("DNA repair")
entries = results.get("results", [])
for entry in entries[:5]:
for e in entry.get("entries", []):
print(f"{e.get('stId', 'N/A')}: {e.get('name', 'N/A')}")
# Pathway enrichment
enrichment = pathway_enrichment(["BRCA1", "BRCA2", "TP53", "ATM", "CHEK2"])
for p in enrichment.get("pathways", [])[:5]:
name = p.get("name", "N/A")
pval = p.get("entities", {}).get("pValue", "N/A")
found = p.get("entities", {}).get("found", 0)
print(f"{name} — p={pval:.2e}, {found} genes found")
Common Pathway IDs
- DNA Repair:
R-HSA-73894
- Apoptosis:
R-HSA-109581
- Cell Cycle:
R-HSA-1640170
- Immune System:
R-HSA-168256
Follow-up Suggestions
- "Want me to do pathway enrichment with your gene list?"
- "Should I compare with KEGG pathways?"
- "Want me to find upstream regulators of this pathway?"
1---2name: query-reactome3description: Query Reactome for biological pathways and reactions. Use when user asks about signaling cascades, biological processes, pathway diagrams, or reaction details. Triggers on "reactome", "signaling cascade", "biological pathway", "pathway diagram", "reaction mechanism".4---5
6# Reactome Pathway Database
7
8Query the Reactome ContentService and AnalysisService APIs.
9
10## When to Use
11
12- User asks about detailed biological pathways
13- User wants pathway diagrams
14- User asks about specific reactions in a pathway
15- User wants to do pathway enrichment with a gene list
16
17## How to Execute
18
19```python
20import requests
21import json
22
23CONTENT_URL = "https://reactome.org/ContentService"
24ANALYSIS_URL = "https://reactome.org/AnalysisService"
25
26# 1. Search pathways by keyword
27def search_pathways(keyword, species="Homo sapiens"):
28 url = f"{CONTENT_URL}/search/query"
29 params = {"query": keyword, "species": species, "types": "Pathway", "cluster": True}
30 r = requests.get(url, params=params)
31 r.raise_for_status()
32 return r.json()
33
34# 2. Get pathway details
35def get_pathway(pathway_id):
36 url = f"{CONTENT_URL}/data/query/{pathway_id}"
37 r = requests.get(url, headers={"Accept": "application/json"})
38 r.raise_for_status()
39 return r.json()
40
41# 3. Get genes/proteins in a pathway
42def get_pathway_participants(pathway_id):
43 url = f"{CONTENT_URL}/data/participants/{pathway_id}"
44 r = requests.get(url, headers={"Accept": "application/json"})
45 r.raise_for_status()
46 return r.json()
47
48# 4. Gene list pathway enrichment
49def pathway_enrichment(gene_list):
50 url = f"{ANALYSIS_URL}/identifiers/projection"
51 genes_text = "\n".join(gene_list)
52 headers = {"Content-Type": "text/plain"}
53 r = requests.post(url, data=genes_text, headers=headers)
54 r.raise_for_status()
55 return r.json()
56
57# 5. Look up a gene in Reactome
58def query_gene(gene_symbol):
59 url = f"{CONTENT_URL}/data/query/{gene_symbol}"
60 r = requests.get(url, headers={"Accept": "application/json"})
61 r.raise_for_status()
62 return r.json()
63
64# Example: DNA repair pathways
65results = search_pathways("DNA repair")
66entries = results.get("results", [])
67for entry in entries[:5]:
68 for e in entry.get("entries", []):
69 print(f"{e.get('stId', 'N/A')}: {e.get('name', 'N/A')}")
70
71# Pathway enrichment
72enrichment = pathway_enrichment(["BRCA1", "BRCA2", "TP53", "ATM", "CHEK2"])
73for p in enrichment.get("pathways", [])[:5]:
74 name = p.get("name", "N/A")
75 pval = p.get("entities", {}).get("pValue", "N/A")
76 found = p.get("entities", {}).get("found", 0)
77 print(f"{name} — p={pval:.2e}, {found} genes found")
78```
79
80## Common Pathway IDs
81
82- DNA Repair: `R-HSA-73894`
83- Apoptosis: `R-HSA-109581`
84- Cell Cycle: `R-HSA-1640170`
85- Immune System: `R-HSA-168256`
86
87## Follow-up Suggestions
88
89- "Want me to do pathway enrichment with your gene list?"
90- "Should I compare with KEGG pathways?"
91- "Want me to find upstream regulators of this pathway?"