mkt.databases.chembl

ChEMBL molecule-search client for resolving drug names to ChEMBL IDs and metadata.

Provides ChEMBLMoleculeSearch and related clients plus return_chembl_id() to map drug names/synonyms to ChEMBL identifiers and molecule records.

Functions

return_chembl_id(drug)

Return the ChEMBL ID for a given drug name.

Classes

ChEMBL(id, url_suffix, url_base, url_query, ...)

ChEMBL API client.

ChEMBLMolecule(id, url_suffix, url_base, ...)

ChEMBL molecule API client.

ChEMBLMoleculeExact(id, url_suffix, ...)

ChEMBL molecule exact match API client.

ChEMBLMoleculePreferred(id, url_suffix, ...)

ChEMBL molecule preferred match API client.

ChEMBLMoleculeSearch(id, url_suffix, ...)

ChEMBL molecule search API client.

class mkt.databases.chembl.ChEMBL(id: str, url_suffix: str, url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None)[source]

Bases: RESTAPIClient

ChEMBL API client.

__init__(id: str, url_suffix: str, url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None) None
check_molecules() str | None[source]

Check that a single molecule is returned for the query.

get_chembl_id() str | None[source]

Get the ChEMBL ID for the queried molecule.

id: str

ID for querying specific entities.

params: dict

Parameters for the API query.

query_api()[source]

Query the ChEMBL API for a given URL.

update_params(**kwargs) None[source]

Update the parameters for the API query.

update_url(url: str) None[source]

Update the URL for querying the ChEMBL API.

url_base: str = 'https://www.ebi.ac.uk/chembl/api/data'

Base URL for the ChEMBL API.

url_query: str | None = None

URL query for specific queries.

url_suffix: str

URL suffix to update for specific queries.

verbose: bool = False

Flag to enable verbose logging.

class mkt.databases.chembl.ChEMBLMolecule(id: str, url_suffix: str = '/molecule', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None)[source]

Bases: ChEMBL

ChEMBL molecule API client.

__init__(id: str, url_suffix: str = '/molecule', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None) None
adjudicate_preferred_name(str_in: str | None = None) str[source]

Return the adjudicated preferred name for the queried molecule.

Parameters:

str_in (str | None) – The input string to adjudicate the preferred name. If None, will not compare to input string.

Returns:

The adjudicated preferred name or the original ID if no preferred name is found or matches the input string.

Return type:

str

params: dict

Parameters for the molecule API query.

return_preferred_name() str | None[source]

Return the preferred name for the queried molecule.

return_smiles() str | None[source]

Return the SMILES string for the queried molecule.

url_suffix: str = '/molecule'

URL suffix for querying exact molecule match in ChEMBL.

class mkt.databases.chembl.ChEMBLMoleculeExact(id: str, url_suffix: str = '/molecule', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None)[source]

Bases: ChEMBL

ChEMBL molecule exact match API client.

__init__(id: str, url_suffix: str = '/molecule', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None) None
params: dict

Parameters for the molecule exact match API query.

url_suffix: str = '/molecule'

URL suffix for querying exact molecule match in ChEMBL.

class mkt.databases.chembl.ChEMBLMoleculePreferred(id: str, url_suffix: str = '/molecule', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None)[source]

Bases: ChEMBL

ChEMBL molecule preferred match API client.

__init__(id: str, url_suffix: str = '/molecule', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None) None
params: dict

Parameters for the molecule preferred match API query.

url_suffix: str = '/molecule'

URL suffix for querying exact molecule match in ChEMBL.

class mkt.databases.chembl.ChEMBLMoleculeSearch(id: str, url_suffix: str = '/molecule/search', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None)[source]

Bases: ChEMBL

ChEMBL molecule search API client.

__init__(id: str, url_suffix: str = '/molecule/search', url_base: str = 'https://www.ebi.ac.uk/chembl/api/data', url_query: str | None = None, params: dict = <factory>, verbose: bool = False, _json: dict | None = None) None
url_suffix: str = '/molecule/search'

URL suffix for querying molecule search in ChEMBL.

mkt.databases.chembl.return_chembl_id(drug: str)[source]

Return the ChEMBL ID for a given drug name.

Parameters:

drug (str) – The name of the drug to search for in ChEMBL.

Returns:

A tuple containing the ChEMBL ID and the source of the ID (exact, preferred, or search);

if no ID is found, returns (None, None).

Return type:

tuple