annotate MsDb.R @ 0:e66bb061af06 draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
author prog
date Tue, 12 Jul 2016 12:02:37 -0400
parents
children 20d69a062da3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
1 if ( ! exists('MsDb')) { # Do not load again if already loaded
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
2
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
3 library('methods')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
4 source('msdb-common.R')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
5 source('MsDbObserver.R')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
6 source('MsDbOutputStream.R')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
7
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
8 #####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
9 # CLASS DECLARATION #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
10 #####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
11
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
12 MsDb <- setRefClass("MsDb", fields = list(.observers = "ANY", .prec = "list", .output.streams = "ANY", .input.stream = "ANY", .mz.tol.unit = "character"))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
13
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
14 ###############
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
15 # CONSTRUCTOR #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
16 ###############
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
17
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
18 MsDb$methods( initialize = function(...) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
19
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
20 .observers <<- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
21 .output.streams <<- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
22 .input.stream <<- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
23 .prec <<- MSDB.DFT.PREC
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
24 .mz.tol.unit <<- MSDB.DFT.MZTOLUNIT
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
25
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
26 callSuper(...)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
27 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
28
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
29 ####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
30 # SET INPUT STREAM #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
31 ####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
32
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
33 MsDb$methods( setInputStream = function(stream) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
34
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
35 # Check types of input stream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
36 if ( ! inherits(stream, "MsDbInputStream") && ! is.null(stream))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
37 stop("Input stream must inherit from MsDbInputStream class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
38
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
39 # Save current stream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
40 cur.stream <- .self$.input.stream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
41
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
42 # Set stream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
43 .input.stream <<- stream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
44
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
45 return(cur.stream)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
46 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
47
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
48 ######################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
49 # ADD OUTPUT STREAMS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
50 ######################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
51
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
52 MsDb$methods( addOutputStreams = function(stream) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
53
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
54 # Check types of output streams
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
55 if ( ( ! is.list(stream) && ! inherits(stream, "MsDbOutputStream")) || (is.list(stream) && any( ! vapply(stream, function(s) inherits(s, "MsDbOutputStream"), FUN.VALUE = TRUE))))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
56 stop("Output streams must inherit from MsDbOutputStream class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
57
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
58 # Add streams to current list
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
59 .output.streams <<- if (is.null(.self$.output.streams)) c(stream) else c(.self$.output.streams, stream)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
60 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
61
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
62 #########################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
63 # REMOVE OUTPUT STREAMS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
64 #########################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
65
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
66 MsDb$methods( removeOutputStreams = function(stream) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
67
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
68 # Check types of output streams
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
69 if ( ( ! is.list(stream) && ! inherits(stream, "MsDbOutputStream")) || (is.list(stream) && any( ! vapply(stream, function(s) inherits(s, "MsDbOutputStream"), FUN.VALUE = TRUE))))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
70
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
71 # Remove streams from current list
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
72 .output.streams <<- .self$.output.streams[ ! stream %in% .self$.output.streams]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
73 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
74
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
75 ########################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
76 # RESET OUTPUT STREAMS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
77 ########################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
78
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
79 MsDb$methods( resetOutputStreams = function(stream) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
80 .output.streams <<- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
81 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
82
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
83 #################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
84 # ADD OBSERVERS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
85 #################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
86
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
87 MsDb$methods( addObservers = function(obs) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
88
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
89 # Check types of observers
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
90 if ( ( ! is.list(obs) && ! inherits(obs, "MsDbObserver")) || (is.list(obs) && any( ! vapply(obs, function(o) inherits(o, "MsDbObserver"), FUN.VALUE = TRUE))))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
91 stop("Observers must inherit from MsDbObserver class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
92
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
93 # Add observers to current list
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
94 .observers <<- if (is.null(.self$.observers)) c(obs) else c(.self$.observers, obs)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
95 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
96
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
97 ##################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
98 # SET PRECURSORS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
99 ##################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
100
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
101 MsDb$methods( setPrecursors = function(prec) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
102 .prec <<- prec
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
103 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
104
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
105 #################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
106 # SET DB FIELDS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
107 #################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
108
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
109 MsDb$methods( areDbFieldsSettable = function() {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
110 return(FALSE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
111 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
112
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
113 MsDb$methods( setDbFields = function(fields) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
114 stop("Method setDbFields() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
115 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
116
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
117 ################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
118 # SET MS MODES #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
119 ################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
120
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
121 MsDb$methods( areDbMsModesSettable = function() {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
122 return(FALSE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
123 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
124
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
125 MsDb$methods( setDbMsModes = function(modes) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
126 stop("Method setDbMsModes() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
127 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
128
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
129 MsDb$methods( setMzTolUnit = function(mztolunit) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
130
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
131 if ( ! mztolunit %in% MSDB.MZTOLUNIT.VALS)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
132 stop(paste0("M/Z tolerance unit must be one of: ", paste(MSDB.MZTOLUNIT.VALS, collapse = ', '), "."))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
133
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
134 .mz.tol.unit <<- mztolunit
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
135 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
136
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
137 ####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
138 # GET MOLECULE IDS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
139 ####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
140
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
141 # Returns an integer vector of all molecule IDs stored inside the database.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
142 MsDb$methods( getMoleculeIds = function() {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
143 stop("Method getMoleculeIds() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
144 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
145
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
146 ####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
147 # GET NB MOLECULES #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
148 ####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
149
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
150 # Returns the number of molecules in the database.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
151 MsDb$methods( getNbMolecules = function() {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
152 stop("Method getNbMolecules() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
153 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
154
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
155 #################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
156 # GET MZ VALUES #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
157 #################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
158
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
159 # Returns a numeric vector of all masses stored inside the database.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
160 MsDb$methods( getMzValues = function(mode = NULL) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
161 stop("Method getMzValues() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
162 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
163
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
164 #####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
165 # GET MOLECULE NAME #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
166 #####################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
167
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
168 # Get molecule names
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
169 # molid An integer vector of molecule IDs.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
170 # Returns a character vector containing the names of the molecule IDs, in the same order as the input vector.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
171 MsDb$methods( getMoleculeName = function(molid) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
172 stop("Method getMoleculeName() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
173 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
174
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
175 ###############################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
176 # GET CHROMATOGRAPHIC COLUMNS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
177 ###############################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
178
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
179 # Get chromatographic columns.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
180 # Returns a vector of character listing the chromatographic column names. The name must be formatted in lowercase as following: uplc(-c8)?(-20min)?.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
181 MsDb$methods( getChromCol = function(molid = NULL) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
182 stop("Method getChromCol() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
183 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
184
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
185 ################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
186 # FIND BY NAME #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
187 ################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
188
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
189 # Find a molecule by name
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
190 # name A vector of molecule names to search for.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
191 # Return an integer vector of the same size as the name input vector, containing the found molecule IDs, in the same order.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
192 MsDb$methods( findByName = function(name) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
193 stop("Method findByName() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
194 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
195
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
196 #######################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
197 # GET RETENTION TIMES #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
198 #######################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
199
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
200 # Get the retention times of a molecule.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
201 # Returns a list of numeric vectors. The list has for keys/names the columns, and for values vectors of numerics (the retention times). If no retention times are registered for this molecule, then returns an empty list.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
202 MsDb$methods( getRetentionTimes = function(molid, col = NA_character_) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
203 stop("Method getRetentionTimes() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
204 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
205
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
206 ################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
207 # GET NB PEAKS #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
208 ################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
209
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
210 # Get the total number of MS peaks stored inside the database.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
211 # molid The ID of the molecule.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
212 # type The MS type.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
213 MsDb$methods( getNbPeaks = function(molid = NA_integer_, type = NA_character_) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
214 stop("Method getNbPeaks() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
215 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
216
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
217 ##################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
218 # GET PEAK TABLE #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
219 ##################
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
220
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
221 MsDb$methods( getPeakTable = function(molid = NA_integer_, mode = NA_character_){
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
222 stop("Method getPeakTable() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
223 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
224
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
225 ##########
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
226 # SEARCH #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
227 ##########
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
228
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
229 # Find molecule MS peaks whose m/z matches the submitted m/z in the tolerance specified.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
230 # mode The mode to use: either MSDB.TAG.POS or MSDB.TAG.NEG.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
231 # shift The m/z shift to use, in ppm.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
232 # prec The m/z precision to use, in ppm.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
233 # col The chromatographic column used.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
234 # rt.tol Simple retention tolerance parameter: rtinf = rt - rt.tol and rtsup = rt + rt.tol
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
235 # rt.tol.x Tolerance parameter for the equations : rtinf = rt - rt.tol.x - rt ^ rt.tol.y and rtsup = rt + rt.tol.x + rt ^ rt.tol.y
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
236 # rt.tol.y Tolerance parameter. See rt.tol.x parameter.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
237 # attribs Only search for peaks whose attribution is among this set of attributions.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
238 # molids Only search for peaks whose molecule ID is among this vector of integer molecule IDs. Can also be a data frame with a retention time column x.colnames$rt and a molecule ID column MSDB.TAG.molid.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
239 # molids.rt.tol Retention time tolerance used when molids parameter is a data frame (rt, id)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
240 # precursor.match Remove peaks whose molecule precursor peak has not also been matched.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
241 # precursor.rt.tol
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
242 # Returns a data frame, listing m/z values provided in input. Several matches can be found for an m/z value, in which case several lines (the same number as the number of matches found) with the same m/z value repeated will be inserted. The m/z values will be listed in the same order as in the input. The columns of the data.frame are: mz, rt (only if present in the input), id, mztheo, col, colrt, composition, attribution.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
243 MsDb$methods( searchForMzRtList = function(x = NULL, mode, shift = NULL, prec = NULL, col = NULL, rt.tol = NULL, rt.tol.x = NULL, rt.tol.y = NULL, molids = NULL, molids.rt.tol = NULL, attribs = NULL, precursor.match = FALSE, precursor.rt.tol = NULL, same.cols = FALSE, same.rows = FALSE, peak.table = FALSE) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
244
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
245 # Use provided data frame
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
246 old.input <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
247 tmp.output <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
248 if ( ! is.null(x)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
249 tmp.input <- MsDbInputDataFrameStream$new(df = x)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
250 tmp.output <- MsDbOutputDataFrameStream$new()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
251 old.input <- .self$setInputStream(tmp.input)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
252 .self$addOutputStreams(tmp.output)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
253 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
254
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
255 if (precursor.match) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
256 # Get IDs of all molecules whose precursor peak matches one of the mz in the list
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
257 precursors.df <- .self$.doSearchForMzRtList(mode = mode, shift = shift, prec = prec, col = col, rt.tol = rt.tol, rt.tol.x = rt.tol.x, rt.tol.y = rt.tol.y, attribs = .self$.prec[[mode]], output.to.stream = FALSE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
258 cols.to.keep <- if (is.null(col)) MSDB.TAG.MOLID else c(MSDB.TAG.MOLID, MSDB.TAG.COL, MSDB.TAG.COLRT)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
259 precursors.ids <- precursors.df[, cols.to.keep, drop = FALSE]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
260 precursors.ids <- precursors.ids[ ! is.na(precursors.ids[[MSDB.TAG.MOLID]]), , drop = FALSE]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
261 precursors.ids <- precursors.ids[ ! duplicated(precursors.ids), ]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
262
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
263 # Get all matching peaks whose molecule is inside the previously obtained list of molecules
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
264 .self$.doSearchForMzRtList(mode = mode, shift = shift, prec = prec, col = col, rt.tol = NULL, rt.tol.x = NULL, rt.tol.y = NULL, molids = precursors.ids, molids.rt.tol = precursor.rt.tol, same.cols = same.cols, same.rows = same.rows, peak.table = peak.table)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
265 # TODO
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
266 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
267 # peaks <- if (peak.table) results[['peaks']] else results
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
268 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
269 # # Merge results with the column/rt found for precursors.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
270 # if ( ! is.null(col) && ! is.null(peaks)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
271 # precursors.ids <- precursors.df[, c(MSDB.TAG.MOLID, MSDB.TAG.col, MSDB.TAG.COLRT)]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
272 # precursors.ids <- precursors.ids[ ! is.na(precursors.ids[[MSDB.TAG.MOLID]]), ]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
273 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
274 # # Get rows where ID is NA
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
275 # peaks.na <- peaks[is.na(peaks[[MSDB.TAG.MOLID]]), ]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
276 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
277 # # Get rows where ID is found (i.e.: not NA)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
278 # peaks <- peaks[, !(colnames(peaks) %in% c(MSDB.TAG.COL, MSDB.TAG.COLRT))] # drop col and colrt columns
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
279 # peaks.not.na <- peaks[! is.na(peaks[[MSDB.TAG.MOLID]]), ]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
280 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
281 # # Add col and colrt values to found peaks
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
282 # peaks <- merge(peaks.not.na, precursors.ids, by = MSDB.TAG.MOLID)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
283 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
284 # # Put back unfound peaks
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
285 # peaks <- rbind(peaks, peaks.na)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
286 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
287 # # Sort
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
288 # print(colnames(peaks))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
289 # print(x.colnames)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
290 # peaks <- peaks[order(peaks[[x.colnames$mz]], peaks[[x.colnames$rt]], peaks[[MSDB.TAG.MOLID]], peaks[[MSDB.TAG.COL]]), ]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
291 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
292 # # Remove rownames
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
293 # rownames(peaks) <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
294 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
295 # # Reorder columns
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
296 # peaks <- peaks[unlist(.self$.output.fields[names(.PEAK.TABLE.COLS)])]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
297 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
298 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
299 # # Remove duplicates
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
300 # if ( ! is.null(peaks))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
301 # peaks <- peaks[ ! duplicated(peaks), ]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
302 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
303 # if (peak.table)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
304 # results[['peaks']] <- peaks
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
305 # else
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
306 # results <- peaks
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
307 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
308 # return(results)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
309 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
310 else
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
311 .self$.doSearchForMzRtList(mode = mode, shift = shift, prec = prec, col = col, rt.tol = rt.tol, rt.tol.x = rt.tol.x, rt.tol.y = rt.tol.y, molids = molids, molids.rt.tol = molids.rt.tol, attribs = attribs, same.cols = same.cols, same.rows = same.rows, peak.table = peak.table)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
312
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
313 if ( ! is.null(x)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
314 results <- tmp.output$getDataFrame()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
315 .self$removeOutputStreams(tmp.output)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
316 .self$setInputStream(old.input)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
317 return(results)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
318 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
319 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
320
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
321 MsDb$methods( .doSearchForMzRtList = function(mode, shift = NULL, prec = NULL, col = NULL, rt.tol = NULL, rt.tol.x = NULL, rt.tol.y = NULL, molids = NULL, molids.rt.tol = NULL, attribs = NULL, same.cols = FALSE, same.rows = FALSE, peak.table = FALSE, output.to.stream = TRUE) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
322
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
323 # # Choose columns to keep from x
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
324 # x.cols <- if (same.cols) colnames(x) else intersect(if (is.null(col)) c(x.colnames$mz) else c(x.colnames$mz, x.colnames$rt), colnames(x))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
325 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
326 # # Create a peak fake data frame for defining columns
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
327 # peaks.fake <- data.frame(stringsAsFactors = FALSE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
328 # for (field in names(.PEAK.TABLE.COLS))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
329 # if ( ! is.null(col) || ! field %in% .RT.MATCHING.COLS)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
330 # peaks.fake[.self$.output.fields[[field]]] <- vector(mode = .PEAK.TABLE.COLS[[field]], length = 0)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
331 #
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
332 # # Initialize y data frame, so when x contains no rows an empty y data frame is returned with all the columns set with right type.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
333 # if (same.rows) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
334 # y <- peaks.fake[, if (is.null(col)) c(MSDB.TAG.MZ) else c(MSDB.TAG.MZ, MSDB.TAG.RT), drop = FALSE]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
335 # y[MSDB.TAG.MSMATCHING] <- character()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
336 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
337 # else
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
338 # y <- peaks.fake
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
339 # y <- cbind(y, x[NULL, ! x.cols %in% colnames(y), drop = FALSE])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
340 # if (peak.table) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
341 # z <- peaks.fake
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
342 # z <- cbind(z, x[NULL, ! x.cols %in% colnames(z), drop = FALSE])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
343 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
344
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
345 # Loop on all lines of input
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
346 peaks <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
347 while (.self$.input.stream$hasNextValues()) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
348
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
349 .self$.input.stream$nextValues()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
350
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
351 # Search for m/z
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
352 results <- .self$searchForMzRtTols(mode = mode, mz = .self$.input.stream$getMz(), shift = shift, prec = prec, rt = .self$.input.stream$getRt(), col = col, rt.tol = rt.tol, rt.tol.x = rt.tol.x, rt.tol.y = rt.tol.y, attribs = attribs, molids = molids, molids.rt.tol = molids.rt.tol)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
353
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
354 # Call output streams
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
355 if (output.to.stream && ! is.null(.self$.output.streams))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
356 for (s in .self$.output.streams)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
357 s$matchedPeaks(mz = .self$.input.stream$getMz(), rt = if (is.null(col)) NULL else .self$.input.stream$getRt(), peaks = results, unused = .self$.input.stream$getAll(but = if (is.null(col)) c(MSDB.TAG.MZ) else c(MSDB.TAG.MZ, MSDB.TAG.RT)))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
358
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
359 # Append to peak list
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
360 peaks <- rbind(peaks, results)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
361
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
362 # # Add results to output
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
363 # r <- nrow(y) + 1
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
364 # x.lines <- x[i, x.cols, drop = FALSE]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
365 # x.lines <- rename.col(x.lines, unlist(x.colnames), unlist(.self$.output.fields[names(x.colnames)]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
366 # if (nrow(results) == 0) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
367 # y[r, colnames(x.lines)] <- x.lines
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
368 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
369 # else {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
370 # if (same.rows) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
371 # y[r, colnames(x.lines)] <- x.lines
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
372 # ids <- results[[MSDB.TAG.molid]]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
373 # ids <- ids[ ! duplicated(ids)] # Remove duplicated values
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
374 # y[r, MSDB.TAG.msmatching] <- paste(ids, collapse = .self$.molids.sep)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
375 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
376 # if ( ! same.rows || peak.table) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
377 # new.rows <- cbind(x.lines, results, row.names = NULL)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
378 # if ( ! same.rows) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
379 # rows <- r:(r+nrow(results)-1)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
380 # y[rows, colnames(new.rows)] <- new.rows
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
381 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
382 # if (peak.table) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
383 # zr <- nrow(z) + 1
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
384 # zrows <- zr:(zr+nrow(results)-1)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
385 # z[zrows, colnames(new.rows)] <- new.rows
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
386 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
387 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
388 # }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
389 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
390
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
391 # results <- if (peak.table) list(main = y, peaks = z) else y
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
392
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
393 # return(results)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
394 return(peaks)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
395 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
396
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
397 # rt Retention time in seconds.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
398 # molids An option vector of molecule IDs, used to restrict the search.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
399 MsDb$methods( searchForMzRtTols = function(mode, mz, rt = NULL, shift = NULL, prec = NULL, col = NULL, rt.tol = NULL, rt.tol.x = NULL, rt.tol.y = NULL, attribs = NULL, molids = NULL, molids.rt.tol = NULL, colnames = MSDB.DFT.INPUT.FIELDS) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
400
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
401 # Set M/Z bounds
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
402 if (.self$.mz.tol.unit == MSDB.MZTOLUNIT.PPM) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
403 mz.low <- mz * (1 + (- shift - prec) * 1e-6)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
404 mz.high <- mz * (1 + (- shift + prec) * 1e-6)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
405 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
406 else { # PLAIN
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
407 mz.low <- mz - shift - prec
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
408 mz.high <- mz - shift + prec
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
409 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
410
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
411 # Set retention time bounds
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
412 rt.low <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
413 rt.high <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
414 if ( ! is.null(rt.tol)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
415 low <- rt - rt.tol
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
416 high <- rt + rt.tol
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
417 rt.low <- if (is.null(rt.low)) low else max(low, rt.low)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
418 rt.high <- if (is.null(rt.high)) high else min(high, rt.high)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
419 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
420 if ( ! is.null(rt.tol.x)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
421 low <- rt - rt.tol.x - rt ^ rt.tol.y
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
422 high <- rt + rt.tol.x + rt ^ rt.tol.y
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
423 rt.low <- if (is.null(rt.low)) low else max(low, rt.low)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
424 rt.high <- if (is.null(rt.high)) high else min(high, rt.high)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
425 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
426
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
427 # List molecule IDs
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
428 if ( ! is.null(molids.rt.tol) && is.data.frame(molids)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
429 ids <- molids[(rt >= molids[[MSDB.TAG.colrt]] - molids.rt.tol) & (rt <= molids[[MSDB.TAG.colrt]] + molids.rt.tol), MSDB.TAG.molid]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
430 if (length(ids) == 0)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
431 # No molecule ID match for this retention time
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
432 return(data.frame()) # return empty result set
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
433 } else {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
434 ids <- molids
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
435 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
436
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
437 return(.self$searchForMzRtBounds(mode,
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
438 mz.low = mz * (1 + (- shift - prec) * 1e-6),
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
439 mz.high = mz * (1 + (- shift + prec) * 1e-6),
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
440 rt.low = rt.low,
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
441 rt.high = rt.high,
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
442 col = col,
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
443 attribs = attribs,
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
444 molids = ids))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
445 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
446
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
447 # rt.low Lower bound of the retention time in seconds.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
448 # rt.high Higher bound of the retention time in seconds.
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
449 MsDb$methods( searchForMzRtBounds = function(mode, mz.low, mz.high, rt.low = NULL, rt.high = NULL, col = NULL, attribs = NULL, molids = NULL) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
450
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
451 results <- .self$.do.search.for.mz.rt.bounds(mode = mode, mz.low = mz.low, mz.high = mz.high, rt.low = rt.low, rt.high = rt.high, col = col, attribs = attribs, molids = molids)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
452
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
453 return(results)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
454 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
455
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
456 # TODO Write description of output: data frame with which columns ?
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
457 MsDb$methods( .do.search.for.mz.rt.bounds = function(mode, mz.low, mz.high, rt.low = NULL, rt.high = NULL, col = NULL, attribs = NULL, molids = NULL) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
458 stop("Method .do.search.for.mz.rt.bounds() not implemented in concrete class.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
459 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
460
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
461 # DEPRECATED
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
462 MsDb$methods( searchForMz = function(x, mode, tol = 5, col = NULL, rt.tol.x = 5, rt.tol.y = 0.80) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
463 warning("Method searchForMz() is deprecated. Use searchForMzRtList() instead.")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
464 .self$searchForMzRtList(x = x, mode = mode, prec = tol, col = col, rt.tol.x = rt.tol.x, rt.tol.y = rt.tol.y)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
465 })
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
466
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
467 } # end of load safe guard