You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Search for drugresults=tu.tools.DailyMed_search_spls(drug_name="metformin")
setid=results[0]['setid']
# Get full labellabel=tu.tools.DailyMed_get_spl_by_set_id(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_of_action
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
drug_name, limit
FAERS_get_event_details
Detailed event data
drug_name, reaction
FAERS_search_by_drug
Search all reports
drug_name
FAERS_get_demographics
Patient demographics
drug_name, reaction
Parameter Note: Use drug_name not drug.
Example - Get adverse events:
# Get top adverse eventsevents=tu.tools.FAERS_count_reactions_by_drug_event(
drug_name="metformin",
limit=50
)
# Get details for specific eventdetails=tu.tools.FAERS_get_event_details(
drug_name="metformin",
reaction="Lactic acidosis"
)
# Search for drugpgx=tu.tools.PharmGKB_search_drug(query="warfarin")
# Get clinical annotationsannotations=tu.tools.PharmGKB_get_clinical_annotations(
drug_id=pgx[0]['id']
)
CPIC Tools
Tool
Purpose
Key Parameters
CPIC_get_guidelines
CPIC guidelines
drug_name or gene
CPIC_get_recommendations
Dosing recommendations
guideline_id
Phase 5: Clinical Trial Safety
ClinicalTrials.gov Tools
Tool
Purpose
Key Parameters
search_clinical_trials
Search trials
intervention, phase, status
get_clinical_trial_by_nct_id
Get trial details
nct_id
get_clinical_trial_results
Get posted results
nct_id
Example - Get trial safety data:
# Search completed phase 3 trialstrials=tu.tools.search_clinical_trials(
intervention="metformin",
phase="Phase 3",
status="Completed",
pageSize=20
)
# Get results for trials with posted datafortrialintrials:
iftrial.get('has_results'):
results=tu.tools.get_clinical_trial_results(
nct_id=trial['nct_id']
)
Phase 5.5: Pathway & Mechanism Context (NEW)
KEGG Pathway Tools
Tool
Purpose
Key Parameters
kegg_search_pathway
Search pathways
query
kegg_get_gene_info
Get gene details
gene_id
kegg_find_genes
Find genes by keyword
query, database
Example - Get drug metabolism pathways:
# Search for drug metabolismpathways=tu.tools.kegg_search_pathway(query="drug metabolism")
# Get genes in pathwaygenes=tu.tools.kegg_get_pathway_genes(pathway_id=pathways[0]['pathway_id'])
Reactome Tools
Tool
Purpose
Key Parameters
Reactome_search_pathway
Search pathways
query, species
Reactome_get_pathway_participants
Get pathway entities
pathway_id
Use: Understand drug mechanism pathways to contextualize adverse events.
⚠️ 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 insightspreprints=tu.tools.EuropePMC_search_articles(
query="metformin toxicity mechanism",
source="PPR", # PPR = Preprints onlypageSize=15
)
# MedRxiv for real-world safety data (via EuropePMC)clinical_preprints=tu.tools.EuropePMC_search_articles(
query="metformin real-world safety",
source="PPR",
pageSize=15
)
Citation Analysis Tools
Tool
Purpose
Key Parameters
openalex_search_works
Search with citations
query, limit
SemanticScholar_search
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
defcalculate_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 formulaimportmathse=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
}
defcompare_drug_safety(tu, drug_a, drug_b):
"""Compare safety profiles of two drugs."""# Get events for both drugsevents_a=tu.tools.FAERS_count_reactions_by_drug_event(
drug_name=drug_a, limit=30
)
events_b=tu.tools.FAERS_count_reactions_by_drug_event(
drug_name=drug_b, limit=30
)
# Find common eventsevents_a_dict= {e['reaction']: eforeinevents_a}
events_b_dict= {e['reaction']: eforeinevents_b}
common_events=set(events_a_dict.keys()) &set(events_b_dict.keys())
comparison= []
foreventincommon_events:
comparison.append({
'event': event,
'drug_a_prr': events_a_dict[event].get('prr'),
'drug_a_count': events_a_dict[event].get('count'),
'drug_b_prr': events_b_dict[event].get('prr'),
'drug_b_count': events_b_dict[event].get('count')
})
returncomparison
Example 3: Emerging Signal Detection
defdetect_emerging_signals(tu, drug_name, threshold_prr=3.0):
"""Identify signals that may require attention."""events=tu.tools.FAERS_count_reactions_by_drug_event(
drug_name=drug_name,
limit=100
)
signals= []
foreventinevents:
ifevent.get('prr', 0) >=threshold_prr:
# Get details for high-PRR eventsdetails=tu.tools.FAERS_get_event_details(
drug_name=drug_name,
reaction=event['reaction']
)
signals.append({
'event': event['reaction'],
'prr': event['prr'],
'count': event['count'],
'serious_pct': details.get('serious_count', 0) /event['count'],
'fatal_count': details.get('death_count', 0)
})
# Sort by signal strengthreturnsorted(signals, key=lambdax: x['prr'], reverse=True)
Fallback Chains
FAERS Alternatives
Primary
Fallback 1
Fallback 2
FAERS_count_reactions_by_drug_event
OpenFDA_get_drug_events
PubMed safety literature
FAERS_get_event_details
OpenFDA with filters
Manual FAERS query
Label Alternatives
Primary
Fallback 1
Fallback 2
DailyMed_get_spl_by_set_id
OpenFDA_get_drug_labels
FDA website
DailyMed_search_spls
FDA_drug_search
DrugBank
PGx Alternatives
Primary
Fallback 1
Fallback 2
PharmGKB_search_drug
CPIC_get_guidelines
FDA PGx table
PharmGKB_get_clinical_annotations
Literature search
FDA label PGx
Pathway Analysis (NEW)
Primary
Fallback 1
Fallback 2
kegg_search_pathway
Reactome_search_pathway
Literature search
Literature (NEW)
Primary
Fallback 1
Fallback 2
PubMed_search_articles
openalex_search_works
SemanticScholar_search
EuropePMC_search_articles (source='PPR')
web_search (site:medrxiv.org)
Skip preprints
ICD-10 Mapping Tool
AdverseEventICDMapper
Tool
Purpose
Key Parameters
AdverseEventICDMapper
Map AE text to ICD-10
text
Example:
# Map adverse event to ICD-10mapping=tu.tools.AdverseEventICDMapper(
text="Patient developed severe hepatotoxicity with jaundice"
)
# Returns: [{"adverse_event": "hepatotoxicity", "icd10cm_code": "K71.9", ...}]
Common Parameter Mistakes
Tool
Wrong
Correct
FAERS_count_reactions_by_drug_event
drug="metformin"
drug_name="metformin"
DailyMed_search_spls
name="aspirin"
drug_name="aspirin"
PharmGKB_search_drug
drug="warfarin"
query="warfarin"
OpenFDA_get_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