Skip to content

Python wrapper for RxClass API with helper functions to lookup: indications, contraindications, pharmacology, pharmacokinetics, chemical names, therapeutic class, mechanisms of action, physiological effects, and drug similarities.

License

Notifications You must be signed in to change notification settings

Ianphorsman/RxClassAPIWrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RxClass API Wrapper with Helper Utility

Getting Started

This project contains a python wrapper for the RxClass API as well as a set of helper functions to obtain useful information stripped of unimportant data.

Helper Functions

`RxClassHelpers` contains several high level helper functions to acquaint yourself with what the RxClass API can (and can't) do. Just create an instance to get started. Warning: there are a lot of false negative results.


pip install rxclass

# To access API helpers:

from rxclass_api import RxClassHelpers

# To access API wrapper functions directly:
from rxclass_api import RxAPIWrapper

# To start using available helper functions create a helper instance.

helper = RxClassHelpers()

Supplying a with statement will also automatically load and save gathered data given a filename.

helper = RxClassHelpers(filename='data')
with helper:
    ...

Obtaining Class's Id and Type

Unique identifiers are represented as classId(s). Every class in RxClass has a classId and classType.

helper.get_class_by_name('fluoxetine')

#=>
{'classId': 'N0000007101',
  'className': 'Fluoxetine',
  'classType': 'CHEM'}

helper.get_class_by_name('SSRI')

#=>
{'classId': 'N0000175696',
 'className': 'Serotonin Reuptake Inhibitor',
 'classType': 'EPC'}

 helper.get_class_by_name('Drug Hypersensitivity')

#=>
{'classId': 'N0000000999',
 'className': 'Drug Hypersensitivity',
 'classType': 'DISEASE'}

Class Types

List all the class types with descriptions.

helper.list_class_types()

#=>
['MESHPA = MeSH Pharmacological Actions',
 'VA = Class',
 'PK = Pharmacokinetics',
 'EPC = Established Pharmacological Classes',
 'DISEASE = Indication / Condition / Disease',
 'ATC1-4 = Anatomical Therapeutic Chemical',
 'CHEM = Chemical Name',
 'MOA = Mechanism of Action',
 'PE = Physiological Effect']

Drug Indications

helper.indications('bupropion')

#=>
['Anorexia',
 'Attention Deficit Disorder with Hyperactivity',
 'Bulimia',
 'Depressive Disorder',
 'Drug Hypersensitivity',
 'Seizures',
 'Substance Withdrawal Syndrome',
 'Tobacco Use Disorder']

 helper.indications('azithromycin')

 #=>
 ['Chlamydia Infections',
 'Endocarditis, Bacterial',
 'Haemophilus Infections',
 'Hypersensitivity',
 'Liver Diseases',
 'Mycobacterium Infections, Nontuberculous',
 'Neisseriaceae Infections',
 'Otitis Media',
 'Pharyngitis',
 'Pneumonia, Bacterial',
 'Pneumonia, Mycoplasma',
 'Respiratory Tract Infections',
 'Sexually Transmitted Diseases, Bacterial',
 'Skin Diseases, Infectious',
 'Staphylococcal Infections',
 'Streptococcal Infections',
 'Tonsillitis',
 'Urethritis']

Drug's Mechanism of Action

helper.mechanism_of_action('marijuana') # 'marijuana' will not be in database

#=>
[]

helper.mechanism_of_action('tetrahydrocannabinol') # chemical name will be found though

#=>
['Cannabinoid Receptor Agonists']

helper.similarly_acting_drugs('fluoxetine')

#=>
[('Serotonin Uptake Inhibitors',
  ['Citalopram',
   'Desvenlafaxine',
   'duloxetine',
   'Escitalopram',
   'Fluoxetine',
   'Fluvoxamine',
   'levomilnacipran',
   'milnacipran',
   'Paroxetine',
   'Sertraline',
   'venlafaxine']),
 ('Monoamine Oxidase Inhibitors',
  ['Isocarboxazid',
   'Phenelzine',
   'rasagiline',
   'safinamide',
   'Selegiline',
   'Tranylcypromine'])]

Drug's Physiological Effect

helper.physiological_effect('aripiprazole')

#=>
['Decreased Dopamine Activity', 'Decreased Serotonin Activity']

helper.drugs_with_similar_physiological_response('ibuprofen')

#=>
[('Decreased Platelet Activating Factor Production', None),
 ('Decreased Prostaglandin Production', ['Aspirin', 'Diclofenac']),
 ('Decreased Thromboxane Production', None)]

helper.drugs_with_similar_physiological_response('aripiprazole') # will yield a false negative

#=>
[('Decreased Dopamine Activity', None),
 ('Decreased Serotonin Activity', None)]

helper.drugs_with_physiological_effect('Decreased Dopamine Activity') # but this works

#=>
('Decreased Dopamine Activity',
 ['acetophenazine',
  'aripiprazole',
  'Chlorpromazine',
  'Chlorprothixene',
  'Clozapine',
  'deutetrabenazine',
  'Fluphenazine',
  'Haloperidol',
  'Mesoridazine',
  ...])

Drug's Pharmacokinetics

helper.pharmacokinetics('ibuprofen')

#=>
['Hepatic Metabolism', 'Renal Excretion']

helper.drugs_with_similar_pharmacokinetics('ibuprofen')

#=>
[('Drugs processed via Renal Excretion',
  ['Acetaminophen',
   'Albuterol',
   'Alprazolam',
   'Amoxicillin',
   'Aspirin',
   'Atenolol',
   ...]),
 ('Drugs processed via Hepatic Metabolism',
  ['Acetaminophen',
   'Albuterol',
   'Aspirin',
   'atorvastatin',
   ...])]

helper.drugs_with_pharmacokinetics('Hepatic Metabolism')

#=>
('Hepatic Metabolism',
 ['Acetaminophen',
  'Albuterol',
  'Aspirin',
  'atorvastatin',
  'celecoxib',
  'Codeine',
  ...])

Therapeutic Class

helper.therapeutic_class('azithromycin')

#=>
['Antibiotics', 'Macrolides']

helper.therapeutic_class('budesonide')

#=>
['Adrenergics in combination with corticosteroids or other drugs, excl. '
 'anticholinergics',
 'Corticosteroids',
 'Corticosteroids acting locally',
 'Corticosteroids, potent (group III)',
 'Glucocorticoids']

Drug Type

helper.drug_type('azithromycin')

#=>
['ANTIBACTERIALS,TOPICAL OPHTHALMIC', 'ERYTHROMYCINS/MACROLIDES']

helper.drug_type('budesonide')

#=>
['ANTI-INFLAMMATORIES,INHALATION',
 'ANTI-INFLAMMATORIES,NASAL',
 'ANTIASTHMA,OTHER',
 'GLUCOCORTICOIDS']

Class information of a given drug.

helper.drug_info('ketamine')

#=>
{'Drug Type': ['GENERAL ANESTHETICS,OTHER'],
 'Indications': ['Aneurysm',
                 'Angina Pectoris',
                 'Burns',
                 'Drug Hypersensitivity',
                 'Heart Failure',
                 'Hypertension',
                 'Intracranial Hypertension',
                 'Pain',
                 'Psychotic Disorders',
                 'Thyrotoxicosis',
                 'Unconsciousness'],
 'Mechanism of Action': [],
 'Name': 'Ketamine Hydrochloride',
 'Pharmacokinetics': None,
 'Physiological Effects': ['Blood Pressure Alteration',
                           'Decreased Cerebral Cortex Organized Electrical '
                           'Activity',
                           'Decreased Midbrain Organized Electrical Activity',
                           'Decreased Sensory-Somatic Nervous System '
                           'Organized Electrical Activity',
                           'General Anesthesia',
                           'Increased Epinephrine Activity',
                           'Increased Norepinephrine Activity'],
 'Therapeutic Class': ['Other general anesthetics']}

Drugs that can induce a reaction or condition.

helper.drug_induces(vomiting')

#=>
('Drugs that induce vomiting',
 ['Disulfiram', 'ethyl ether', 'Ipecac', 'Nitrous Oxide'])

helper.drug_induces(seizure disorder')

#=>
('Drugs that induce seizure disorder', ['Pentylenetetrazole'])

Drugs that may prevent a condition or acute reaction.

helper.drugs_that_may('prevent', 'seizure disorder')

#=>
('Drugs that may prevent seizure disorder',
 ['fosphenytoin', 'Magnesium Sulfate', 'Phenytoin', 'Thiamylal'])

helper.drugs_that_may('prevent', 'dementia')

#=>
('Drugs that may prevent alzheimer disease', ['Vitamin E'])

Drugs that may treat a condition or acute response.

helper.drugs_that_may('treat', 'seizures')

#=>
('Drugs that may treat seizure disorder',
 ['Acetazolamide',
  'Amobarbital',
  'Brivaracetam',
  'Carbamazepine',
  'clobazam',
  'Clonazepam',
  'clorazepate',
  'Corticotropin',
  'Diazepam',
  'Ethosuximide',
  'Ethotoin',
  'Etomidate',
  'ezogabine',
  'felbamate',
  'fosphenytoin',
  'gabapentin',
  ...])

helper.drugs_that_may('treat', 'depressive disorder')

#=>
('Drugs that may treat depressive disorder',
 ['Alprazolam',
  'Amitriptyline',
  'Amoxapine',
  'brexpiprazole',
  'Bupropion',
  'Buspirone',
  'Citalopram',
  'Clomipramine',
  'Desipramine',
  'Desvenlafaxine',
  'Doxepin',
  'duloxetine',
  'Escitalopram',
  'Fluoxetine',
  'Fluvoxamine',
  'Imipramine',
  'Isocarboxazid',
  'Isoflurane',
  'Kava preparation',
  'levomilnacipran',
  'Lithium',
  'Lorazepam',
  'lurasidone',
  'Maprotiline',
  'Melatonin',
  'Methylphenidate',
  'milnacipran',
  ...])

Drugs that can diagnose a condition.

helper.drugs_that_may('diagnose', '<condition>')

#=> # yet to find a condition name that yields results from NDFRT database

Contraindications

Not as straightforward. Supply 'with' instead of 'DISEASE'.

helper.contraindications('with', 'Drug Hypersensitivity')

#=>
('Drug Hypersensitivity contraindications',
 ['17-alpha-Hydroxyprogesterone',
  '4-Aminobenzoic Acid',
  'abacavir',
  'abciximab',
  'Acarbose',
  'Acebutolol',
  'acemannan',
  'Acetaminophen',
  'Acetazolamide',
  'Acetic Acid',
  ...])

helper.contraindications('with', 'bulimia')

#=>
('bulimia contraindications', ['Bupropion'])

helper.contraindications('with', 'schizophrenia')

#=>
('schizophrenia contraindications',
 ['Fenfluramine', 'Ginseng Preparation', 'Tetrahydrocannabinol'])

Class Subtypes

Use of this function appears to be limited currently.

helper.subtypes('')

#=> # Let me know if you find a valid use case that works.

Spelling Suggestions

helper.class_name_suggestions('amines')

#=>
['amines',
 'amides',
 'diamines',
 'azides',
 'amidines',
 'acids',
 'ascites',
 'apnea',
 'anions',
 'amnesia']

helper.class_name_suggestions('oxetine', only_drugs=True) # returns only drug names

#=>
['fluoxetine',
 'paroxetine',
 'reboxetine',
 'duloxetine',
 'oxypertine',
 'oxerutins',
 'oxetorone']

Statement of Credit

This product uses publicly available data from the U.S. National Library of Medicine (NLM), National Institutes of Health, Department of Health and Human Services; NLM is not responsible for the product and does not endorse or recommend this or any other product."

About

Python wrapper for RxClass API with helper functions to lookup: indications, contraindications, pharmacology, pharmacokinetics, chemical names, therapeutic class, mechanisms of action, physiological effects, and drug similarities.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages