R/zzz.R

###
### Load any db objects whenever the package is loaded.
###

.onLoad <- function(libname, pkgname)
{
  ns <- asNamespace(pkgname)
  path <- system.file("extdata", package = pkgname, lib.loc = libname)
  files <- dir(path)
  for(i in seq_len(length(files))){
      db <- CompoundDb(system.file("extdata", files[[i]], package = pkgname,
                                   lib.loc = libname))
      objname <- sub(".sqlite$","",files[[i]])
      assign(objname, db, envir = ns)
      namespaceExport(ns, objname)
  }
}
jotsetung/CompoundDb.Hsapiens.HMDB.4.0 documentation built on May 29, 2019, 1:08 a.m.