Mercurial > repos > prog > lcmsmatching
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:253d531a0193 | 2:20d69a062da3 |
---|---|
1 if ( ! exists('BiodbConn')) { | 1 ##################### |
2 # CLASS DECLARATION # | |
3 ##################### | |
2 | 4 |
3 source('biodb-common.R') | 5 BiodbConn <- methods::setRefClass("BiodbConn", contains = "BiodbObject", fields = list( .debug = "logical" )) |
4 | 6 |
5 ##################### | 7 ############### |
6 # CLASS DECLARATION # | 8 # CONSTRUCTOR # |
7 ##################### | 9 ############### |
8 | |
9 BiodbConn <- setRefClass("BiodbConn", fields = list( .debug = "logical" )) | |
10 | 10 |
11 ############### | 11 BiodbConn$methods( initialize = function(debug = FALSE, ...) { |
12 # CONSTRUCTOR # | 12 .debug <<- debug |
13 ############### | 13 }) |
14 | 14 |
15 BiodbConn$methods( initialize = function(debug = FALSE, ...) { | 15 ####################### |
16 .debug <<- debug | 16 # PRINT DEBUG MESSAGE # |
17 }) | 17 ####################### |
18 | 18 |
19 ####################### | 19 BiodbConn$methods( .print.debug.msg = function(msg) { |
20 # PRINT DEBUG MESSAGE # | 20 if (.self$.debug) |
21 ####################### | 21 .print.msg(msg = msg, class = class(.self)) |
22 }) | |
22 | 23 |
23 BiodbConn$methods( .print.debug.msg = function(msg) { | 24 ########################## |
24 if (.self$.debug) | 25 # GET ENTRY CONTENT TYPE # |
25 .print.msg(msg = msg, class = class(.self)) | 26 ########################## |
26 }) | |
27 | 27 |
28 ###################### | 28 BiodbConn$methods( getEntryContentType = function() { |
29 # HANDLES ENTRY TYPE # | 29 .self$.abstract.method() |
30 ###################### | 30 }) |
31 | 31 |
32 BiodbConn$methods( handlesEntryType = function(type) { | 32 ############# |
33 return( ! is.null(.self$getEntryContentType(type))) | 33 # GET ENTRY # |
34 }) | 34 ############# |
35 | 35 |
36 ########################## | 36 BiodbConn$methods( getEntry = function(id, drop = TRUE) { |
37 # GET ENTRY CONTENT TYPE # | 37 content <- .self$getEntryContent(id) |
38 ########################## | 38 return(.self$createEntry(content, drop = drop)) |
39 }) | |
39 | 40 |
40 BiodbConn$methods( getEntryContentType = function(type) { | 41 ##################### |
41 stop("Method getEntryContentType() is not implemented in concrete class.") | 42 # GET ENTRY CONTENT # |
42 }) | 43 ##################### |
43 | 44 |
44 ############# | 45 # Download entry content from the public database. |
45 # GET ENTRY # | 46 # type The entry type. |
46 ############# | 47 # id The ID of the entry to get. |
48 # RETURN An entry content downloaded from database. | |
49 BiodbConn$methods( getEntryContent = function(id) { | |
50 .self$.abstract.method() | |
51 }) | |
47 | 52 |
48 BiodbConn$methods( getEntry = function(type, id, drop = TRUE) { | 53 ############################# |
49 content <- .self$getEntryContent(type, id) | 54 # CREATE ENTRY FROM CONTENT # |
50 return(.self$createEntry(type, content, drop = drop)) | 55 ############################# |
51 }) | |
52 | 56 |
53 ##################### | 57 # Creates a Compound instance from file content. |
54 # GET ENTRY CONTENT # | 58 # content A file content, downloaded from the public database. |
55 ##################### | 59 # RETURN A compound instance. |
56 | 60 BiodbConn$methods( createEntry = function(content, drop = TRUE) { |
57 # Download entry content from the public database. | 61 .self$.abstract.method() |
58 # type The entry type. | 62 }) |
59 # id The ID of the entry to get. | |
60 # RETURN An entry content downloaded from database. | |
61 BiodbConn$methods( getEntryContent = function(type, id) { | |
62 stop("Method getCompound() is not implemented in concrete class.") | |
63 }) | |
64 | |
65 ############################# | |
66 # CREATE ENTRY FROM CONTENT # | |
67 ############################# | |
68 | |
69 # Creates a Compound instance from file content. | |
70 # content A file content, downloaded from the public database. | |
71 # RETURN A compound instance. | |
72 BiodbConn$methods( createEntry = function(type, content, drop = TRUE) { | |
73 stop("Method createEntry() is not implemented in concrete class.") | |
74 }) | |
75 | 63 |
76 ################# | 64 ################# |
77 # GET ENTRY IDS # | 65 # GET ENTRY IDS # |
78 ################# | 66 ################# |
79 | |
80 # Get a list of IDs of all entries contained in this database. | |
81 BiodbConn$methods( getEntryIds = function(type) { | |
82 stop("Method getEntryIds() is not implemented in concrete class.") | |
83 }) | |
84 | 67 |
85 ################## | 68 # Get a list of IDs of all entries contained in this database. |
86 # GET NB ENTRIES # | 69 BiodbConn$methods( getEntryIds = function(max.results = NA_integer_) { |
87 ################## | 70 .self$.abstract.method() |
88 | 71 }) |
89 # Get the number of entries contained in this database. | 72 |
90 BiodbConn$methods( getNbEntries = function(type) { | 73 ################## |
91 stop("Method getNbEntries() is not implemented in concrete class.") | 74 # GET NB ENTRIES # |
92 }) | 75 ################## |
93 } | 76 |
77 # Get the number of entries contained in this database. | |
78 BiodbConn$methods( getNbEntries = function() { | |
79 .self$.abstract.method() | |
80 }) |