webservices.unichem¶
Substance cross references from UniChem.
UniChem maps a structure, identified by its InChIKey, to the entries of many chemistry databases, which gives cross references for a substance without having to query every database separately.
from pymetadata.webservices.unichem import UnichemQuery
query = UnichemQuery()
xrefs = query.query_xrefs_for_inchikey("AAOVKJBEBIDNHE-UHFFFAOYSA-N")
See https://www.ebi.ac.uk/unichem/info/webservices.
UnichemSource
dataclass
¶
UnichemSource(
sourceID,
srcUrl,
name,
nameLabel,
nameLong,
UCICount,
baseIdUrl,
description,
created,
lastUpdated,
srcDetails,
srcReleaseDate,
srcReleaseNumber,
updateComments,
private,
)
Unichem source.
src_id (the src_id for this source), src_url (the main home page of the source), name (the unique name for the source in UniChem, always lower case), name_long (the full name of the source, as defined by the source), name_label (A name for the source suitable for use as a 'label' for the source within a web-page. Correct case setting for source, and always less than 30 characters), description (a description of the content of the source), base_id_url_available (an flag indicating whether this source provides a valid base_id_url for creating cpd-specific links [1=yes, 0=no]). base_id_url (the base url for constructing hyperlinks to this source [append an identifier from this source to the end of this url to create a valid url to a specific page for this cpd], unless aux_for_url=1), aux_for_url (A flag to indicate whether the aux_src field should be used to create hyperlinks instead of the src_compound_id [1=yes, 0=no]
UnichemQuery
¶
Queries against the UniChem web service.
The sources of UniChem are retrieved once and shared by all instances.
Responses are cached on disk for CACHE_DURATION_ONTOLOGY hours, see
pymetadata.CACHE_USE. If UniChem cannot be reached, cached content is used
however old it is.
Initialize the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_path
|
Path | None
|
directory for cached responses, defaults to
|
None
|
cache
|
bool | None
|
cache responses, defaults to |
None
|
get_sources
¶
Get the databases known to UniChem, from the cache or the service.
Returns:
| Type | Description |
|---|---|
dict[int, UnichemSource]
|
The sources by their UniChem source id. |
Raises:
| Type | Description |
|---|---|
WebserviceError
|
if the sources are neither cached nor retrievable |
query_xrefs_for_inchikey
¶
Get the cross references for a structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inchikey
|
str
|
InChIKey of the structure, e.g.,
|
required |
Returns:
| Type | Description |
|---|---|
list[CrossReference]
|
One cross reference per database which contains the structure. |