annotate MassFiledbConn.R @ 1:253d531a0193 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
author prog
date Sat, 03 Sep 2016 17:02:01 -0400
parents
children 20d69a062da3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
1 if ( ! exists('MassFiledbConn')) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
2
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
3 source('MassdbConn.R')
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
4
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
5 # LCMS File db.
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
6 # In this type of database, a single file is provided in CSV format. Default separator is tabulation.
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
7 # Each line is a MS peak measure, .
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
8 # The file contains molecule and spectrum information. Each spectrum has an accession id.
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
9
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
10 # TODO Rename setField into setFieldName + addNewField, and setMsMode into setMsModeValue
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
11
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
12 #############
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
13 # CONSTANTS #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
14 #############
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
15
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
16 # Default database fields
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
17 .BIODB.DFT.DB.FIELDS <- list()
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
18 for (f in c(BIODB.ACCESSION, BIODB.NAME, BIODB.FULLNAMES, BIODB.COMPOUND.ID, BIODB.MSMODE, BIODB.PEAK.MZ, BIODB.PEAK.COMP, BIODB.PEAK.ATTR, BIODB.CHROM.COL, BIODB.CHROM.COL.RT, BIODB.FORMULA, BIODB.MASS))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
19 .BIODB.DFT.DB.FIELDS[[f]] <- f
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
20
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
21 #####################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
22 # CLASS DECLARATION #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
23 #####################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
24
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
25 MassFiledbConn <- setRefClass("MassFiledbConn", contains = "MassdbConn", fields = list(.file = "character", .file.sep = "character", .file.quote = "character", .field.multval.sep = 'character', .db = "ANY", .fields = "list", .ms.modes = "character"))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
26
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
27 ###############
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
28 # CONSTRUCTOR #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
29 ###############
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
30
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
31 MassFiledbConn$methods( initialize = function(file = NA_character_, file.sep = "\t", file.quote = "\"", ...) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
32
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
33 # Check file
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
34 (! is.null(file) && ! is.na(file)) || stop("You must specify a file database to load.")
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
35 file.exists(file) || stop(paste0("Cannot locate the file database \"", file ,"\"."))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
36
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
37 # Set fields
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
38 .db <<- NULL
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
39 .file <<- file
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
40 .file.sep <<- file.sep
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
41 .file.quote <<- file.quote
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
42 .fields <<- .BIODB.DFT.DB.FIELDS
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
43 .field.multval.sep <<- ';'
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
44 .ms.modes <<- c(BIODB.MSMODE.NEG, BIODB.MSMODE.POS)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
45 names(.self$.ms.modes) <- .self$.ms.modes
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
46
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
47 callSuper(...)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
48 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
49
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
50 ######################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
51 # Is valid field tag #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
52 ######################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
53
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
54 MassFiledbConn$methods( isValidFieldTag = function(tag) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
55 return (tag %in% names(.self$.fields))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
56 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
57
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
58 #############
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
59 # Set field #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
60 #############
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
61
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
62 MassFiledbConn$methods( setField = function(tag, colname) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
63
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
64 ( ! is.null(tag) && ! is.na(tag)) || stop("No tag specified.")
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
65 ( ! is.null(colname) && ! is.na(colname)) || stop("No column name specified.")
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
66
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
67 # Load database file
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
68 .self$.init.db()
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
69
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
70 # Check that this field tag is defined in the fields list
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
71 .self$isValidFieldTag(tag) || stop(paste0("Database field tag \"", tag, "\" is not valid."))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
72
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
73 # Check that columns are defined in database file
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
74 all(colname %in% names(.self$.db)) || stop(paste0("One or more columns among ", paste(colname, collapse = ", "), " are not defined in database file."))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
75
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
76 # Set new definition
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
77 if (length(colname) == 1)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
78 .fields[[tag]] <<- colname
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
79 else {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
80 new.col <- paste(colname, collapse = ".")
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
81 .self$.db[[new.col]] <- vapply(seq(nrow(.self$.db)), function(i) { paste(.self$.db[i, colname], collapse = '.') }, FUN.VALUE = '')
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
82 .fields[[tag]] <<- new.col
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
83 }
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
84 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
85
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
86 ######################################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
87 # SET FIELD MULTIPLE VALUE SEPARATOR #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
88 ######################################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
89
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
90 MassFiledbConn$methods( setFieldMultValSep = function(sep) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
91 .field.multval.sep <<- sep
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
92 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
93
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
94 ################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
95 # SET MS MODES #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
96 ################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
97
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
98 MassFiledbConn$methods( setMsMode = function(mode, value) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
99 .self$.ms.modes[[mode]] <- value
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
100 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
101
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
102 ##########################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
103 # GET ENTRY CONTENT TYPE #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
104 ##########################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
105
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
106 MassFiledbConn$methods( getEntryContentType = function(type) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
107 return(BIODB.DATAFRAME)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
108 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
109
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
110 ###########
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
111 # INIT DB #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
112 ###########
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
113
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
114 MassFiledbConn$methods( .init.db = function() {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
115
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
116 if (is.null(.self$.db)) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
117
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
118 # Load database
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
119 .db <<- read.table(.self$.file, sep = .self$.file.sep, .self$.file.quote, header = TRUE, stringsAsFactors = FALSE, row.names = NULL)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
120
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
121 # Rename columns
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
122 colnames(.self$.db) <- vapply(colnames(.self$.db), function(c) if (c %in% .self$.fields) names(.self$.fields)[.self$.fields %in% c] else c, FUN.VALUE = '')
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
123 }
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
124 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
125
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
126 ################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
127 # CHECK FIELDS #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
128 ################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
129
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
130 MassFiledbConn$methods( .check.fields = function(fields) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
131
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
132 # Check if fields are known
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
133 unknown.fields <- names(.self$.fields)[ ! fields %in% names(.self$.fields)]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
134 if (length(unknown.fields) > 0)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
135 stop(paste0("Field(s) ", paste(fields, collapse = ", "), " is/are unknown."))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
136
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
137 # Init db
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
138 .self$.init.db()
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
139
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
140 # Check if fields are defined in file database
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
141 undefined.fields <- colnames(.self$.init.db)[ ! unlist(.self$.fields[fields]) %in% colnames(.self$.init.db)]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
142 if (length(undefined.fields) > 0)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
143 stop(paste0("Column(s) ", paste(unlist(.self$.fields[fields]), collapse = ", "), " is/are undefined in file database."))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
144 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
145
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
146 ################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
147 # EXTRACT COLS #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
148 ################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
149
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
150 MassFiledbConn$methods( .extract.cols = function(cols, mode = NULL, drop = FALSE, uniq = FALSE, sort = FALSE, max.rows = NA_integer_) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
151
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
152 x <- NULL
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
153
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
154 if ( ! is.null(cols) && ! is.na(cols)) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
155
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
156 # Init db
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
157 .self$.init.db()
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
158
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
159 # TODO check existence of cols/fields
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
160
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
161 # Get db, eventually filtering it.
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
162 if (is.null(mode))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
163 db <- .self$.db
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
164 else {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
165 # Check mode value
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
166 mode %in% names(.self$.ms.modes) || stop(paste0("Unknown mode value '", mode, "'."))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
167 .self$.check.fields(BIODB.MSMODE)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
168
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
169 # Filter on mode
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
170 db <- .self$.db[.self$.db[[unlist(.self$.fields[BIODB.MSMODE])]] %in% .self$.ms.modes[[mode]], ]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
171 }
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
172
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
173 # Get subset
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
174 x <- db[, unlist(.self$.fields[cols]), drop = drop]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
175
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
176 # Rename columns
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
177 if (is.data.frame(x))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
178 colnames(x) <- cols
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
179
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
180 # Rearrange
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
181 if (drop && is.vector(x)) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
182 if (uniq)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
183 x <- x[ ! duplicated(x)]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
184 if (sort)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
185 x <- sort(x)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
186 }
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
187
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
188 # Cut
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
189 if ( ! is.na(max.rows))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
190 x <- if (is.vector(x)) x[1:max.rows] else x[1:max.rows, ]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
191 }
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
192
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
193 return(x)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
194 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
195
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
196 #################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
197 # GET ENTRY IDS #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
198 #################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
199
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
200 MassFiledbConn$methods( getEntryIds = function(type) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
201
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
202 ids <- NA_character_
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
203
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
204 if (type %in% c(BIODB.SPECTRUM, BIODB.COMPOUND))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
205 ids <- as.character(.self$.extract.cols(if (type == BIODB.SPECTRUM) BIODB.ACCESSION else BIODB.COMPOUND.ID, drop = TRUE, uniq = TRUE, sort = TRUE))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
206
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
207 return(ids)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
208 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
209
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
210 ##################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
211 # GET NB ENTRIES #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
212 ##################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
213
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
214 MassFiledbConn$methods( getNbEntries = function(type) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
215 return(length(.self$getEntryIds(type)))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
216 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
217
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
218 ###############################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
219 # GET CHROMATOGRAPHIC COLUMNS #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
220 ###############################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
221
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
222 # Inherited from MassdbConn.
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
223 MassFiledbConn$methods( getChromCol = function(compound.ids = NULL) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
224
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
225 # Extract needed columns
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
226 db <- .self$.extract.cols(c(BIODB.COMPOUND.ID, BIODB.CHROM.COL))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
227
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
228 # Filter on molecule IDs
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
229 if ( ! is.null(compound.ids))
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
230 db <- db[db[[BIODB.COMPOUND.ID]] %in% compound.ids, ]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
231
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
232 # Get column names
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
233 cols <- db[[BIODB.CHROM.COL]]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
234
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
235 # Remove duplicates
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
236 cols <- cols[ ! duplicated(cols)]
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
237
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
238 # Make data frame
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
239 chrom.cols <- data.frame(cols, cols, stringsAsFactors = FALSE)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
240 colnames(chrom.cols) <- c(BIODB.ID, BIODB.TITLE)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
241
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
242 return(chrom.cols)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
243 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
244
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
245 #################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
246 # GET MZ VALUES #
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
247 #################
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
248
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
249 # Inherited from MassdbConn.
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
250 MassFiledbConn$methods( getMzValues = function(mode = NULL, max.results = NA_integer_) {
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
251
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
252 # Get mz values
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
253 mz <- .self$.extract.cols(BIODB.PEAK.MZ, mode = mode, drop = TRUE, uniq = TRUE, sort = TRUE, max.rows = max.results)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
254
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
255 return(mz)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
256 })
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
257
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents:
diff changeset
258 }