pharmpy is an umbrella library for searching the FDA NDC directory, Established Pharmacologic Class (EPC), Anatomical Therapeutic Chemical (ATC) through RxNav, and some other APIs on RxNav.
Project description
pharmpy
pharmpy
is an umbrella Python library for searching the FDA NDC directory, Established Pharmacologic Class (EPC), Anatomical Therapeutic Chemical (ATC) through RxNav, and some other APIs on RxNav.
Installing
Installing from the source:
$ git clone git@github.com:yubin-park/pharmpy.git
$ cd pharmpy
$ python setup.py develop
Or, simply using pip
:
$ pip install pharmpy
A NOTE for the users who want to use RxNav functions such as ATC and Drug Interactions. For those, we strongly recommend using the RxNav-in-a-Box rather than the RxNav REST APIs.
The RxNav-in-a-Box is a Docker conatiner image that installs on your local machine.
To use the image, please follow the set-up instructions, which are available inside the downloadable zip file, and carefully read the UMLS license agreement.
If you decide to use the RxNAV REST APis, you should control the rate limit (20 calls per second) by yourself.
This pharmpy
module does not control the rate limit by itself.
File Structure
pharmpy/
: The package source code is located here.data/
: The raw data files downloaded from the FDA website. If you are using the RxNav functions and data, the caches of the query results will be stored in this folder as well.epc.py
: Established Pharmacologic Class (EPC) engine from the FDA websiterxcui.py
: A RxNorm Concept Unique Identifier (RxCUI) module that maps from NDC to RxCUI. [Dependancy: RxNav]atc.py
: A mapping from NDCs to Level-4 Anatomical Therapeutic Chemical (ATC). [Dependency: RxNav]druginter.py
: A mapping from a list of NDCs to a potential drug-drug interactions. [Dependency: RxNav]utils.py
: A module for readings data files
tests/
: test scripts to check the validity of the outputs.LICENSE.txt
: Apache 2.0.README.md
: This README file.setup.py
: a set-up script.
Code Examples
pharmpy
is really simple to use.
Please see some examples below.
NOTE that all functions used below have docstrings.
If you want to see the input parameter specifications,
please type print(<instance>.<function>.__doc__)
.
Using EPC
>>> from pharmpy.epc import EPCEngine
>>> epe = EPCEngine()
>>> res = epe.get_epc("50090347201")
>>> import json
>>> print(json.dumps(res, indent=2))
{
"ndc": "50090-3472",
"name_proprietary": "JANUVIA",
"name_generic": "sitagliptin",
"substance_lst": [
"SITAGLIPTIN PHOSPHATE"
],
"pc_lst": [
"Dipeptidyl Peptidase 4 Inhibitor [EPC]",
"Dipeptidyl Peptidase 4 Inhibitors [MoA]"
]
}
>>>
Using RxCUI
>>> from pharmpy.rxcui import RxCUIEngine
>>> rce = RxCUIEngine()
>>> res = rce.get_rxcui("50090347201")
>>> print(json.dumps(res, indent=2))
"665044"
>>>
Using ATC
>>> from pharmpy.atc import ATCEngine
>>> ae = ATCEngine()
>>> res = ae.get_atc("50090347201")
>>> print(json.dumps(res, indent=2))
[
{
"id": "A10BH",
"name": "Dipeptidyl peptidase 4 (DPP-4) inhibitors"
}
]
>>>
Using DrugInter
>>> from pharmpy.druginter import DrugInterEngine
>>> dre = DrugInterEngine()
>>> res = dre.get_interactions_from_rxcui(["88014","8123"])
>>> print(json.dumps(res, indent=2))
[
{
"pair": [
"8123",
"88014"
],
"desc": [
"[ONCHigh] Triptans - monoamine oxidase (MAO) inhibitors"
]
}
]
>>>
Warming-up Caches
For the RxNav functions, pharmpy
keeps cache, so that you do not need to query again for the same results.
For most use cases, we recommend you warm up the cache before using any of the RxNav functions.
The warm-up process goes through a comprehensive list of NDCs, and store all results into a local drive.
The total process takes up about 6 hours, however, you would rarely need to query new results after warming up the cache.
- RxCUI Cache Warm-up
>> from pharmpy.rxcui import RxCUIEngine
>> rce = RxCUIEngine()
>> rce.run_cache() # this takes about 2-3 hours using RxNav-in-a-Box
- ATC Cache Warm-up
from pharmpy.atc import ATCEngine
ae = ATCEngine()
ae.run_cache() # takes about 10-20 minutes using RxNav-in-a-Box
- DrugInter Cache Warm-up
from pharmpy.druginter import DrugInterEngine
dre = DrugInterEngine()
dre.run_cache() # takes about 2 hours using RxNav-in-a-Box
The caches are stored in a local drive indefinitely. Thus, you just need to run these warm-up scripts periodically whenever you update the RxNav-in-a-Box monthly images.
Please refer to the test scripts under the tests/
folder if you want to see other example use cases.
License
Apache 2.0
Authors
Yubin Park, PhD
References
- https://open.fda.gov/data/ndc/
- https://www.accessdata.fda.gov/cder/ndctext.zip
- https://www.fda.gov/drugs/drug-approvals-and-databases/ndc-product-file-definitions
- https://rxnav.nlm.nih.gov/RxNav-in-a-Box.html
- https://mor.nlm.nih.gov/pubs/pdf/2018-amia-lp-poster.pdf
- https://rxnav.nlm.nih.gov/APIsOverview.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pharmpy-0.0.2.tar.gz
.
File metadata
- Download URL: pharmpy-0.0.2.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93b83a443d1a44dd9ffabffc44d7cc19186d005c8e1c856df6de78b2edc82cc0 |
|
MD5 | 5b80a6b54d194fcc09455e092ec3b972 |
|
BLAKE2b-256 | bb1a82a2e7560f154d1ae17fd6685d05a57eee8c7ec7c5b7b26b6625aea443f9 |
File details
Details for the file pharmpy-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pharmpy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 13.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 853d4602c5b4bb48298ca75cd6c3c4f10f54e4de650e6d1c48e741dbfa3e4f43 |
|
MD5 | 67b64b363342bc53116616fe9b7c7218 |
|
BLAKE2b-256 | 34bfe5108817326612e00171ede2f678f577a102788021040b8e60df3bf32c29 |