comparison createMSP.R @ 0:ca0ac330f1a4 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
author tomnl
date Fri, 24 May 2019 09:13:42 -0400
parents
children 2c8b5a640a04
comparison
equal deleted inserted replaced
-1:000000000000 0:ca0ac330f1a4
1 library(optparse)
2 library(msPurity)
3 print(sessionInfo())
4
5 # Get the parameter
6 option_list <- list(
7 make_option(c("-i","--rdata_input"),type="character"),
8 make_option(c("-m","--method"),type="character"),
9 make_option(c("-meta","--metadata"),type="character"),
10 make_option(c("-metac","--metadata_cols"),type="character"),
11 make_option(c("-a","--adduct_split"),type="character"),
12 make_option(c("-x","--xcms_groupids"),type="character"),
13 make_option(c("-f","--filter"),action="store_true"),
14 make_option("--intensity_ra",type="character"),
15 make_option("--msp_schema",type="character"),
16 make_option(c("-o","--out_dir"),type="character", default=".")
17 )
18 opt <- parse_args(OptionParser(option_list=option_list))
19
20 print(opt)
21
22 load(opt$rdata_input)
23
24 if (is.null(opt$metadata)){
25 metadata <- NULL
26 }else{
27 metadata <- read.table(opt$metadata, header = TRUE, sep='\t', stringsAsFactors = FALSE, check.names = FALSE)
28 print(head(metadata))
29 }
30
31 if(is.null(opt$adduct_split)){
32 adduct_split <- FALSE
33 }else{
34 adduct_split <- TRUE
35 }
36
37 if (is.null(opt$xcms_groupids)){
38 xcms_groupids <- NULL
39 }else{
40 xcms_groupids <- trimws(strsplit(opt$xcms_groupids, ',')[[1]])
41 }
42
43 if(is.null(opt$filter)){
44 filter <- FALSE
45 }else{
46 filter <- TRUE
47 }
48
49 msPurity::createMSP(pa,
50 msp_file_pth = file.path(opt$out_dir, 'lcmsms_spectra.msp'),
51 metadata = metadata,
52 metadata_cols = opt$metadata_cols,
53 method = opt$method,
54 adduct_split = adduct_split,
55 xcms_groupids = xcms_groupids,
56 filter = filter,
57 intensity_ra=opt$intensity_ra,
58 msp_schema=opt$msp_schema)
59
60 print('msp created')