1 Purpose

biodbNci is a biodb extension package that implements a connector to biodbNci, a library for connecting to the National Cancer Institute (USA) CACTUS API (Institute 2022).

2 Installation

Install using Bioconductor:

if (!requireNamespace("BiocManager", quietly=TRUE))
    install.packages("BiocManager")
BiocManager::install('biodbNci')

3 Initialization

The first step in using biodbNci, is to create an instance of the biodb class Biodb from the main biodb package. This is done by calling the constructor of the class:

mybiodb <- biodb::newInst()

During this step the configuration is set up, the cache system is initialized and extension packages are loaded.

We will see at the end of this vignette that the biodb instance needs to be terminated with a call to the terminate() method.

4 Creating a connector to CACTUS

In biodb the connection to a database is handled by a connector instance that you can get from the factory. biodbNci implements a connector to a remote database. Here is the code to instantiate a connector:

conn <- mybiodb$getFactory()$createConn('nci.cactus')
## Loading required package: biodbNci

For this vignette, we will avoid the downloading of the full NCI CACTUS database, and use instead an extract containing a few entries:

dbExtract <- system.file("extdata", 'generated', "cactus_extract.txt.gz",
    package="biodbNci")
conn$setPropValSlot('urls', 'db.gz.url', dbExtract)

5 Accessing entries

To get some of the first entry IDs (accession numbers) from the database, run:

ids <- conn$getEntryIds(2)
## INFO  [16:06:41.341] Create cache folder "/home/biocbuild/.cache/R/biodb/nci.cactus-8efc65070d01b214e760b1d4932ee427" for "nci.cactus-8efc65070d01b214e760b1d4932ee427". 
## INFO  [16:06:41.343] Downloading whole database of nci.cactus. 
## INFO  [16:06:41.344] Downloading NCI CACTUS database at "/tmp/RtmpmqTcnp/Rinst130cc66726daae/biodbNci/extdata/generated/cactus_extract.txt.gz" ... 
## INFO  [16:06:41.350] Extract whole database of nci.cactus. 
## INFO  [16:06:41.351] Extracting content of downloaded biodbNci, a library for connecting to the National Cancer Institute (USA) CACTUS Database....
ids
## [1] "749674" "750690"

To retrieve entries, use:

entries <- conn$getEntry(ids)
entries
## [[1]]
## Biodb NCI CACTUS entry instance 749674.
## 
## [[2]]
## Biodb NCI CACTUS entry instance 750690.

To convert a list of entries into a dataframe, run:

x <- mybiodb$entriesToDataframe(entries)
x
##   accession     formula molecular.mass
## 1    749674   C16H14N4O       278.3128
## 2    750690 C22H27FN4O2       398.4793
##                                                                                                                                                                     inchi
## 1                                                           InChI=1S/C16H14N4O/c1-11-15(20-19-12-7-3-2-4-8-12)16(21)18-14-10-6-5-9-13(14)17-11/h2-10,19H,1H3,(H,18,20,21)
## 2 InChI=1S/C22H27FN4O2/c1-5-27(6-2)10-9-24-22(29)20-13(3)19(25-14(20)4)12-17-16-11-15(23)7-8-18(16)26-21(17)28/h7-8,11-12,25H,5-6,9-10H2,1-4H3,(H,24,29)(H,26,28)/b17-12-
##                      inchikey nci.cactus.id      cas.id
## 1 RWIQZKLIGWLCEK-UHFFFAOYSA-N        749674        <NA>
## 2 WINHZLLDWRZWRT-ATVHPVEESA-N        750690 557795-19-4
##                                                                                                                                                    name
## 1                                                                                                                                                  <NA>
## 2 Sunitinib (free base);1H-Pyrrole-3-carboxamide, N-[2-(diethylamino)ethyl]-5-[(Z)-(5-fluoro-1,2-dihydro-2-oxo-3H-indol-3-ylidene)methyl]-2,4-dimethyl-

6 Chemical Identifier Resolver web service

Here is an example of calling the Chemical Identifier Resolver for converting a SMILES into an InChI:

conn$wsChemicalIdentifierResolver(structid='C=O', repr='InChI')
## [1] "InChI=1/CH2O/c1-2/h1H2"

7 Convert CAS IDs

There are currently two methods in NCI CACTUS for converting from CAS IDs to InChI or InChI keys:

conn$convCasToInchi('87605-72-9')
## [1] "InChI=1/C25H30O5/c1-15(2)6-5-7-16(3)8-9-30-19-11-17-10-18-13-25(4,29)14-21(27)23(18)24(28)22(17)20(26)12-19/h6,8,10-12,26,28-29H,5,7,9,13-14H2,1-4H3/b16-8+"
conn$convCasToInchikey('87605-72-9')
## [1] "KZPCPZBBGCTGCN-LZYBPNLTNA-N"

The conversion is made thanks to the Chemical Identifier Resolver web service.

8 Closing biodb instance

When done with your biodb instance you have to terminate it, in order to ensure release of resources (file handles, database connection, etc):

mybiodb$terminate()
## INFO  [16:06:45.011] Closing BiodbMain instance... 
## INFO  [16:06:45.019] Connector "nci.cactus" deleted.

9 Session information

sessionInfo()
## R version 4.2.0 RC (2022-04-19 r82224)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-bioc/R/lib/libRlapack.so
## 
## 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       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] biodbNci_1.0.0   BiocStyle_2.24.0
## 
## loaded via a namespace (and not attached):
##  [1] progress_1.2.2      tidyselect_1.1.2    xfun_0.30          
##  [4] bslib_0.3.1         purrr_0.3.4         vctrs_0.4.1        
##  [7] generics_0.1.2      htmltools_0.5.2     BiocFileCache_2.4.0
## [10] yaml_2.3.5          utf8_1.2.2          blob_1.2.3         
## [13] XML_3.99-0.9        rlang_1.0.2         jquerylib_0.1.4    
## [16] pillar_1.7.0        withr_2.5.0         glue_1.6.2         
## [19] DBI_1.1.2           rappdirs_0.3.3      bit64_4.0.5        
## [22] dbplyr_2.1.1        lifecycle_1.0.1     plyr_1.8.7         
## [25] stringr_1.4.0       memoise_2.0.1       evaluate_0.15      
## [28] knitr_1.38          fastmap_1.1.0       curl_4.3.2         
## [31] fansi_1.0.3         biodb_1.4.0         Rcpp_1.0.8.3       
## [34] openssl_2.0.0       filelock_1.0.2      BiocManager_1.30.17
## [37] cachem_1.0.6        jsonlite_1.8.0      bit_4.0.4          
## [40] hms_1.1.1           chk_0.8.0           askpass_1.1        
## [43] digest_0.6.29       stringi_1.7.6       bookdown_0.26      
## [46] dplyr_1.0.8         bitops_1.0-7        cli_3.3.0          
## [49] tools_4.2.0         magrittr_2.0.3      sass_0.4.1         
## [52] RCurl_1.98-1.6      RSQLite_2.2.12      tibble_3.1.6       
## [55] crayon_1.5.1        pkgconfig_2.0.3     ellipsis_0.3.2     
## [58] prettyunits_1.1.1   assertthat_0.2.1    rmarkdown_2.14     
## [61] httr_1.4.2          lgr_0.4.3           R6_2.5.1           
## [64] compiler_4.2.0

References

Institute, National Cancer. 2022. “CADD Group Chemoinformatics Tools and User Services (Cactus).” https://cactus.nci.nih.gov/.