Mercurial > repos > prog > lcmsmatching
diff BiodbConn.R @ 2:20d69a062da3 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
author | prog |
---|---|
date | Thu, 02 Mar 2017 08:55:00 -0500 |
parents | 253d531a0193 |
children |
line wrap: on
line diff
--- a/BiodbConn.R Sat Sep 03 17:02:01 2016 -0400 +++ b/BiodbConn.R Thu Mar 02 08:55:00 2017 -0500 @@ -1,93 +1,80 @@ -if ( ! exists('BiodbConn')) { - - source('biodb-common.R') +##################### +# CLASS DECLARATION # +##################### - ##################### - # CLASS DECLARATION # - ##################### - - BiodbConn <- setRefClass("BiodbConn", fields = list( .debug = "logical" )) +BiodbConn <- methods::setRefClass("BiodbConn", contains = "BiodbObject", fields = list( .debug = "logical" )) - ############### - # CONSTRUCTOR # - ############### +############### +# CONSTRUCTOR # +############### - BiodbConn$methods( initialize = function(debug = FALSE, ...) { - .debug <<- debug - }) +BiodbConn$methods( initialize = function(debug = FALSE, ...) { + .debug <<- debug +}) - ####################### - # PRINT DEBUG MESSAGE # - ####################### +####################### +# PRINT DEBUG MESSAGE # +####################### - BiodbConn$methods( .print.debug.msg = function(msg) { - if (.self$.debug) - .print.msg(msg = msg, class = class(.self)) - }) +BiodbConn$methods( .print.debug.msg = function(msg) { + if (.self$.debug) + .print.msg(msg = msg, class = class(.self)) +}) - ###################### - # HANDLES ENTRY TYPE # - ###################### +########################## +# GET ENTRY CONTENT TYPE # +########################## - BiodbConn$methods( handlesEntryType = function(type) { - return( ! is.null(.self$getEntryContentType(type))) - }) - - ########################## - # GET ENTRY CONTENT TYPE # - ########################## +BiodbConn$methods( getEntryContentType = function() { + .self$.abstract.method() +}) - BiodbConn$methods( getEntryContentType = function(type) { - stop("Method getEntryContentType() is not implemented in concrete class.") - }) +############# +# GET ENTRY # +############# - ############# - # GET ENTRY # - ############# +BiodbConn$methods( getEntry = function(id, drop = TRUE) { + content <- .self$getEntryContent(id) + return(.self$createEntry(content, drop = drop)) +}) - BiodbConn$methods( getEntry = function(type, id, drop = TRUE) { - content <- .self$getEntryContent(type, id) - return(.self$createEntry(type, content, drop = drop)) - }) +##################### +# GET ENTRY CONTENT # +##################### + +# Download entry content from the public database. +# type The entry type. +# id The ID of the entry to get. +# RETURN An entry content downloaded from database. +BiodbConn$methods( getEntryContent = function(id) { + .self$.abstract.method() +}) + +############################# +# CREATE ENTRY FROM CONTENT # +############################# - ##################### - # GET ENTRY CONTENT # - ##################### - - # Download entry content from the public database. - # type The entry type. - # id The ID of the entry to get. - # RETURN An entry content downloaded from database. - BiodbConn$methods( getEntryContent = function(type, id) { - stop("Method getCompound() is not implemented in concrete class.") - }) - - ############################# - # CREATE ENTRY FROM CONTENT # - ############################# - - # Creates a Compound instance from file content. - # content A file content, downloaded from the public database. - # RETURN A compound instance. - BiodbConn$methods( createEntry = function(type, content, drop = TRUE) { - stop("Method createEntry() is not implemented in concrete class.") - }) +# Creates a Compound instance from file content. +# content A file content, downloaded from the public database. +# RETURN A compound instance. +BiodbConn$methods( createEntry = function(content, drop = TRUE) { + .self$.abstract.method() +}) + +################# +# GET ENTRY IDS # +################# - ################# - # GET ENTRY IDS # - ################# - - # Get a list of IDs of all entries contained in this database. - BiodbConn$methods( getEntryIds = function(type) { - stop("Method getEntryIds() is not implemented in concrete class.") - }) +# Get a list of IDs of all entries contained in this database. +BiodbConn$methods( getEntryIds = function(max.results = NA_integer_) { + .self$.abstract.method() +}) - ################## - # GET NB ENTRIES # - ################## - - # Get the number of entries contained in this database. - BiodbConn$methods( getNbEntries = function(type) { - stop("Method getNbEntries() is not implemented in concrete class.") - }) -} +################## +# GET NB ENTRIES # +################## + +# Get the number of entries contained in this database. +BiodbConn$methods( getNbEntries = function() { + .self$.abstract.method() +})