annotate search-mz @ 5:fb9c0409d85c draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
author prog
date Wed, 19 Apr 2017 10:00:05 -0400
parents 20d69a062da3
children
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 #!/usr/bin/env Rscript
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
2 # vi: ft=R fdm=marker
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
3 args <- commandArgs(trailingOnly = F)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
4 script.path <- sub("--file=","",args[grep("--file=",args)])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
5 library(getopt)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
6 source(file.path(dirname(script.path), 'msdb-common.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
7 source(file.path(dirname(script.path), 'MsDbLogger.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
8 source(file.path(dirname(script.path), 'MsDbInputDataFrameStream.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
9 source(file.path(dirname(script.path), 'MsDbOutputDataFrameStream.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
10 source(file.path(dirname(script.path), 'htmlhlp.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
11 source(file.path(dirname(script.path), 'strhlp.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
12 source(file.path(dirname(script.path), 'fshlp.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
13 source(file.path(dirname(script.path), 'biodb-common.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
14 source(file.path(dirname(script.path), 'nethlp.R'), chdir = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
15
1
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
16 # Missing paste0() function in R 2.14.1
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
17 if (as.integer(R.Version()$major) == 2 && as.numeric(R.Version()$minor) < 15)
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
18 paste0 <- function(...) paste(..., sep = '')
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
19
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
20 # Constants {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
21 ################################################################
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
22
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
23 PROG <- sub('^.*/([^/]+)$', '\\1', commandArgs()[4], perl = TRUE)
1
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
24 USERAGENT <- 'search-mz ; pierrick.roger@gmail.com'
0
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 # Authorized database types
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
27 MSDB.XLS <- 'xls'
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
28 MSDB.4TABSQL <- '4tabsql'
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
29 MSDB.FILE <- 'file'
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
30 MSDB.PEAKFOREST <- 'peakforest'
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
31 MSDB.VALS <- c(MSDB.XLS, MSDB.4TABSQL, MSDB.FILE, MSDB.PEAKFOREST)
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
32 DB.SRC.FILE <- list ()
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
33 DB.SRC.FILE[[MSDB.FILE]] <- 'MsFileDb.R'
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
34 DB.SRC.FILE[[MSDB.PEAKFOREST]] <- 'MsPeakForestDb.R'
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
35 DB.SRC.FILE[[MSDB.XLS]] <- 'MsXlsDb.R'
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
36 DB.SRC.FILE[[MSDB.4TABSQL]] <- 'Ms4TabSqlDb.R'
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
37
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
38 # Authorized mode values
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
39 POS_MODE <- 'pos'
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
40 NEG_MODE <- 'neg'
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
41 MSDB.MODE.VALS <- c(POS_MODE, NEG_MODE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
42
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
43 # Default
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
44 MSDB.DFT <- list()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
45 MSDB.DFT[['mzshift']] <- 0 # in ppm
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
46 MSDB.DFT[['mzprec']] <- 5 # in ppm
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
47 MSDB.DFT[['mztolunit']] <- MSDB.DFT.MZTOLUNIT
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
48 MSDB.DFT[['precursor-rt-tol']] <- 5
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
49 MSDB.DFT[['molids-sep']] <- MSDB.DFT.MATCH.SEP
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
50 MSDB.DFT[['db-fields']] <- concat.kv.list(msdb.get.dft.db.fields())
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
51 MSDB.DFT[['db-ms-modes']] <- concat.kv.list(MSDB.DFT.MODES)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
52 MSDB.DFT[['pos-prec']] <- paste(MSDB.DFT.PREC[[MSDB.TAG.POS]], collapse = ',')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
53 MSDB.DFT[['neg-prec']] <- paste(MSDB.DFT.PREC[[MSDB.TAG.NEG]], collapse = ',')
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
54 MSDB.DFT[['db-rt-unit']] <- MSDB.RTUNIT.SEC
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
55 MSDB.DFT[['rtunit']] <- MSDB.RTUNIT.SEC
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
56 DEFAULT.ARG.VALUES <- MSDB.DFT
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
57 DEFAULT.ARG.VALUES[['input-col-names']] <- concat.kv.list(msdb.get.dft.input.fields())
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
58
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
59 # Print help {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
60 ################################################################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
61
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
62 print.help <- function() {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
63
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
64 cat("USAGE:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
65 prog.mz.match <- paste(PROG, ' -d (', paste(MSDB.VALS, collapse = '|'), ') --url (file|dir|database URL) -i <file> -m (', paste(MSDB.MODE.VALS, collapse = '|'), ") -p <mz precision> -s <mz shift> -u (", paste(MSDB.MZTOLUNIT.VALS, collapse = '|'), ") -o <file>", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
66 cat("\t(1) ", prog.mz.match, " ...\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
67 cat("\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
68 cat("\t(2) ", prog.mz.match, "(--all-cols|-c <cols>) -x <X RT tolerance> -y <Y RT tolerance>", " ...\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
69 cat("\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
70 cat("\t(3) ", PROG, ' -d (', paste(MSDB.VALS, collapse = '|'), ") --url (file|dir|database URL) --list-cols\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
71
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
72 cat("\nDETAILS:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
73 cat("Form (1) is for running an MZ match on a database.\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
74 cat("Form (2) is for running an MZ/RT match on a database.\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
75 cat("Form (3) is for getting a list of available chromatographic columns in a database.\n")
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
76
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
77 cat("\nOPTIONS:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
78 spec <- matrix(make.getopt.spec(), byrow = TRUE, ncol = 5)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
79 max.length.opt.cols <- max(nchar(spec[,1])) + 1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
80 sections <- list(database = "Database setting", input = "Input file", output = "Output files", mz = "M/Z matching", rt = "RT matching", precursor = "Precursor matching", misc = "Miscellaneous")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
81 for (section in names(sections)) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
82 cat("\n\t", sections[[section]], ":\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
83 spec <- matrix(make.getopt.spec(section), byrow = TRUE, ncol = 5)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
84 for (i in seq(nrow(spec))) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
85 opt <- ''
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
86 if ( ! is.na(spec[i,2]))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
87 opt <- paste('-', spec[i,2], '|', sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
88 opt <- paste(opt, '--', spec[i, 1], sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
89 nb.space.padding <- max.length.opt.cols - nchar(opt) + 6
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
90 padding <- paste(rep(' ', nb.space.padding), sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
91 cat("\t\t", opt, padding, "\t", spec[i, 5], "\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
92 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
93 }
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
94
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
95 cat("\nEXAMPLES:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
96
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
97 cat("\nSimple M/Z matching with a file database:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
98 cat("\t./", PROG, " -d file --url mydbfile.tsv -i input.tsv -m pos -o output.tsv\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
99
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
100 cat("\nFile database with M/Z tolerance:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
101 cat("\t./", PROG, " -d file --url mydbfile.tsv -i input.tsv -m pos -o output.tsv -p 0.5 -s 0\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
102
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
103 cat("\nFile database with M/Z tolerance unit:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
104 cat("\t./", PROG, " -d file --url mydbfile.tsv -i input.tsv -m pos -o output.tsv -p 1 -s 0.5 -u plain\n", sep = '')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
105
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
106 cat("\nPeakforest database:\n")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
107 cat("\t./", PROG, " -d peakforest --url https://rest.peakforest.org/ --db-token <your Peakforest token> -i input.tsv -m pos -o output.tsv\n", sep = '')
0
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
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
110 # Set default argument values {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
111 ################################################################
0
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 set.dft.arg.val <-function(opt) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
114
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
115 for (f in names(MSDB.DFT))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
116 if (is.null(opt[[f]]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
117 opt[[f]] <- MSDB.DFT[[f]]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
118
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
119 # Set default values
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
120 if ( opt$database == MSDB.XLS && ! is.null(opt$url) && is.null(opt[['cache-dir']]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
121 opt[['cache-dir']] <- file.path(opt$url, 'cache')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
122
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
123 if ( ! is.null(opt$rtcol) && opt$rtcol == '')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
124 opt$rtcol <- NULL
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
125
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
126 return(opt)
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
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
129 # Parse argument values {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
130 ################################################################
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
131
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
132 parse.arg.val <- function(opt) {
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 # Parse input column names
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
135 if ( ! is.null(opt[['db-fields']])) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
136 cust <- split.kv.list(opt[['db-fields']])
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
137 cust <- cust[cust != 'NA']
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
138 opt[['db-fields']] <- split.kv.list(MSDB.DFT[['db-fields']])
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
139 cust <- cust[names(cust) %in% names(opt[['db-fields']])]
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
140 opt[['db-fields']][names(cust)] <- cust
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
141 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
142
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
143 # Parse MS modes
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
144 if ( ! is.null(opt[['db-ms-modes']])) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
145 cust <- split.kv.list(opt[['db-ms-modes']])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
146 opt[['db-ms-modes']] <- split.kv.list(MSDB.DFT[['db-ms-modes']])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
147 opt[['db-ms-modes']][names(cust)] <- cust
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 # Parse retention time columns
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
151 if ( ! is.null(opt$rtcol))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
152 opt$rtcol <- strsplit(opt$rtcol, ',')[[1]]
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 # Parse input column names
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
155 if (is.null(opt[['input-col-names']])) {
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
156 opt[['input-col-names']] <- msdb.get.dft.input.fields()
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
157 }
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
158 else {
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
159 custcols <- split.kv.list(opt[['input-col-names']])
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
160 custcols <- custcols[custcols != 'NA']
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
161 dftcols <- msdb.get.dft.input.fields()
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
162 opt[['input-col-names']] <- c(custcols, dftcols[ ! names(dftcols) %in% names(custcols)])
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 # Parse lists of precursors
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
166 if ( ! is.null(opt[['pos-prec']]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
167 opt[['pos-prec']] <- split.str(opt[['pos-prec']], unlist = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
168 if ( ! is.null(opt[['neg-prec']]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
169 opt[['neg-prec']] <- split.str(opt[['neg-prec']], unlist = TRUE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
170
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
171 return(opt)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
172 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
173
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
174 # Make getopt specifications {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
175 ################################################################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
176
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
177 make.getopt.spec <- function(sections = NULL) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
178
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
179 spec <- character(0)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
180
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
181 if (is.null(sections) || 'input' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
182 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
183 'input-file', 'i', 1, 'character', 'Set input file.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
184 'input-col-names', 'j', 1, 'character', paste0('Set the input column names. Default is "', DEFAULT.ARG.VALUES[['input-col-names']], '".')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
185 )
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
186
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
187 if (is.null(sections) || 'mz' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
188 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
189 'mode', 'm', 1, 'character', paste0('MS mode. Possible values are:', paste(MSDB.MODE.VALS, collapse = ", "), '.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
190 'mzshift', 's', 1, 'numeric', paste0('Shift on m/z. Default is ', MSDB.DFT$mzshift,'.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
191 'mzprec', 'p', 1, 'numeric', paste0('Tolerance on m/z. Default is ', MSDB.DFT$mzprec,'.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
192 'mztolunit', 'u', 1, 'character', paste0('Unit used for tolerance values (options -s and -p) on M/Z. Default is ', MSDB.DFT$mztolunit,'.')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
193 )
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
194
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
195 if (is.null(sections) || 'rt' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
196 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
197 'all-cols', 'A', 0, 'logical', 'Use all available chromatographic columns to match retention times.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
198 'rtcol', 'c', 1, 'character', paste0('Chromatographic column to use. Unset by default. If set, use the corresponding column to filter on retention times, if retention times are provided.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
199 'check-cols', 'k', 0, 'logical', 'Check that the chromatographic column names specified with option -c really exist.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
200 'list-cols', 'l', 0, 'logical', 'List all chromatographic columns present in the database. Write list inside the file specified by -o option.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
201 'rttol', 'r', 1, 'numeric', paste0('Tolerance on retention times. Unset by default.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
202 'rttolx', 'x', 1, 'numeric', paste0('Tolerance on retention times. Unset by default.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
203 'rttoly', 'y', 1, 'numeric', paste0('Tolerance on retention times. Unset by default.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
204 'rtunit', 'v', 1, 'character', paste0('Retention time unit for the input file. Default is ', MSDB.DFT$rtunit, '. Allowed values are:', paste(MSDB.RTUNIT.VALS, collapse = ", "), '.')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
205 )
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
206
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
207 if (is.null(sections) || 'precursor' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
208 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
209 'precursor-match', 'Q', 0, 'logical', 'Remove peaks whose molecule precursor peak has not been matched. Unset by default.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
210 'precursor-rt-tol', 'R', 1, 'numeric', paste0('Precursor retention time tolerance. Only used when precursor-match is enabled. Default is ', MSDB.DFT[['precursor-rt-tol']], '.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
211 'pos-prec', 'Y', 1, 'character', paste0('Set the list of precursors to use in positive mode. Default is "', MSDB.DFT[['pos-prec']], '".'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
212 'neg-prec', 'Z', 1, 'character', paste0('Set the list of precursors to use in negative mode. Default is "', MSDB.DFT[['neg-prec']], '".')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
213 )
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
214
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
215 if (is.null(sections) || 'output' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
216 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
217 'output-file', 'o', 1, 'character', 'Set file to use for the main output.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
218 'peak-output-file', 'O', 1, 'character', 'If set and if --same-rows is set, then output all matches inside the specified file, with one mz match per line. The output columns are: mz, rt, id, col, colrt, composition, attribution. This means that if an mz value is matched several times, then it will repeated on several lines, with one match description per line.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
219 'html-output-file', 'H', 1, 'character', 'Set file to use for the HTML output.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
220 'no-main-table-in-html-output', 't', 0, 'logical', 'Do not display main table in HTML output.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
221 'same-rows', 'a', 0, 'logical', 'If set, output exactly the same number of rows as the input. This means that in case of multiple matches for one mz, then only one line is output (i.e.: the mz value is not duplicated on several lines). In the main output file, an "ms.matching" column is output with inside, for each mz, a comma separated list of matched component/molecule IDs. If unset, then only the main output file is used, and one single is written to it with one line per peak match, and eventual mz line duplicated if there are multiple matches for this mz.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
222 'same-cols', 'b', 0, 'logical', 'If set, output the same columns as inside the input. All input columns are copied to the output.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
223 'molids-sep', 'S', 1, 'character', paste0('Set character separator used to when concatenating molecule IDs in output. Default is "', MSDB.DFT[['molids-sep']] , '".'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
224 'first-val', '1', 0, 'logical', 'Keep only the first value in multi-value fields. Unset by default.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
225 'excel2011comp', 'X', 0, 'logical', 'Excel 2011 compatiblity mode. Output ASCII text files instead of UTF-8 files, where greek letters are replaced with their latin names, plusminus sign is replaced with +- and apostrophe is replaced with \"prime\". All other non-ASCII characters are repladed with underscore.'
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
226 )
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
227
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
228 if (is.null(sections) || 'database' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
229 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
230 'database', 'd', 1, 'character', paste0('Set database to use: "xls" for an Excel database, "file" for a single file database, "4tabsql" for a 4Tab SQL database, and "peakforest" for a connection to PeakForest database.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
231 'url', 'W', 1, 'character', 'URL of database. For "peakforest" database it is the HTTP URL, for the "xls" database it is the path to the directory containing the Excel files, for the "file" database it is the path to the file database and for the "4tabsql" database it is the IP address of the server.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
232 'cache-dir', 'C', 1, 'character', 'Path to directory where to store cache files. Only used when database flag is set to "xls".',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
233 'db-name', 'N', 1, 'character', 'Name of the database. Used by the "4tabsql" database.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
234 'db-user', 'U', 1, 'character', 'User of the database. Used by the "4tabsql" database.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
235 'db-password', 'P', 1, 'character', 'Password of the database user. Used by the "4tabsql" database.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
236 'db-ms-modes', 'M', 1, 'character', paste0('Comma separated key/value list giving the MS modes to be used in the single file database. Default is "', MSDB.DFT[['db-ms-modes']], '".'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
237 'db-rt-unit', 'V', 1, 'character', paste0('Retention time unit for the database, used in the single file database. Default is "', MSDB.DFT[['db-rt-unit']], '". Allowed values are:', paste(MSDB.RTUNIT.VALS, collapse = ", "), '.'),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
238 'db-token', 'T', 1, 'character', 'Database token. Used by Peakforest database.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
239 'db-fields', 'F', 1, 'character', paste0('Comma separated key/value list giving the field names to be used in the single file database. Default is "', MSDB.DFT[['db-fields']], '".')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
240 )
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
241
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
242 if (is.null(sections) || 'misc' %in% sections)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
243 spec <- c(spec,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
244 'help', 'h', 0, 'logical', 'Print this help.',
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
245 'debug', 'g', 0, 'logical', 'Set debug mode.'
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
246 )
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
247
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
248 return(spec)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
249 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
250
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
251 # Read args {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
252 ################################################################
0
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 read_args <- function() {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
255
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
256 # Get options
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
257 opt <- getopt(matrix(make.getopt.spec(), byrow = TRUE, ncol = 5))
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
258
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
259 # help
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
260 if ( ! is.null(opt$help)) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
261 print.help()
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
262 quit()
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
263 }
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
264
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
265 opt <- set.dft.arg.val(opt) # Set default values
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
266 opt <- parse.arg.val(opt) # Parse list values
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
267
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
268 # Check values
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
269 error <- check.args(opt)
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
270
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
271 return(opt)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
272 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
273
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
274 # Check args {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
275 ################################################################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
276
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
277 check.args <- function(opt) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
278
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
279 # Check database type
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
280 if (is.null(opt$database))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
281 stop("You must provide a database type through --database option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
282 if ( ! opt$database %in% MSDB.VALS)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
283 stop(paste0("Invalid value \"", opt$database, "\" for --database option."))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
284
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
285 # Check filedb database
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
286 if (opt$database == MSDB.FILE) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
287 if (is.null(opt$url))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
288 stop("When using single file database, you must specify the location of the database file with option --url.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
289 if ( ! file.exists(opt$url))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
290 stop(paste0("The file path \"", opt$url,"\" specified with --db-file option is not valid."))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
291 }
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
292
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
293 # Check Excel database
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
294 if (opt$database == MSDB.XLS) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
295 if (is.null(opt$url))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
296 stop("When using Excel database, you must specify the location of the Excel files directory with option --url.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
297 if ( ! file.exists(opt$url))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
298 stop(paste0("The directory path \"", opt$url,"\" specified with --xls-dir option is not valid."))
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
299 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
300
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
301 # Check 4 tab database
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
302 if (opt$database == MSDB.4TABSQL) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
303 if (is.null(opt$url))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
304 stop("When using 4Tab SQL database, you must specify the URL of the SQL server with option --url.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
305 if (is.null(opt[['db-name']]))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
306 stop("When using 4Tab SQL database, you must specify the database name through the --db-name option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
307 if (is.null(opt[['db-user']]))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
308 stop("When using 4Tab SQL database, you must specify the database user through the --db-user option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
309 if (is.null(opt[['db-password']]))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
310 stop("When using 4Tab SQL database, you must specify the database user password through the --db-password option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
311 }
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
312
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
313 # Check Peakforest database
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
314 if (opt$database == MSDB.PEAKFOREST) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
315 if (is.null(opt$url))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
316 stop("When using PeakForest database, you must specify the URL of the PeakForest server with option --url.")
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
317 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
318
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
319 if (is.null(opt[['list-cols']])) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
320
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
321 if (is.null(opt[['output-file']]))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
322 stop("You must set a path for the output file.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
323
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
324 if (is.null(opt[['input-file']]))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
325 stop("You must provide an input file.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
326
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
327 if (is.null(opt$mode) || ( ! opt$mode %in% MSDB.MODE.VALS))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
328 stop("You must specify a mode through the --mode option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
329
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
330 if (is.null(opt$mzprec))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
331 stop("You must set a precision in MZ with the --mzprec option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
332
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
333 if ( ( ! is.null(opt$rtcol) || ! is.null(opt[['all-cols']])) && (is.null(opt$rttolx) || is.null(opt$rttoly)))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
334 stop("When chromatographic columns are set, you must provide values for --rttolx and -rttoly.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
335
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
336 if (is.null(opt$mztolunit) || ( ! opt$mztolunit %in% MSDB.MZTOLUNIT.VALS))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
337 stop("You must specify an M/Z tolerance unit through the --mztolunit option.")
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
338 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
339 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
340
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
341 # Load database {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
342 ################################################################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
343
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
344 .load.db <- function(opt) {
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
345
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
346 if (is.null(opt[['pos-prec']]) && is.null(opt[['neg-prec']])) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
347 precursors <- NULL
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
348 } else {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
349 precursors <- list()
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
350 precursors[[MSDB.TAG.POS]] <- opt[['pos-prec']]
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
351 precursors[[MSDB.TAG.NEG]] <- opt[['neg-prec']]
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
352 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
353
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
354 db <- switch(opt$database,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
355 peakforest = MsPeakForestDb$new(url = opt$url, useragent = USERAGENT, token = opt[['db-token']]),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
356 xls = MsXlsDb$new(db_dir = opt$url, cache_dir = opt[['cache-dir']]),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
357 '4tabsql' = Ms4TabSqlDb$new(host = extract.address(opt$url), port = extract.port(opt$url), dbname = opt[['db-name']], user = opt[['db-user']], password = opt[['db-password']]),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
358 file = MsFileDb$new(file = opt$url),
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
359 NULL)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
360 db$setPrecursors(precursors)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
361 if (db$areDbFieldsSettable())
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
362 db$setDbFields(opt[['db-fields']])
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
363 if (db$areDbMsModesSettable())
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
364 db$setDbMsModes(opt[['db-ms-modes']])
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
365 db$addObservers(MsDbLogger$new())
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
366
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
367 return(db)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
368 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
369
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
370 # Output HTML {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
371 ################################################################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
372
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
373 output.html <- function(db, peaks, file) {
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
374
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
375 # Replace public database IDs by URLs
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
376 if ( ! is.null(peaks)) {
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
377 # Conversion from extdb id field to extdb name
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
378 extdb2classdb = list()
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
379 extdb2classdb[MSDB.TAG.KEGG] = BIODB.KEGG
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
380 extdb2classdb[MSDB.TAG.HMDB] = BIODB.HMDB
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
381 extdb2classdb[MSDB.TAG.CHEBI] = BIODB.CHEBI
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
382 extdb2classdb[MSDB.TAG.PUBCHEM] = BIODB.PUBCHEMCOMP
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
383
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
384 # Loop on all dbs
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
385 for (extdb in c(MSDB.TAG.KEGG, MSDB.TAG.HMDB, MSDB.TAG.CHEBI, MSDB.TAG.PUBCHEM)) {
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
386 if ( ! is.null(peaks) && extdb %in% colnames(peaks))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
387 peaks[[extdb]] <- vapply(peaks[[extdb]], function(id) if (is.na(id)) '' else paste0('<a href="', get.entry.url(class = extdb2classdb[[extdb]], accession = id, content.type = BIODB.HTML), '">', id, '</a>'), FUN.VALUE = '')
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
388 }
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
389 }
0
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 # Write HTML
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
392 html <- HtmlWriter(file = file)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
393 html$writeBegTag('html')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
394 html$writeBegTag('header')
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
395 html$writeTag('meta', attr = c(charset = "UTF-8"))
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
396 html$writeTag('title', text = "LC/MS matching results")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
397 html$writeBegTag('style')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
398 html$write('table, th, td { border-collapse: collapse; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
399 html$write('table, th { border: 1px solid black; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
400 html$write('td { border-left: 1px solid black; border-right: 1px solid black; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
401 html$write('th, td { padding: 5px; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
402 html$write('th { background-color: LightBlue; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
403 html$write('tr:nth-child(even) { background-color: LemonChiffon; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
404 html$write('tr:nth-child(odd) { background-color: LightGreen; }')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
405 html$writeEndTag('style')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
406 html$writeEndTag('header')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
407 html$writeBegTag('body')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
408
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
409 # Write results
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
410 results <- FALSE
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
411 if ( ! is.null(peaks) && nrow(peaks) > 0) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
412 html$writeTag('h3', text = "Matched peaks")
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
413 html$writeTable(peaks)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
414 results <- TRUE
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
415 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
416 if ( ! results)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
417 html$writeTag('p', 'None.')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
418
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
419 html$writeEndTag('body')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
420 html$writeEndTag('html')
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
421 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
422
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
423 # MAIN {{{1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
424 ################################################################
0
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 # Read command line arguments
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
427 opt <- read_args()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
428
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
429 if (is.null(opt$debug)) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
430 options(error = function() { quit(status = 1) }, warn = 0 )
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
431 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
432
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
433 # Load database
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
434 source(file.path(dirname(script.path), DB.SRC.FILE[[opt$database]]), chdir = TRUE)
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
435 db <- .load.db(opt)
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 # Print columns
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
438 if ( ! is.null(opt[['list-cols']])) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
439 cols <- db$getChromCol()
1
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
440 df.write.tsv(cols, file = if (is.null(opt[['output-file']])) stdout() else opt[['output-file']])
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
441 q(status = 0)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
442 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
443
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
444 # Read input
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
445 if ( ! is.null(opt[['input-file']]) && ! file.exists(opt[['input-file']]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
446 stop(paste0("Input file \"", opt[['input-file']], "\" does not exist."))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
447 if (file.info(opt[['input-file']])$size > 0) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
448
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
449 # Load file into data frame
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
450 input <- read.table(file = opt[['input-file']], header = TRUE, sep = "\t", stringsAsFactor = FALSE, check.names = FALSE, comment.char = '')
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
451
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
452 # Convert each column that is identified by a number into a name
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
453 for (field in names(opt[['input-col-names']])) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
454 if ( ! opt[['input-col-names']][[field]] %in% colnames(input) && length(grep('^[0-9]+$', opt[['input-col-names']][[field]])) > 0) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
455 col.index <- as.integer(opt[['input-col-names']][[field]])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
456 if (col.index < 1 || col.index > length(colnames(input)))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
457 stop(paste0("No column n°", col.index, " for input field ", field, "."))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
458 opt[['input-col-names']][[field]] <- colnames(input)[[col.index]]
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 } else {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
462 input <- data.frame()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
463 input[[opt[['input-col-names']][['mz']]]] <- double()
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
464 input[[opt[['input-col-names']][['rt']]]] <- double()
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 # Check mz column
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
468 if ( ! opt[['input-col-names']][['mz']] %in% colnames(input))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
469 stop(paste0('No column named "', opt[['input-col-names']][['mz']], '" in input file.'))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
470
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
471 # Set columns 'all-cols' specified
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
472 if ( ! is.null(opt[['all-cols']]))
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
473 opt$rtcol <- db$getChromCol()[['id']]
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
474
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
475 # Check chrom columns
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
476 if ( ! is.null(opt[['check-cols']]) && ! is.null(opt$rtcol)) {
1
253d531a0193 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
prog
parents: 0
diff changeset
477 dbcols <- db$getChromCol()[['id']]
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
478 unknown.cols <- opt$rtcol[ ! opt$rtcol %in% dbcols]
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
479 if (length(unknown.cols) > 0) {
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
480 stop(paste0("Unknown chromatographic column", (if (length(unknown.cols) > 1) 's' else ''), ': ', paste(unknown.cols, collapse = ', '), ".\nAllowed chromatographic column names are:\n", paste(dbcols, collapse = "\n")))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
481 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
482 }
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
483
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
484 # Check that an RT column exists when using MZ/RT matching
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
485 if ( ! is.null(opt$rtcol) && ! opt[['input-col-names']][['rt']] %in% colnames(input))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
486 stop(paste0("You are running an MZ/RT match run on your input data, but no retention time column named '", opt[['input-col-names']][['rt']],"' can be found inside your input file."))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
487
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
488 # Set output col names
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
489 output.col.names <- opt[['input-col-names']]
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
490
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
491 # Set streams
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
492 input.stream <- MsDbInputDataFrameStream$new(df = input, input.fields = opt[['input-col-names']], rtunit = opt[['rtunit']])
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
493 main.output <- MsDbOutputDataFrameStream$new(keep.unused = ! is.null(opt[['same-cols']]), output.fields = output.col.names, one.line = ! is.null(opt[['same-rows']]), match.sep = opt[['molids-sep']], first.val = ! is.null(opt[['first-val']]), ascii = ! is.null(opt[['excel2011comp']]), nogreek = ! is.null(opt[['excel2011comp']]), noapostrophe = ! is.null(opt[['excel2011comp']]), noplusminus = ! is.null(opt[['excel2011comp']]), rtunit = opt[['rtunit']])
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
494 peaks.output <- MsDbOutputDataFrameStream$new(keep.unused = ! is.null(opt[['same-cols']]), output.fields = output.col.names, first.val = ! is.null(opt[['first-val']]), ascii = ! is.null(opt[['excel2011comp']]), nogreek = ! is.null(opt[['excel2011comp']]), noapostrophe = ! is.null(opt[['excel2011comp']]), noplusminus = ! is.null(opt[['excel2011comp']]), rtunit = opt[['rtunit']])
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
495 invisible(db$setInputStream(input.stream))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
496 db$addOutputStreams(c(main.output, peaks.output))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
497
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
498 # Set database units
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
499 db$setMzTolUnit(opt$mztolunit)
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
500 if ( ! is.null(opt[['db-rt-unit']]) && opt$database == 'file')
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
501 db$setRtUnit(opt[['db-rt-unit']])
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
502
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
503 # Search database
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
504 mode <- if (opt$mode == POS_MODE) MSDB.TAG.POS else MSDB.TAG.NEG
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
505 db$searchForMzRtList(mode = mode, shift = opt$mzshift, prec = opt$mzprec, rt.tol = opt$rttol, rt.tol.x = opt$rttolx, rt.tol.y = opt$rttoly, col = opt$rtcol, precursor.match = ! is.null(opt[['precursor-match']]), precursor.rt.tol = opt[['precursor-rt-tol']])
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
506
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
507 # Write output
2
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
508 main.output$moveColumnsToBeginning(colnames(input))
20d69a062da3 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit d4048accde6bdfd5b3e14f5394902d38991854f8
prog
parents: 1
diff changeset
509 peaks.output$moveColumnsToBeginning(colnames(input))
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
510 # TODO Create a class MsDbOutputCsvFileStream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
511 df.write.tsv(main.output$getDataFrame(), file = opt[['output-file']], row.names = FALSE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
512 if ( ! is.null(opt[['peak-output-file']]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
513 # TODO Create a class MsDbOutputCsvFileStream
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
514 df.write.tsv(peaks.output$getDataFrame(), file = opt[['peak-output-file']], row.names = FALSE)
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
515 if ( ! is.null(opt[['html-output-file']]))
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
516 # TODO Create a class MsDbOutputHtmlFileStream
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
517 output.html(db = db, peaks = peaks.output$getDataFrame(), file = opt[['html-output-file']])