Authors: Johannes Rainer [cre] (https://orcid.org/0000-0002-6977-7147)
Compiled: Wed Dec 13 15:58:24 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-10-20
## # $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 version 4.3.2 Patched (2023-11-13 r85521)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.18-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.6.0        S4Vectors_0.40.2        AnnotationFilter_1.26.0
## [4] AnnotationHub_3.10.0    BiocFileCache_2.10.1    dbplyr_2.4.0           
## [7] BiocGenerics_0.48.1     BiocStyle_2.30.0       
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.2.0              dplyr_1.1.4                  
##  [3] blob_1.2.4                    filelock_1.0.3               
##  [5] Biostrings_2.70.1             bitops_1.0-7                 
##  [7] fastmap_1.1.1                 RCurl_1.98-1.13              
##  [9] lazyeval_0.2.2                promises_1.2.1               
## [11] digest_0.6.33                 mime_0.12                    
## [13] lifecycle_1.0.4               cluster_2.1.6                
## [15] ProtGenerics_1.34.0           rsvg_2.6.0                   
## [17] ellipsis_0.3.2                KEGGREST_1.42.0              
## [19] interactiveDisplayBase_1.40.0 RSQLite_2.3.4                
## [21] magrittr_2.0.3                compiler_4.3.2               
## [23] rlang_1.1.2                   sass_0.4.8                   
## [25] tools_4.3.2                   utf8_1.2.4                   
## [27] yaml_2.3.8                    knitr_1.45                   
## [29] htmlwidgets_1.6.4             bit_4.0.5                    
## [31] curl_5.2.0                    xml2_1.3.6                   
## [33] BiocParallel_1.36.0           withr_2.5.2                  
## [35] purrr_1.0.2                   grid_4.3.2                   
## [37] fansi_1.0.6                   colorspace_2.1-0             
## [39] xtable_1.8-4                  ggplot2_3.4.4                
## [41] MASS_7.3-60                   scales_1.3.0                 
## [43] cli_3.6.2                     rmarkdown_2.25               
## [45] crayon_1.5.2                  generics_0.1.3               
## [47] httr_1.4.7                    rjson_0.2.21                 
## [49] DBI_1.1.3                     cachem_1.0.8                 
## [51] zlibbioc_1.48.0               parallel_4.3.2               
## [53] AnnotationDbi_1.64.1          BiocManager_1.30.22          
## [55] XVector_0.42.0                base64enc_0.1-3              
## [57] vctrs_0.6.5                   jsonlite_1.8.8               
## [59] bookdown_0.37                 IRanges_2.36.0               
## [61] bit64_4.0.5                   clue_0.3-65                  
## [63] jquerylib_0.1.4               glue_1.6.2                   
## [65] codetools_0.2-19              DT_0.31                      
## [67] Spectra_1.12.0                gtable_0.3.4                 
## [69] BiocVersion_3.18.1            later_1.3.2                  
## [71] GenomeInfoDb_1.38.2           GenomicRanges_1.54.1         
## [73] munsell_0.5.0                 tibble_3.2.1                 
## [75] pillar_1.9.0                  rappdirs_0.3.3               
## [77] htmltools_0.5.7               GenomeInfoDbData_1.2.11      
## [79] R6_2.5.1                      evaluate_0.23                
## [81] shiny_1.8.0                   Biobase_2.62.0               
## [83] png_0.1-8                     memoise_2.0.1                
## [85] httpuv_1.6.13                 bslib_0.6.1                  
## [87] MetaboCoreUtils_1.10.0        Rcpp_1.0.11                  
## [89] gridExtra_2.3                 ChemmineR_3.54.0             
## [91] xfun_0.41                     fs_1.6.3                     
## [93] MsCoreUtils_1.14.1            pkgconfig_2.0.3