Mercurial > repos > prog > lcmsmatching
comparison MsBioDb.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 | |
| children | fb9c0409d85c |
comparison
equal
deleted
inserted
replaced
| 1:253d531a0193 | 2:20d69a062da3 |
|---|---|
| 1 if ( ! exists('MsBioDb')) { # Do not load again if already loaded | |
| 2 | |
| 3 library(methods) | |
| 4 source('MsDb.R') | |
| 5 source(file.path('BiodbObject.R'), chdir = TRUE) | |
| 6 source(file.path('BiodbFactory.R'), chdir = TRUE) | |
| 7 | |
| 8 ##################### | |
| 9 # CLASS DECLARATION # | |
| 10 ##################### | |
| 11 | |
| 12 MsBioDb <- setRefClass("MsBioDb", contains = "MsDb", fields = list(.massdb = "ANY")) | |
| 13 | |
| 14 ############### | |
| 15 # CONSTRUCTOR # | |
| 16 ############### | |
| 17 | |
| 18 MsBioDb$methods( initialize = function(massdb = NULL, ...) { | |
| 19 | |
| 20 # Check bio database | |
| 21 ! is.null(massdb) || stop("You must set a bio database.") | |
| 22 inherits(massdb, "MassdbConn") || stop("The bio database must inherit from MassdbConn class.") | |
| 23 .massdb <<- massdb | |
| 24 | |
| 25 callSuper(...) | |
| 26 }) | |
| 27 | |
| 28 #################### | |
| 29 # HANDLE COMPOUNDS # | |
| 30 #################### | |
| 31 | |
| 32 MsBioDb$methods( handleCompounds = function() { | |
| 33 return(.self$.massdb$handlesEntryType(BIODB.COMPOUND)) | |
| 34 }) | |
| 35 | |
| 36 #################### | |
| 37 # GET MOLECULE IDS # | |
| 38 #################### | |
| 39 | |
| 40 MsBioDb$methods( getMoleculeIds = function(max.results = NA_integer_) { | |
| 41 return(.self$.massdb$getEntryIds(type = BIODB.COMPOUND, max.results = max.results)) | |
| 42 }) | |
| 43 | |
| 44 #################### | |
| 45 # GET NB MOLECULES # | |
| 46 #################### | |
| 47 | |
| 48 MsBioDb$methods( getNbMolecules = function() { | |
| 49 return(.self$.massdb$getNbEntries(type = BIODB.COMPOUND)) | |
| 50 }) | |
| 51 | |
| 52 ################# | |
| 53 # GET MZ VALUES # | |
| 54 ################# | |
| 55 | |
| 56 MsBioDb$methods( getMzValues = function(mode = NULL, max.results = NA_integer_) { | |
| 57 return(.self$.massdb$getMzValues(mode = mode, max.results = max.results)) | |
| 58 }) | |
| 59 | |
| 60 ##################### | |
| 61 # GET MOLECULE NAME # | |
| 62 ##################### | |
| 63 | |
| 64 MsBioDb$methods( getMoleculeName = function(molid) { | |
| 65 return(.self$.massdb$getMoleculeName(molid)) | |
| 66 }) | |
| 67 | |
| 68 ############################### | |
| 69 # GET CHROMATOGRAPHIC COLUMNS # | |
| 70 ############################### | |
| 71 | |
| 72 MsBioDb$methods( getChromCol = function(molid = NULL) { | |
| 73 return(.self$.massdb$getChromCol(molid)) | |
| 74 }) | |
| 75 | |
| 76 ################ | |
| 77 # FIND BY NAME # | |
| 78 ################ | |
| 79 | |
| 80 MsBioDb$methods( findByName = function(name) { | |
| 81 return(.self$.massdb$findCompoundByName(name)) | |
| 82 }) | |
| 83 | |
| 84 ####################### | |
| 85 # GET RETENTION TIMES # | |
| 86 ####################### | |
| 87 | |
| 88 MsBioDb$methods( getRetentionTimes = function(molid, col = NA_character_) { | |
| 89 return(.self$.massdb$getRetentionTimes(molid, chrom.cols = col)) | |
| 90 }) | |
| 91 | |
| 92 ################ | |
| 93 # GET NB PEAKS # | |
| 94 ################ | |
| 95 | |
| 96 MsBioDb$methods( getNbPeaks = function(molid = NA_integer_, mode = NA_character_) { | |
| 97 return(.self$.massdb$getNbPeaks(compound.ids = molid, mode = mode)) | |
| 98 }) | |
| 99 | |
| 100 } |
