In version 0.9.2, I just modified the database argument in identify_metabolites() and identify_metabolite_alls functions. Now you can put the database in the work directory and then give the database name, and you can also directory provide the database (databaseClass) to it.

Load demo data

First we load the MS1 peak and database from metID package and then put them in a example folder.

##create a folder named as example
path <- file.path(".", "example")
dir.create(path = path, showWarnings = FALSE)

##get MS1 peak table from metID
ms1_peak <- system.file("ms1_peak", package = "metID")
file.copy(from = file.path(ms1_peak, "ms1.peak.table.csv"), 
          to = path, overwrite = TRUE, recursive = TRUE)
#> [1] TRUE

##get database from metID
database <- system.file("ms2_database", package = "metID")

file.copy(from = file.path(database, "msDatabase_rplc0.0.2"), 
          to = path, overwrite = TRUE, recursive = TRUE)
#> [1] TRUE

Now in your ./example, there are two files, namely ms1.peak.table.csv and msDatabase_rplc_0.0.2, respectively.

Use database name

annotate_result1 <- 
  identify_metabolites(ms1.data = "ms1.peak.table.csv", 
                       ms1.match.ppm = 15, 
                       rt.match.tol = 1000000, 
                       polarity = "positive", 
                       column = "rp", 
                       path = path, 
                       candidate.num = 3,
                       database = "msDatabase_rplc0.0.2", 
                       threads = 5)
#> You don't provide MS2 data, so only use mz and/or RT for matching.
#> You set rt.match.tol > 10,000, so RT will not be used for matching.
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |======================================================================| 100%
#> 
#> All done.

Use databaseClass object

load(file.path(path, "msDatabase_rplc0.0.2"))
msDatabase_rplc0.0.2
#> -----------Base information------------
#> Version: 0.0.2 
#> Source: MS 
#> Link: http://snyderlab.stanford.edu/ 
#> Creater: Xiaotao Shen ( shenxt1990@163.com )
#> With RT information
#> -----------Spectral information------------
#> There are 14 items of metabolites in database:
#> Lab.ID; Compound.name; mz; RT; CAS.ID; HMDB.ID; KEGG.ID; Formula; mz.pos; mz.neg; Submitter; Family; Sub.pathway; Note 
#> There are 833 metabolites in total
#> There are 356 metabolites in positive mode with MS2 spectra.
#> There are 534 metabolites in negative mode with MS2 spectra.
#> Collision energy in positive mode (number:):
#> Total number: 2 
#> NCE25; NCE50 
#> Collision energy in negative mode:
#> Total number: 2 
#> NCE25; NCE50

Then we can directory provide this database to identify_metabolites():

annotate_result2 <- 
  identify_metabolites(ms1.data = "ms1.peak.table.csv", 
                       ms1.match.ppm = 15, 
                       rt.match.tol = 1000000, 
                       polarity = "positive", 
                       column = "rp", 
                       path = path, 
                       candidate.num = 3,
                       database = msDatabase_rplc0.0.2, 
                       threads = 5)
#> You don't provide MS2 data, so only use mz and/or RT for matching.
#> You set rt.match.tol > 10,000, so RT will not be used for matching.
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |======================================================================| 100%
#> 
#> All done.

But what should be noticed is that it have different name for database in the final result:

annotate_result1@database
#> [1] "msDatabase_rplc0.0.2"
annotate_result2@database
#> [1] "MS_0.0.2"

It is because that if you give the databaseClass, so identify_metabolites can know the name of database, if just use the source and version as the name for database.

paste(msDatabase_rplc0.0.2@database.info$Source,
      msDatabase_rplc0.0.2@database.info$Version, 
      sep = "_")
#> [1] "MS_0.0.2"