Write scripts that can get drugbank data without redistributing it
Project description
drugbank_downloader
Don't worry about DrugBank licensing and distribution rules -
just use drugbank_downloader
to write code that knows how
to download it and use it automatically.
Installation
$ pip install drugbank-downloader
Download A Specific Version
import os
from drugbank_downloader import download_drugbank
username = ... # suggestion: load from environment with os.getenv('DRUGBANK_USERNAME')
password = ...
path = download_drugbank(version='5.1.7', username=username, password=password)
# This is where it gets downloaded: ~/.data/drugbank/5.1.7/full database.xml.zip
expected_path = os.path.join(os.path.expanduser('~'), '.data', 'drugbank', '5.1.7', 'full database.xml.zip')
assert expected_path == path.as_posix()
After it's been downloaded once, it's smart and doesn't need to download again. It gets stored
using pystow
automatically in the ~/.data/drugbank
directory.
Download the Latest Version
First, you'll have to install bioversions
with pip install bioversions
, whose job it is to look up the latest
version of many databases. Then, you can modify the previous code slightly:
import os
from drugbank_downloader import download_drugbank
username = ... # suggestion: load from environment with os.getenv('DRUGBANK_USERNAME')
password = ...
path = download_drugbank(username=username, password=password)
# This is where it gets downloaded: ~/.data/drugbank/5.1.7/full database.xml.zip based on the latest
# version, as of December 14th, 2020.
expected_path = os.path.join(os.path.expanduser('~'), '.data', 'drugbank', '5.1.7', 'full database.xml.zip')
assert expected_path == path.as_posix()
Store in a Different Place
If you want to store the data elsewhere using pystow
(e.g., in PyOBO I also keep a copy of this file), you can use
the prefix
argument.
import os
from drugbank_downloader import download_drugbank
username = ... # suggestion: load from environment with os.getenv('DRUGBANK_USERNAME')
password = ...
path = download_drugbank(version='5.1.7', username=username, password=password, prefix=['pyobo', 'raw', 'drugbank'])
# This is where it gets downloaded: ~/.data/pyobo/raw/drugbank/5.1.7/full database.xml.zip
expected_path = os.path.join(os.path.expanduser('~'), '.data', 'pyobo', 'raw', 'drugbank', '5.1.7',
'full database.xml.zip')
assert expected_path == path.as_posix()
Download via CLI
After installing, run the following CLI command to ensure it and send the path to stdout
$ drugbank_downloader --username *** --password ***
Project details
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
Hashes for drugbank_downloader-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68f03aea842ecacf0a610c4fbac42899505ac31ed0751d6b4a68c8d7f35b39db |
|
MD5 | a1256363a92528b2392cdb71d6bac0c5 |
|
BLAKE2b-256 | 6c8c4e4888b1d5a6580a6fcbaeda9eeac21e46f6c5fa7842aedb1279e959fb55 |
Hashes for drugbank_downloader-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 072316eca265ca8111f3ebaf9d720ef4a5954f7a3f9e4e0c7c60375ddd6352e1 |
|
MD5 | bf745b92c756e9508ca98b1ff941b6a7 |
|
BLAKE2b-256 | 1e04f9f372a1f14dcedf7ef63b53449d1719aa80774a33b4e445c937d2fd74f1 |