API Reference - Utils
pyepisuite.utils
clear_cache()
Clear all cached results.
Source code in src/pyepisuite/utils.py
get_cache_dir()
get_cache_key(identifier)
Generate a unique cache key for an identifier.
Source code in src/pyepisuite/utils.py
get_search_cache_key(query_terms, search_type='general')
Generate a unique cache key for search queries.
Source code in src/pyepisuite/utils.py
is_valid_cas(cas)
Validate a CAS (Chemical Abstracts Service) number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cas
|
Any
|
The CAS number to validate. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the CAS number is valid, False otherwise. |
Source code in src/pyepisuite/utils.py
json_to_ecosar(json_data)
Convert a JSON response from the EcoSAR API to a Chemical instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
dict
|
The JSON response from the API (submit). For the response of submit method, |
required |
Returns:
Name | Type | Description |
---|---|---|
ResultEcoSAR |
A ResultEcoSAR instance. |
Source code in src/pyepisuite/utils.py
json_to_episuite(json_data)
Convert a JSON response from the EPISuite API to a Chemical instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_data
|
dict
|
The JSON response from the API. |
required |
Returns:
Name | Type | Description |
---|---|---|
ResultEPISuite |
A ResultEPISuite instance. |
Source code in src/pyepisuite/utils.py
load_from_cache(cache_key)
Load results from cache if available.
Source code in src/pyepisuite/utils.py
load_search_from_cache(cache_key)
Load search results from cache if available.
Source code in src/pyepisuite/utils.py
save_search_to_cache(cache_key, identifiers)
Save search results to cache.
Source code in src/pyepisuite/utils.py
save_to_cache(cache_key, epi_result, ecosar_result)
Save results to cache.
Source code in src/pyepisuite/utils.py
search_episuite(query_terms, use_cache=True)
Search the EPISuite API with a query term (SMILES, CAS, or chemical name).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_terms
|
List[str]
|
The terms to search for. |
required |
use_cache
|
bool
|
Whether to use caching for the search results. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
List[Identifiers]
|
List[Identifiers]: A list of Identifiers instances. |
Source code in src/pyepisuite/utils.py
search_episuite_by_cas(CASRN, use_cache=True)
Search the EPISuite API with a CAS number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
CASRN
|
List[str]
|
The CAS numbers to search for. |
required |
use_cache
|
bool
|
Whether to use caching for the search results. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
List[Identifiers]
|
List[Identifiers]: A list of Identifiers instances. |
Source code in src/pyepisuite/utils.py
submit_to_episuite(identifiers, use_cache=True)
Submit an identifier to the EPISuite API with caching support.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifiers
|
List[Identifiers]
|
List of identifiers; the identifiers obtained by calling search_episuite_by_cas. |
required |
use_cache
|
bool
|
Whether to use caching. Default is True. |
True
|
Returns:
Type | Description |
---|---|
tuple[List[ResultEPISuite], List[ResultEcoSAR]]
|
List[ResultEPISuite, ResultEcoSAR]: A list of ResultEPISuite and ResultEcoSAR instances. |