A python client to interact with enviPath
Project description
enviPath Python
Python client for enviPath - the environmental contaminant biotransformation pathway resource.
The client allows you to include enviPath directly into you Python code. This is done by using the REST API of enviPath, all calls to Python functions are translated to remote calls to our enviPath. Please see below for documentation.
Quickstart
pip install --upgrade enviPath-python
from pprint import pprint
from enviPath_python import enviPath
eP = enviPath('https://envipath.org')
bbd = eP.get_package('https://envipath.org/package/32de3cf4-e3e6-4168-956e-32fa5ddb0ce1')
bbd_pws = bbd.get_pathways()
pprint(bbd_pws[0].get_description())
Documentation
The enviPath-python documentation can be found here.
If you are new to enviPath our wiki might also contain some value information.
Examples
Searching data
from enviPath_python import enviPath
eP = enviPath('https://envipath.org')
# get package(s) that should be searched
bbd = eP.get_package('https://envipath.org/package/32de3cf4-e3e6-4168-956e-32fa5ddb0ce1')
soil = eP.get_package('https://envipath.org/package/5882df9c-dae1-4d80-a40e-db4724271456')
# returns a dictionary with properly initialized objects
res = eP.search('c1ccccc1', [bbd, soil])
print(res)
# or use a package to search it
res = bbd.search('c1ccccc1')
print(res)
Accessing Data
from pprint import pprint
from enviPath_python import enviPath
eP = enviPath('https://envipath.org')
# get the EAWAG BBD package
bbd = eP.get_package('https://envipath.org/package/32de3cf4-e3e6-4168-956e-32fa5ddb0ce1')
# access collections (e.g. compounds)
# other collections such as reactions, rules, pathways, etc work the same way
compounds = bbd.get_compounds()
for c in compounds[:10]:
print(c.get_id(), c.get_name(), c.get_smiles())
Accessing private data
import getpass
from enviPath_python import enviPath
eP = enviPath('https://envipath.org')
# get username + password
username = input("Enter username")
password = getpass.getpass(prompt="Password for {}".format(username))
eP.login(username, password)
print(eP.who_am_i())
for p in eP.get_packages()[:10]:
print(p)
Predict Pathways
from enviPath_python import enviPath
from enviPath_python.objects import Pathway
from time import sleep
eP = enviPath('https://envipath.org')
# obtain the currently logged in user
me = eP.who_am_i()
# get the package the pathway should be stored in
package = me.get_default_package()
# will trigger the pathway prediction
pw = Pathway.create(package, smiles='CC1(C)C2CCC1(C)C(=O)C2')
# wait until the prediction finished
while pw.is_running():
print("Sleeping for three secs...")
sleep(3)
# check result
if pw.has_failed():
exit(1)
else:
for node in pw.get_nodes():
print(node.get_smiles())
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
envipath_python-0.2.3.tar.gz
(43.2 kB
view details)
Built Distribution
File details
Details for the file envipath_python-0.2.3.tar.gz
.
File metadata
- Download URL: envipath_python-0.2.3.tar.gz
- Upload date:
- Size: 43.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d89d730fd5c2b5c98a8589838369d75ebc5eb985608eecc1630516bfd6e501b4 |
|
MD5 | 45df6e99f00871046468fe5dba4ae4af |
|
BLAKE2b-256 | 82da6c61ea91b070110c12dc558713c122b5e1348d10131c61dc1dff1815ac33 |
File details
Details for the file enviPath_python-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: enviPath_python-0.2.3-py3-none-any.whl
- Upload date:
- Size: 46.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3721688c55b153d32c55cfe9e53431244712ed9ad9187672876ab3f7c33a46f |
|
MD5 | 8c3042609f27588d46ffcc556ce676f4 |
|
BLAKE2b-256 | 946fae8d703ec0ce68946fa4ff2a486f850b61d201a89f267afb80eac2046685 |