# Search for drug
results = tu.tools.DailyMed_search_spls(drug_name="metformin")
setid = results[0]['setid']
# Get full label
label = tu.tools.DailyMed_get_spl_by_setid(setid=setid)
ChEMBL Drug Tools
Tool
Purpose
Key Parameters
ChEMBL_search_drugs
Search drugs
query
ChEMBL_get_molecule
Get molecule details
molecule_chembl_id
ChEMBL_get_drug_mechanisms
Get MOA
molecule_chembl_id
Phase 2: FAERS Adverse Events
FAERS Query Tools
Tool
Purpose
Key Parameters
FAERS_count_reactions_by_drug_event
AE counts for drug
medicinalproduct, limit
FAERS_search_reports_by_drug_and_reaction
Reports for a drug + specific reaction
medicinalproduct, reactionmeddrapt
FAERS_search_adverse_event_reports
Search all reports for a drug
medicinalproduct, limit
FAERS_calculate_disproportionality
PRR / ROR / IC signal metrics
drug_name, adverse_event
FAERS_stratify_by_demographics
Patient demographics
drug_name, reaction
Parameter Note: The FAERS_count_* and FAERS_search_* tools take medicinalproduct (not drug_name or drug); the analysis tools (FAERS_calculate_disproportionality, FAERS_stratify_by_demographics) take drug_name.
Example - Get adverse events:
# Get top adverse events
events = tu.tools.FAERS_count_reactions_by_drug_event(
medicinalproduct="metformin",
limit=50
)
# Returns: results[] of {term, count}, e.g. {"term": "NAUSEA", "count": 31807}
# Get details for specific event
details = tu.tools.FAERS_search_reports_by_drug_and_reaction(
medicinalproduct="metformin",
reactionmeddrapt="Lactic acidosis"
)
# Returns: reports[] (patient, drug, reaction details per case)
# Signal strength for a drug-event pair
signal = tu.tools.FAERS_calculate_disproportionality(
drug_name="metformin",
adverse_event="Lactic acidosis"
)
# Returns: data.metrics.PRR.value / ROR.value / IC.value and data.signal_detection
# Search for drug
pgx = tu.tools.PharmGKB_search_drugs(query="warfarin")
# Drug record (pgx['data'][0]['id'] == "PA451906" for warfarin)
drug = tu.tools.PharmGKB_get_drug_details(drug_id=pgx['data'][0]['id'])
# Clinical annotations are fetched by annotation ID (lookup by drug or gene is not supported by the API)
annotation = tu.tools.PharmGKB_get_clinical_annotations(
annotation_id="1183618159"
)
# Search completed phase 3 trials
# There is no phase parameter: filter phase with an Essie expression in query_term
trials = tu.tools.search_clinical_trials(
intervention="metformin",
query_term="AREA[Phase]PHASE3",
overall_status=["COMPLETED"],
pageSize=20
)
# Fetch outcome measures for the returned trials
for trial in trials['data']['studies']:
results = tu.tools.get_clinical_trial_outcome_measures(
nct_ids=[trial['NCT ID']]
)
Phase 5.5: Pathway & Mechanism Context (NEW)
KEGG Pathway Tools
Tool
Purpose
Key Parameters
kegg_search_pathway
Search pathways
keyword
kegg_get_gene_info
Get gene details
gene_id
kegg_find_genes
Find genes by keyword
keyword, organism
Example - Get drug metabolism pathways:
# Search for drug metabolism
pathways = tu.tools.kegg_search_pathway(keyword="drug metabolism")
# Returns: data[] of {pathway_id: "map00982", description: ...}
# Get genes in pathway (needs the organism-specific ID, hsaNNNNN, not the mapNNNNN reference ID)
pathway_id = "hsa" + pathways['data'][0]['pathway_id'][3:]
genes = tu.tools.KEGG_get_pathway_genes(pathway_id=pathway_id)
# Returns: data.genes[] such as "hsa:10720"
Reactome Tools
Tool
Purpose
Key Parameters
ReactomeContent_search
Search pathways
query, species
Reactome_get_participants
Get pathway entities
pathway_id
Use: Understand drug mechanism pathways to contextualize adverse events.
query (prefix SRC:PPR AND for preprints only), limit
BioRxiv_get_preprint
Get preprint by DOI
doi
⚠️ Preprints are NOT peer-reviewed but may contain emerging safety signals!
Example - Search preprints for emerging signals (bioRxiv/medRxiv don't have search APIs, use EuropePMC):
# EuropePMC for mechanism insights
preprints = tu.tools.EuropePMC_search_articles(
query="SRC:PPR AND metformin toxicity mechanism", # SRC:PPR = preprints only
limit=15
)
# MedRxiv for real-world safety data (via EuropePMC)
clinical_preprints = tu.tools.EuropePMC_search_articles(
query="SRC:PPR AND metformin real-world safety",
limit=15
)
Citation Analysis Tools
Tool
Purpose
Key Parameters
openalex_search_works
Search with citations
query, limit
SemanticScholar_search_papers
AI-ranked search
query, limit
Example - Find high-impact safety papers:
papers = tu.tools.openalex_search_works(
query="metformin lactic acidosis clinical",
limit=20
)
# Sort by cited_by_count for impact
Disproportionality Calculations
PRR Calculation
def calculate_prr(a, b, c, d):
"""
Calculate Proportional Reporting Ratio.
a = reports of drug X with event Y
b = reports of drug X with all other events
c = reports of event Y with all other drugs
d = reports of all other drug-event pairs
PRR = (a/(a+b)) / (c/(c+d))
"""
prr = (a / (a + b)) / (c / (c + d))
# 95% CI using Rothman formula
import math
se = math.sqrt(1/a - 1/(a+b) + 1/c - 1/(c+d))
ci_lower = math.exp(math.log(prr) - 1.96 * se)
ci_upper = math.exp(math.log(prr) + 1.96 * se)
return {
'prr': prr,
'ci_lower': ci_lower,
'ci_upper': ci_upper,
'significant': ci_lower > 1.0
}
def compare_drug_safety(tu, drug_a, drug_b):
"""Compare safety profiles of two drugs."""
# Get events for both drugs
events_a = tu.tools.FAERS_count_reactions_by_drug_event(
medicinalproduct=drug_a, limit=30
)
events_b = tu.tools.FAERS_count_reactions_by_drug_event(
medicinalproduct=drug_b, limit=30
)
# Find common events (results[] items are {term, count})
events_a_dict = {e['term']: e for e in events_a['results']}
events_b_dict = {e['term']: e for e in events_b['results']}
common_events = set(events_a_dict.keys()) & set(events_b_dict.keys())
comparison = []
for event in common_events:
comparison.append({
'event': event,
'drug_a_count': events_a_dict[event].get('count'),
'drug_b_count': events_b_dict[event].get('count')
# PRR is not in the count results: call FAERS_calculate_disproportionality per drug/event
})
return comparison
Example 3: Emerging Signal Detection
def detect_emerging_signals(tu, drug_name, threshold_prr=3.0):
"""Identify signals that may require attention."""
events = tu.tools.FAERS_count_reactions_by_drug_event(
medicinalproduct=drug_name,
limit=100
)
signals = []
for event in events['results']:
# PRR comes from the disproportionality tool, not the count tool
metrics = tu.tools.FAERS_calculate_disproportionality(
drug_name=drug_name,
adverse_event=event['term']
)['data']['metrics']
prr = metrics['PRR']['value']
if prr >= threshold_prr:
signals.append({
'event': event['term'],
'prr': prr,
'count': event['count']
})
# Sort by signal strength
return sorted(signals, key=lambda x: x['prr'], reverse=True)
Fallback Chains
FAERS Alternatives
Primary
Fallback 1
Fallback 2
FAERS_count_reactions_by_drug_event
OpenFDA_search_drug_events
PubMed safety literature
FAERS_search_adverse_event_reports
OpenFDA with filters
Manual FAERS query
Label Alternatives
Primary
Fallback 1
Fallback 2
DailyMed_search_spls
OpenFDA_search_drug_labels
FDA website
DailyMed_search_spls
FDA_search_drug_labels
DrugBank
PGx Alternatives
Primary
Fallback 1
Fallback 2
PharmGKB_search_drugs
CPIC_list_guidelines
FDA PGx table
PharmGKB_get_clinical_annotations
Literature search
FDA label PGx
Pathway Analysis (NEW)
Primary
Fallback 1
Fallback 2
kegg_search_pathway
ReactomeContent_search
Literature search
Literature (NEW)
Primary
Fallback 1
Fallback 2
PubMed_search_articles
openalex_search_works
SemanticScholar_search_papers
EuropePMC_search_articles (SRC:PPR query)
web_search (site:medrxiv.org)
Skip preprints
ICD-10 Mapping Tool
AdverseEventICDMapper
Tool
Purpose
Key Parameters
AdverseEventICDMapper
Map AE text to ICD-10 (LLM-backed agentic tool)
source_text
Example:
# Map adverse event to ICD-10
mapping = tu.tools.AdverseEventICDMapper(
source_text="Patient developed severe hepatotoxicity with jaundice"
)
# Returns a text string (per its return_schema: type string) listing each adverse event with its
# ICD-10-CM code, not a list of dicts. It is an LLM-backed AgenticTool, so it needs an LLM
# backend configured; not live-run when this snippet was checked (argument name taken from the
# tool schema and its own test_example).
Common Parameter Mistakes
Tool
Wrong
Correct
FAERS_count_reactions_by_drug_event
drug="metformin" / drug_name="metformin"
medicinalproduct="metformin"
DailyMed_search_spls
name="aspirin"
drug_name="aspirin"
PharmGKB_search_drugs
drug="warfarin"
query="warfarin"
OpenFDA_search_drug_events
drug_name="X"
search="patient.drug.medicinalproduct:X"
Rate Limits and Best Practices
FAERS/OpenFDA
Rate limit: 240 requests/minute (without API key)
Best practice: Cache results, batch queries
PharmGKB
No strict rate limit
Best practice: Use drug ID for subsequent queries
DailyMed
No strict rate limit
Best practice: Cache SPL content (large responses)
ClinicalTrials.gov
Rate limit: 3 requests/second
Best practice: Use pageSize parameter to reduce calls