A tool to resolve messy drug names in biomedical datasets to standard identifiers
Project description
Drug Resolver
This package offers a simple way to resolve drug names to their corresponding PubChem entries.
This is useful for identifying unknown drug synonyms or matching drug synonyms across different datasets in an automated way.
Installation
pip install drug-resolver
Usage
from drug_resolver import resolve_drug
d1 = resolve_drug("tetracycline hcl")
print(d1)
"""
ResolvedDrug(
name='Tetracycline hydrochloride',
pubchem_compound_id='54704426',
pubchem_substance_id='103591391',
smiles='CN(C)C1C(=O)C(C(N)=O)=C(O)C2(O)C(=O)C3=C(O)c4c(O)cccc4C(C)(O)C3CC12.Cl',
drug_classes=None,
fda_approval=<FDAApprovalStatus.APPROVED: 'APPROVED'>,
pubchem_parent_compound_id='54675776')
"""
d2 = resolve_drug("Sumycin")
print(d2)
"""
ResolvedDrug(
name='Tetracycline',
pubchem_compound_id='54675776',
pubchem_substance_id='124766046',
smiles='CN(C)C1C(=O)C(C(N)=O)=C(O)C2(O)C(=O)C3=C(O)c4c(O)cccc4C(C)(O)C3CC12',
drug_classes=frozenset({'Established Pharmacologic Class [EPC] - Tetracycline-class Antimicrobial'}),
fda_approval=<FDAApprovalStatus.APPROVED: 'APPROVED'>,
pubchem_parent_compound_id=None)
"""
assert d1 == d2 # True
The equality operator between ResolvedDrug objects will return True under the following conditions:
- The
pubchem_compound_idattribute is the same - The
pubchem_substance_idattribute is the same - The
smilesstrings refer to the same molecule - Two compounds share the same
pubchem_parent_compound_idor thepubchem_compound_idis the same as thepubchem_parent_compound_idof the other compound.
Caching
You can set the env variable DRUG_RESOLVER_REQUEST_CACHE to a filename. A sqlite database will be created
at the filename and all PubChem requests will be cached there. This is useful for avoiding repeated requests
to the PubChem API. By default, the cache will be stored in memory and will be lost when the program exits.
Here is an example of the cache works:
(.venv) drug-name-resolver % DRUG_RESOLVER_REQUEST_CACHE=/tmp/test.sqlite3 ipython
Python 3.11.11 (main, Dec 3 2024, 17:20:40) [Clang 16.0.0 (clang-1600.0.26.4)]
In [1]: from drug_resolver import resolve_drug
In [2]: %time d1 = resolve_drug("tetracycline hcl")
CPU times: user 48.1 ms, sys: 10.7 ms, total: 58.8 ms
Wall time: 1.53 s
(.venv) drug-name-resolver % ls -lh /tmp/test.sqlite3
-rw-r--r--@ 1 quinnj2 wheel 468K Jan 30 14:51 /tmp/test.sqlite3
(.venv) drug-name-resolver % DRUG_RESOLVER_REQUEST_CACHE=/tmp/test.sqlite3 ipython
Python 3.11.11 (main, Dec 3 2024, 17:20:40) [Clang 16.0.0 (clang-1600.0.26.4)]
In [1]: from drug_resolver import resolve_drug
In [2]: %time d1 = resolve_drug("tetracycline hcl")
CPU times: user 24.2 ms, sys: 4.06 ms, total: 28.3 ms
Wall time: 29.3 ms
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file drug_resolver-0.0.5.tar.gz.
File metadata
- Download URL: drug_resolver-0.0.5.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61cd177bccbe74cc8a23ed415cd132d3e29790ceefa7298be88a91847e574188
|
|
| MD5 |
17486d26c52d26cff16f96e8ce7848e6
|
|
| BLAKE2b-256 |
b6271c66ffe3fd1bc7dea3e92e6dbc4c768660022958a531d5f2fd79a4df1b46
|
Provenance
The following attestation bundles were made for drug_resolver-0.0.5.tar.gz:
Publisher:
release.yml on tansey-lab/drug-resolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
drug_resolver-0.0.5.tar.gz -
Subject digest:
61cd177bccbe74cc8a23ed415cd132d3e29790ceefa7298be88a91847e574188 - Sigstore transparency entry: 167277537
- Sigstore integration time:
-
Permalink:
tansey-lab/drug-resolver@4595e2a65338fdcb1f88d13af54d941e56c40d4e -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/tansey-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4595e2a65338fdcb1f88d13af54d941e56c40d4e -
Trigger Event:
push
-
Statement type:
File details
Details for the file drug_resolver-0.0.5-py3-none-any.whl.
File metadata
- Download URL: drug_resolver-0.0.5-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7886e2efb884c592b0cf528f4b42efc9350ed9177527a4a5238c5456d4f0221e
|
|
| MD5 |
2665aefa6b185c9fb55decfd14375253
|
|
| BLAKE2b-256 |
c4c02baa2914a1dd90dfcd894443b4fe753e2be7d9d09063bb538761f454f5c6
|
Provenance
The following attestation bundles were made for drug_resolver-0.0.5-py3-none-any.whl:
Publisher:
release.yml on tansey-lab/drug-resolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
drug_resolver-0.0.5-py3-none-any.whl -
Subject digest:
7886e2efb884c592b0cf528f4b42efc9350ed9177527a4a5238c5456d4f0221e - Sigstore transparency entry: 167277538
- Sigstore integration time:
-
Permalink:
tansey-lab/drug-resolver@4595e2a65338fdcb1f88d13af54d941e56c40d4e -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/tansey-lab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4595e2a65338fdcb1f88d13af54d941e56c40d4e -
Trigger Event:
push
-
Statement type: