create custom 'System Biology' annotation package - class not found
0
0
Entering edit mode
@laure-cougnaud-5920
Last seen 7.2 years ago

I would like to create a custom 'System Biology' annotation package (pathway.db), so containing pathway annotation.

I use the same workflow as described in section 7: 'Setting up a package to expose a SQLite database object' in the vignette 'MakingNewAnnotationPackages.pdf' of AnnotationForge.

I created a sqlite database file in the 'inst/extdata' folder and the corresponding schemas in 'inst/DBschemas'.

I created a pathwayDb (pathway being the name of the pathway database) class inheriting from 'AnnotationDb', as:
pathwayDb <- setRefClass("pathwayDb",
        contains = "AnnotationDb",
        package = "AnnotationDbi")

The 'DB type' and 'Supporting package' classes have been updated in the metadata of the database:

  • 'Supporting package: 'pathway.db'
  • 'Db type': 'pathwayDb'

The 'zzz.R' file contains:

datacache <- new.env(hash = TRUE, parent = emptyenv())

pathway <- function() showQCData("pathway", datacache)
pathway_dbconn <- function() dbconn(datacache)
pathway_dbfile <- function() dbfile(datacache)
pathway_dbschema <- function(file = "", show.indices=FALSE)
    dbschema(datacache, file = file, show.indices = show.indices)
pathway_dbInfo <- function() dbInfo(datacache)

.onLoad <- function(libname, pkgname)
{
    ## Connect to the SQLite DB
    dbfile <- system.file("extdata", "pathway.sqlite",
        package = pkgname, lib.loc = libname)
    assign("dbfile", dbfile, envir = datacache)
    dbconn <- dbFileConnect(dbfile)
    assign("dbconn", dbconn, envir = datacache)

    ## Create the pathwayDb object
    sPkgname <- sub(".db$","",pkgname)
    txdb <- loadDb(
        system.file("extdata",
            paste(sPkgname, ".sqlite",sep = ""),
            package = pkgname, lib.loc = libname),
        packageName = pkgname)

    dbNewname <- AnnotationDbi:::dbObjectName(pkgname, "pathwayDb")
    ns <- asNamespace(pkgname)
    assign(dbNewname, txdb, envir = ns)
    namespaceExport(ns, dbNewname)   
}

.onUnload <- function(libpath){
    dbFileDisconnect(pathway_dbconn())
}

However, I have an error at package installation:
Error : .onLoad failed in loadNamespace() for 'pathway.db', details:
  call: getClass(Class, where = topenv(parent.frame()))
  error: “pathwayDb” is not a defined class

This class is defined within the package (in the script 'aaa-classes.R'), but this doesn't seem to be defined yet when the 'zzz.R' script is run at the package installation.

Would you have any advice how to solve this issue?

Thanks in advance,

Laure

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
 [3] LC_TIME=en_GB.UTF-8           LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_GB.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_GB.UTF-8          LC_NAME=en_GB.UTF-8          
 [9] LC_ADDRESS=en_GB.UTF-8        LC_TELEPHONE=en_GB.UTF-8     
[11] LC_MEASUREMENT=en_GB.UTF-8    LC_IDENTIFICATION=en_GB.UTF-8

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets
[8] methods   base     

other attached packages:
[1] pathway.db_0.0.1        AnnotationDbi_1.36.2 IRanges_2.8.1       
[4] S4Vectors_0.12.1     Biobase_2.34.0       BiocGenerics_0.20.0
[7] devtools_1.12.0      rj_2.1.0-11         

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9     xml2_1.1.1      magrittr_1.5    roxygen2_6.0.1
 [5] rj.gd_2.1.0-2   R6_2.2.0        stringr_1.1.0   tools_3.3.2    
 [9] DBI_0.5-1       withr_1.0.2     commonmark_1.1  digest_0.6.12  
[13] assertthat_0.1  rprojroot_1.2   crayon_1.3.2    memoise_1.0.0  
[17] RSQLite_1.1-2   stringi_1.1.2   backports_1.0.5 desc_1.1.0   

AnnotationDb annotationdbi AnnotationForge • 1.2k views
ADD COMMENT

Login before adding your answer.

Traffic: 640 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6