Skip to main content

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 website
    • rxcui.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

Metadata

Release files for pharmpy 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pharmpy 0.0.2
File Size Uploaded
pharmpy-0.0.2.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pharmpy 0.0.2
File Interpreter ABI Platform
pharmpy-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 MB

Release files / pharmpy-0.0.2.tar.gz

Download URL pharmpy-0.0.2.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
93b83a443d1a44dd9ffabffc44d7cc19186d005c8e1c856df6de78b2edc82cc0
BLAKE2b-256 checksum
How to use checksums
bb1a82a2e7560f154d1ae17fd6685d05a57eee8c7ec7c5b7b26b6625aea443f9
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pharmpy-0.0.2-py3-none-any.whl

Download URL pharmpy-0.0.2-py3-none-any.whl
Size 13.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
853d4602c5b4bb48298ca75cd6c3c4f10f54e4de650e6d1c48e741dbfa3e4f43
BLAKE2b-256 checksum
How to use checksums
34bfe5108817326612e00171ede2f678f577a102788021040b8e60df3bf32c29
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page