comparison createMSP.R @ 8:94a2b6571758 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
author computational-metabolomics
date Wed, 12 Jun 2024 16:06:42 +0000
parents 18c0038dde9c
children
comparison
equal deleted inserted replaced
7:d7104112fac6 8:94a2b6571758
24 24
25 load(opt$rdata_input) 25 load(opt$rdata_input)
26 26
27 if (is.null(opt$metadata)) { 27 if (is.null(opt$metadata)) {
28 metadata <- NULL 28 metadata <- NULL
29 }else{ 29 } else {
30 metadata <- read.table(opt$metadata, header = TRUE, sep = "\t", 30 metadata <- read.table(opt$metadata,
31 stringsAsFactors = FALSE, check.names = FALSE) 31 header = TRUE, sep = "\t",
32 stringsAsFactors = FALSE, check.names = FALSE
33 )
32 34
33 if (!opt$metadata_cols_filter == "") { 35 if (!opt$metadata_cols_filter == "") {
34 metadata_cols_filter <- strsplit(opt$metadata_cols_filter, ",")[[1]] 36 metadata_cols_filter <- strsplit(opt$metadata_cols_filter, ",")[[1]]
35 37
36 metadata <- metadata[, metadata_cols_filter, drop = FALSE] 38 metadata <- metadata[, metadata_cols_filter, drop = FALSE]
37 print(metadata) 39 print(metadata)
38 40
39 if (!"grpid" %in% colnames(metadata)) { 41 if (!"grpid" %in% colnames(metadata)) {
40 metadata$grpid <- seq_len(nrow(metadata)) 42 metadata$grpid <- seq_len(nrow(metadata))
41 } 43 }
42 44
43 print(metadata) 45 print(metadata)
44
45 } 46 }
46
47 } 47 }
48 48
49 49
50 50
51 if (is.null(opt$metadata_cols) || opt$metadata_cols == "") { 51 if (is.null(opt$metadata_cols) || opt$metadata_cols == "") {
52 metadata_cols <- NULL 52 metadata_cols <- NULL
53 }else{ 53 } else {
54 metadata_cols <- opt$metadata_cols 54 metadata_cols <- opt$metadata_cols
55
56 } 55 }
57 56
58 57
59 if (is.null(opt$adduct_split)) { 58 if (is.null(opt$adduct_split)) {
60 adduct_split <- FALSE 59 adduct_split <- FALSE
61 }else{ 60 } else {
62 adduct_split <- TRUE 61 adduct_split <- TRUE
63 } 62 }
64 63
65 if (is.null(opt$xcms_groupids)) { 64 if (is.null(opt$xcms_groupids)) {
66 xcms_groupids <- NULL 65 xcms_groupids <- NULL
67 }else{ 66 } else {
68 xcms_groupids <- trimws(strsplit(opt$xcms_groupids, ",")[[1]]) 67 xcms_groupids <- trimws(strsplit(opt$xcms_groupids, ",")[[1]])
69 } 68 }
70 69
71 70
72 if (is.null(opt$include_adducts_custom)) { 71 if (is.null(opt$include_adducts_custom)) {
73 include_adducts_custom <- "" 72 include_adducts_custom <- ""
74 }else{ 73 } else {
75 include_adducts_custom <- opt$include_adducts_custom 74 include_adducts_custom <- opt$include_adducts_custom
76 } 75 }
77 76
78 77
79 if (opt$include_adducts == "None") { 78 if (opt$include_adducts == "None") {
80 include_adducts <- "" 79 include_adducts <- ""
81 }else{ 80 } else {
82 include_adducts <- opt$include_adducts 81 include_adducts <- opt$include_adducts
83 } 82 }
84 83
85 include_adducts_all <- paste(include_adducts_custom, ",", include_adducts, sep = "") 84 include_adducts_all <- paste(include_adducts_custom, ",", include_adducts, sep = "")
86 85
94 93
95 94
96 95
97 if (is.null(opt$filter)) { 96 if (is.null(opt$filter)) {
98 filter <- FALSE 97 filter <- FALSE
99 }else{ 98 } else {
100 filter <- TRUE 99 filter <- TRUE
101 } 100 }
102 101
103 102
104 103
105 msPurity::createMSP(pa, 104 msPurity::createMSP(pa,
106 msp_file_pth = file.path(opt$out_dir, "lcmsms_spectra.msp"), 105 msp_file_pth = file.path(opt$out_dir, "lcmsms_spectra.msp"),
107 metadata = metadata, 106 metadata = metadata,
108 metadata_cols = metadata_cols, 107 metadata_cols = metadata_cols,
109 method = opt$method, 108 method = opt$method,
110 adduct_split = adduct_split, 109 adduct_split = adduct_split,
111 xcms_groupids = xcms_groupids, 110 xcms_groupids = xcms_groupids,
112 filter = filter, 111 filter = filter,
113 intensity_ra = opt$intensity_ra, 112 intensity_ra = opt$intensity_ra,
114 include_adducts = include_adducts_all, 113 include_adducts = include_adducts_all,
115 msp_schema = opt$msp_schema) 114 msp_schema = opt$msp_schema
115 )
116 116
117 print("msp created") 117 print("msp created")