WARNING: This vignette is a work in progress. If you have questions or would like to see more features, please open an issue at bhklab/AnnotationGx
The ChEMBL database contains information on bioactive drug-like small molecules. The information includes 2-D structures, calculated properties; logP, Molecular Weight, Lipinski Parameters, and abstracted bioactivities; binding constants and ADMET data. The data is curated from primary scientific literature. The ChEMBL API allows for the data to be made available for retrieval in a programmatic fashion. We can use the API to query CHEMBL ID of a compound, retrieve all molecule mechanisms of action, query compound_record resource and molecule resource from the ChEMBL database.
ChEMBL is licensed under CC BY-SA 3.0. Source: https://www.ebi.ac.uk/chembl/
library(AnnotationGx)
Given a ChEMBL ID, we can retrieve the molecule mechanisms of action from the
ChEMBL database using the getChemblMechanism() function.
NOTE: This is a specialized function that queries the API for the mechanism resource only. To query other resources, please see the Custom Queries section.
mechs <- run_chembl_example(getChemblMechanism("CHEMBL1413"))
#> [00:34:30][INFO][AnnotationGx::getChemblMechanism] Retrieving ChEMBL Mechanism information for 1 ChEMBL IDs.
mechs
#> action_type binding_site_comment direct_interaction disease_efficacy
#> <char> <lgcl> <int> <int>
#> 1: CHELATING AGENT NA 1 1
#> 2: CHELATING AGENT NA 1 1
#> max_phase mec_id
#> <int> <int>
#> 1: 4 2200
#> 2: 4 2224
#> mechanism_comment
#> <char>
#> 1: Trivalent metal cations chelating agent; inhibition of the metal-dependent enzymes that are responsible for the degradation of peroxides within the fungal cell
#> 2: Trivalent metal cations chelating agent; inhibition of the metal-dependent enzymes that are responsible for the degradation of peroxides within the fungal cell
#> mechanism_of_action mechanism_refs molecular_mechanism
#> <char> <list> <int>
#> 1: Iron chelating agent <data.frame[3x3]> 1
#> 2: Aluminium chelating agent <data.frame[3x3]> 1
#> molecule_chembl_id parent_molecule_chembl_id record_id selectivity_comment
#> <char> <char> <int> <lgcl>
#> 1: CHEMBL1413 CHEMBL1413 1343970 NA
#> 2: CHEMBL1413 CHEMBL1413 1343970 NA
#> site_id target_chembl_id variant_sequence
#> <lgcl> <char> <lgcl>
#> 1: NA CHEMBL2363058 NA
#> 2: NA CHEMBL2366381 NA
When ChEMBL is available, this example returns mechanisms of action. Live examples report request failures and allow the vignette to continue if the service is unavailable.
The ChEMBL API allows for a wide range of queries. We have specialized one function, but are open to incorporating more. Please open an issue at bhklab/AnnotationGx with an idea of a specialized function that meets a use case.
A query to the API follows the following format:
https://www.ebi.ac.uk/chembl/api/data/[resource]?[field]__[filter_type]=[value]&format=[format]
More information can be found at the API Documentation
In summary, the requirements for a query are:
resource to be queriedfield to be queriedfilter_type to be usedvalue to be used for the filterformat of the returned data (default is JSON)For example, the query for the example in the above section would be: “https://www.ebi.ac.uk/chembl/api/data/mechanism?molecule_chembl_id__in=CHEMBL1413&format=json” where:
resource is “mechanism”field is “molecule_chembl_id”filter_type is “in”value is “CHEMBL1413”format is “json”These parameters can be used in the
queryChemblAPI(resource, field, filter_type, value, format = "json") function
to query the ChEMBL API.
NOTE: unlike the getChemblMechanism() function which returns a data.table,
the queryChemblAPI() function returns the raw data unformatted
run_chembl_example(
queryChemblAPI("mechanism", "molecule_chembl_id", "in", "CHEMBL1413")
)
#> $mechanisms
#> action_type binding_site_comment direct_interaction disease_efficacy
#> 1 CHELATING AGENT NA 1 1
#> 2 CHELATING AGENT NA 1 1
#> max_phase mec_id
#> 1 4 2200
#> 2 4 2224
#> mechanism_comment
#> 1 Trivalent metal cations chelating agent; inhibition of the metal-dependent enzymes that are responsible for the degradation of peroxides within the fungal cell
#> 2 Trivalent metal cations chelating agent; inhibition of the metal-dependent enzymes that are responsible for the degradation of peroxides within the fungal cell
#> mechanism_of_action
#> 1 Iron chelating agent
#> 2 Aluminium chelating agent
#> mechanism_refs
#> 1 20964457, 23416050, Ciclopirox#cite_note-pmid12760852-4, PubMed, PubMed, Wikipedia, http://europepmc.org/abstract/MED/20964457, http://europepmc.org/abstract/MED/23416050, http://en.wikipedia.org/wiki/Ciclopirox#cite_note-pmid12760852-4
#> 2 20964457, 23416050, Ciclopirox#cite_note-pmid12760852-4, PubMed, PubMed, Wikipedia, http://europepmc.org/abstract/MED/20964457, http://europepmc.org/abstract/MED/23416050, http://en.wikipedia.org/wiki/Ciclopirox#cite_note-pmid12760852-4
#> molecular_mechanism molecule_chembl_id parent_molecule_chembl_id record_id
#> 1 1 CHEMBL1413 CHEMBL1413 1343970
#> 2 1 CHEMBL1413 CHEMBL1413 1343970
#> selectivity_comment site_id target_chembl_id variant_sequence
#> 1 NA NA CHEMBL2363058 NA
#> 2 NA NA CHEMBL2366381 NA
#>
#> $page_meta
#> $page_meta$limit
#> [1] 20
#>
#> $page_meta$`next`
#> NULL
#>
#> $page_meta$offset
#> [1] 0
#>
#> $page_meta$previous
#> NULL
#>
#> $page_meta$total_count
#> [1] 2
The getChemblResources() function returns a list of possible
resources that can be queried:
getChemblResources()
#> [1] "activity" "assay"
#> [3] "atc_class" "binding_site"
#> [5] "biotherapeutic" "cell_line"
#> [7] "chembl_id_lookup" "compound_record"
#> [9] "compound_structural_alert" "document"
#> [11] "document_similarity" "document_term"
#> [13] "drug" "drug_indication"
#> [15] "drug_warning" "go_slim"
#> [17] "image" "mechanism"
#> [19] "metabolism" "molecule"
#> [21] "molecule_form" "organism"
#> [23] "protein_classification" "similarity"
#> [25] "source" "status"
#> [27] "substructure" "target"
#> [29] "target_component" "target_relation"
#> [31] "tissue" "xref_source"
The getChemblResourceFields(resource) function returns a list of possible
fields that can be queried for a given resource:
run_chembl_example(getChemblResourceFields("mechanism"))
#> [1] "action_type" "binding_site_comment"
#> [3] "direct_interaction" "disease_efficacy"
#> [5] "max_phase" "mec_id"
#> [7] "mechanism_comment" "mechanism_of_action"
#> [9] "mechanism_refs" "molecular_mechanism"
#> [11] "molecule_chembl_id" "parent_molecule_chembl_id"
#> [13] "record_id" "selectivity_comment"
#> [15] "site_id" "target_chembl_id"
#> [17] "variant_sequence"
The getChemblFilterTypes() function returns a list of possible filter types.
getChemblFilterTypes()
#> [1] "exact" "iexact" "contains" "icontains" "startswith"
#> [6] "istartswith" "endswith" "iendswith" "regex" "iregex"
#> [11] "gt" "gte" "lt" "lte" "range"
#> [16] "in" "isnull" "search" "only"
sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.5 LTS
#>
#> Matrix products: default
#> BLAS: /home/biocbuild/bbs-3.24-bioc/R/lib/libRblas.so
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0 LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_GB LC_COLLATE=C
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: America/New_York
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] data.table_1.18.6.1 AnnotationGx_1.0.0 BiocStyle_2.42.0
#>
#> loaded via a namespace (and not attached):
#> [1] bit_4.6.0 jsonlite_2.0.0 crayon_1.5.3
#> [4] dplyr_1.2.1 compiler_4.6.1 BiocManager_1.30.27
#> [7] filelock_1.0.3 tidyselect_1.2.1 blob_1.3.0
#> [10] parallel_4.6.1 jquerylib_0.1.4 yaml_2.3.12
#> [13] fastmap_1.2.0 R6_2.6.1 generics_0.1.4
#> [16] curl_8.2.0 httr2_1.3.0 knitr_1.52
#> [19] backports_1.5.1 checkmate_2.3.4 tibble_3.3.1
#> [22] bookdown_0.48 DBI_1.3.0 bslib_0.12.0
#> [25] pillar_1.11.1 rlang_1.3.0 cachem_1.1.0
#> [28] xfun_0.62 sass_0.5.0 bit64_4.8.6
#> [31] otel_0.3.0 RSQLite_3.53.3 memoise_2.0.1
#> [34] cli_3.6.6 withr_3.0.3 magrittr_2.0.5
#> [37] digest_0.6.39 dbplyr_2.6.0 lifecycle_1.0.5
#> [40] BiocFileCache_3.4.0 vctrs_0.7.3 evaluate_1.0.5
#> [43] glue_1.8.1 purrr_1.2.2 rmarkdown_2.32
#> [46] tools_4.6.1 pkgconfig_2.0.3 htmltools_0.5.9