Skip to main content

A Python API client for US EPA's Computational Toxicology and Exposure APIs.

Project description

ctx-python

Python wrapper for U.S. EPA's Center for Computational Toxicology and Exposure (CTE) APIs.

Installation

ctx-python is available to install via pip.

pip install ctx-python

Initialization

Before being able to access CCTE's API, a user must acquire an API key. See https://www.epa.gov/comptox-tools/computational-toxicology-and-exposure-apis-about for more information.

Once an API key is obtained, ctx-python offers two options for passing the key for authentication:

  1. Supply the key at the point of instantiatation for each domain. This will look something like:
import ctxpy as ctx

chem = ctx.Chemical(x_api_key='648a3d70')
  1. ctx-python comes with a command-line tool that will utilize the .env file that will store the key. If no key is supplied at instantiation, ctx-python will automatically attempt to load this file and use a key stored there.
[user@host~]$ ctx_init --x-api-key 648a3d70

This will result in the .env file having three new environment variables added to the file: ctx_api_host, ctx_api_accept, ctx_x_api_key.

import ctxpy as ctx

chem = ctx.Chemical()

Usage

The backbone of ctx-python is its base Connection class. This class takes the appropriate authentication key and other important information for GET and POST commands and stores them for each call to the API. There are 5 different domains that have a specific Connection sub-class:

  • Chemical
  • Chemical Lists (limited functionality)
  • Exposure
  • Hazard

Chemical

The Chemical class provides capabilities to:

  • search for chemicals by their names, CAS-RNs, DTXSIDs, or other potential identifiers
  • retrieve details about a chemical from a DTXSID (single chemical or batch search) or DTXCID (single chemical only)
  • search for chemicals that match features common in Mass Spectrometry (i.e., a range of molecular mass, chemical formula, or by DTXCID)
import ctx

# Start an instance of the Chemical class
chem = ctx.Chemical()

# Search for some data
chem.search(by='equals', query='toluene')
chem.search(by='starts-with', query='atra')
chem.search(by='contains', query='-00-')
chem.search(by='batch', query=['50-00-0','BPA'])


# Get some chemical details
chem.details(by='dtxsid', query='DTXSID7020182')
chem.details(by='dtxcid', query='DTXCID701805')
chem.details(by='batch', query=['DTXSID7020182','DTXSID3021805'])

# Search for some MS info
chem.msready(by='dtxcid', query='DTXCID30182')
chem.msready(by='formula', query='C17H19NO3')
chem.msready(by='mass', start=200.9, end=200.93)

Exposure

The Exposure class provides capabilities to search EPA's Chemical and Products Database (CPDat), High-throughput Toxicokinetics data (httk), and return predictions from its Quantitative Structure-Use Relationship (QSUR) models and from Systematic Empirical Evaluation of Models (SEEM) framework for exposure predictions.

import ctx

# Start an instance of the Exposure class
expo = ctx.Exposure()

# Search for data reported data from CPDat
expo.search_cpdat(vocab_name="fc", dtxsid="DTXSID7020182")
expo.search_cpdat(vocab_name='puc', dtxsid='DTXSID7020182')
expo.search_cpdat(vocab_name='lpk', dtxsid='DTXSID7020182')

# Get httk data results
expo.search_httk(dtxsid='DTXSID7020182')

# Get controlled vocabularies from CPDat
expo.get_cpdat_vocabulary(vocab_name='fc')
expo.get_cpdat_vocabulary(vocab_name='puc')
expo.get_cpdat_vocabulary(vocab_name='lpk')

# Get predictions of functional use
expo.search_qsur(dtxsid='DTXSID7020182')

# Get exposure pathway predictions
expo.search_exposures(by='pathways',dtxsid='DTXSID7020182')

# Get exposure estimates from SEEM framework
expo.search_exposures(by='seem',dtxsid='DTXSID7020182')

With all search methods in the Exposure class, it is possible to provide a list of DTXSIDs and receive back a pandas DataFrame for all submitted chemicals in the list.

expo.search_qsurs(dtxsid=['DTXSID7020182','DTXSID3021805'])

Hazard

The Hazard class provides capabilities to access all hazard endpoints from the CTX APIs. These endpoints provide access to EPA's Toxicity Values Database (ToxValDB) and other data sources used by EPA's Office of Research and Development.

import ctxpy as ctx

haz = ctx.Hazard()

## Search ToxValDB for cancer data on specific chemical
haz.search_toxvaldb(by='cancer', dtxsid='DTXSID7020182')

## Search ToxValDB for all chemical's human data
haz.search(by='human',dtxsid='DTXSID7020182')

## Search ToxValDB for all chemical's ecological data
haz.search(by='eco',dtxsid='DTXSID7020182')

## Search chemical's skin/eye irritant data
haz.search(by='skin-eye',dtxsid='DTXSID7020182')

## Search chemical's cancer data
haz.search(by='cancer',dtxsid='DTXSID7020182')

## Search chemical's genetic toxicity data (summary data only )
haz.search(by='genetox',dtxsid='DTXSID7020182')

## Search chemical's genetic toxicity detailed data
haz.search(by='genetox',dtxsid='DTXSID7020182',summary=False)

Explicit batch searching is also available for the Hazard class.

haz.batch_search(by='human',dtxsid=['DTXSID7020182','DTXSID3021805'])

Disclaimer

This software/application was developed by the U.S. Environmental Protection Agency (USEPA). No warranty expressed or implied is made regarding the accuracy or utility of the system, nor shall the act of distribution constitute any such warranty. The USEPA has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the USEPA. The USEPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by the USEPA or the United States Government.

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

ctx_python-0.0.1a11.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctx_python-0.0.1a11-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file ctx_python-0.0.1a11.tar.gz.

File metadata

  • Download URL: ctx_python-0.0.1a11.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ctx_python-0.0.1a11.tar.gz
Algorithm Hash digest
SHA256 afd4341f11174518f3bf3e3c307ac34b6b316b758c91b25bded983d68ad99583
MD5 44110d5863924095356b0067ca3aa0a5
BLAKE2b-256 425fceefa66864a7a1304c03a3b1f1282e9cef54da07db88bb690e6149a3d506

See more details on using hashes here.

File details

Details for the file ctx_python-0.0.1a11-py3-none-any.whl.

File metadata

  • Download URL: ctx_python-0.0.1a11-py3-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ctx_python-0.0.1a11-py3-none-any.whl
Algorithm Hash digest
SHA256 aead02351a5f4ad25f83852d0912c638ff7820f8863d520dddfc753a6ed46e6e
MD5 04f018c945ff5e47168aac6e63e92996
BLAKE2b-256 adc6a69175994b3488e7dcac6abc483d842489918e23bb9c91a7f2d320badc03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page