Authors: Johannes Rainer [cre] (https://orcid.org/0000-0002-6977-7147)
Compiled: Wed Dec 13 15:58:23 2023

1 Introduction

MassBank is an open access, community maintained annotation database for small compounds. Annotations provided by this database comprise names, chemical formulas, exact masses and other chemical properties for small compounds (including metabolites, medical treatment agents and others). In addition, fragment spectra are available which are crucial for the annotation of untargeted mass spectrometry data. The CompoundDb Bioconductor package supports conversion of MassBank data into the CompDb (SQLite) format which enables a simplified distribution of the resource and easy integration into Bioconductor-based annotation workflows.

2 Fetch MassBank CompDb Databases from AnnotationHub

The AHMassBank package provides the metadata for all CompDb SQLite databases with MassBank annotations in r Biocpkg("AnnotationHub"). To get and use MassBank annotations we first we load/update the AnnotationHub resource.

library(AnnotationHub)
ah <- AnnotationHub()

Next we list all MassBank entries from AnnotationHub.

query(ah, "MassBank")
## AnnotationHub with 3 records
## # snapshotDate(): 2023-11-08
## # $dataprovider: MassBank
## # $species: NA
## # $rdataclass: CompDb
## # additional mcols(): taxonomyid, genome, description,
## #   coordinate_1_based, maintainer, rdatadateadded, preparerclass, tags,
## #   rdatapath, sourceurl, sourcetype 
## # retrieve records with, e.g., 'object[["AH107048"]]' 
## 
##              title                                
##   AH107048 | MassBank CompDb for release 2021.03  
##   AH107049 | MassBank CompDb for release 2022.06  
##   AH111334 | MassBank CompDb for release 2022.12.1

We fetch the CompDb with MassBank annotations for release 2021.03.

qr <- query(ah, c("MassBank", "2021.03"))
cdb <- qr[[1]]
## loading from cache
## require("CompoundDb")

3 Creating CompDb Databases from MassBank

MassBank provides its annotation database as a MySQL dump. To simplify its usage (also for users not experienced with MySQL or with the specific MassBank database layout), MassBank annotations can also be converted into the (SQLite-based) CompDb format which can be easily used with the CompoundDb package. The steps to convert a MassBank MySQL database to a CompDb SQLite database are described below.

First the MySQL database dump needs to be downloaded from the MassBank github page. This database needs to be installed into a local MySQL/MariaDB database server (using mysql -h localhost -u <username> -p < MassBank.sql with <username> being the name of the user with write access to the database server).

To transfer the MassBank data into a CompDb database a helper function from the CompoundDb package can be used.

library(RMariaDB)
con <- dbConnect(MariaDB(), host = "localhost", user = <username>,
                 pass = <password>, dbname = "MassBank")
source(system.file("scripts", "massbank_to_compdb.R", package = "CompoundDb"))
massbank_to_compdb(con)

4 Session Information

sessionInfo()
## R Under development (unstable) (2023-11-11 r85510)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.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] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
## [1] CompoundDb_1.7.1        S4Vectors_0.41.2        AnnotationFilter_1.27.0
## [4] AnnotationHub_3.11.1    BiocFileCache_2.11.1    dbplyr_2.4.0           
## [7] BiocGenerics_0.49.1     BiocStyle_2.31.0       
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.2.0        dplyr_1.1.4             blob_1.2.4             
##  [4] filelock_1.0.3          Biostrings_2.71.1       bitops_1.0-7           
##  [7] fastmap_1.1.1           RCurl_1.98-1.13         lazyeval_0.2.2         
## [10] digest_0.6.33           mime_0.12               lifecycle_1.0.4        
## [13] cluster_2.1.6           ProtGenerics_1.35.0     rsvg_2.6.0             
## [16] KEGGREST_1.43.0         RSQLite_2.3.4           magrittr_2.0.3         
## [19] compiler_4.4.0          rlang_1.1.2             sass_0.4.8             
## [22] tools_4.4.0             utf8_1.2.4              yaml_2.3.8             
## [25] knitr_1.45              htmlwidgets_1.6.4       bit_4.0.5              
## [28] curl_5.2.0              xml2_1.3.6              BiocParallel_1.37.0    
## [31] withr_2.5.2             purrr_1.0.2             grid_4.4.0             
## [34] fansi_1.0.6             colorspace_2.1-0        ggplot2_3.4.4          
## [37] MASS_7.3-60.1           scales_1.3.0            cli_3.6.2              
## [40] rmarkdown_2.25          crayon_1.5.2            generics_0.1.3         
## [43] httr_1.4.7              rjson_0.2.21            DBI_1.1.3              
## [46] cachem_1.0.8            zlibbioc_1.49.0         parallel_4.4.0         
## [49] AnnotationDbi_1.65.2    BiocManager_1.30.22     XVector_0.43.0         
## [52] base64enc_0.1-3         vctrs_0.6.5             jsonlite_1.8.8         
## [55] bookdown_0.37           IRanges_2.37.0          bit64_4.0.5            
## [58] clue_0.3-65             jquerylib_0.1.4         glue_1.6.2             
## [61] codetools_0.2-19        DT_0.31                 Spectra_1.13.3         
## [64] gtable_0.3.4            BiocVersion_3.19.1      GenomeInfoDb_1.39.2    
## [67] GenomicRanges_1.55.1    munsell_0.5.0           tibble_3.2.1           
## [70] pillar_1.9.0            rappdirs_0.3.3          htmltools_0.5.7        
## [73] GenomeInfoDbData_1.2.11 R6_2.5.1                evaluate_0.23          
## [76] Biobase_2.63.0          png_0.1-8               memoise_2.0.1          
## [79] bslib_0.6.1             MetaboCoreUtils_1.11.0  Rcpp_1.0.11            
## [82] gridExtra_2.3           ChemmineR_3.55.1        xfun_0.41              
## [85] fs_1.6.3                MsCoreUtils_1.15.1      pkgconfig_2.0.3