diff combineAnnotations.R @ 8:b91b9492a4bf draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 7e1748612a9f9dce11a9e54ff36752b600e7aea3
author computational-metabolomics
date Wed, 12 Jun 2024 16:04:05 +0000
parents d25273689e04
children
line wrap: on
line diff
--- a/combineAnnotations.R	Tue Feb 08 13:56:27 2022 +0000
+++ b/combineAnnotations.R	Wed Jun 12 16:04:05 2024 +0000
@@ -9,23 +9,18 @@
   make_option(c("-c", "--sirius_csi_resultPth"), type = "character"),
   make_option(c("-p", "--probmetab_resultPth"), type = "character"),
   make_option(c("-l", "--ms1_lookup_resultPth"), type = "character"),
-
   make_option("--ms1_lookup_checkAdducts", action = "store_true"),
   make_option("--ms1_lookup_keepAdducts", type = "character", default = NA),
   make_option("--ms1_lookup_dbSource", type = "character", default = "hmdb"),
-
   make_option("--sm_weight", type = "numeric"),
   make_option("--metfrag_weight", type = "numeric"),
   make_option("--sirius_csi_weight", type = "numeric"),
   make_option("--probmetab_weight", type = "numeric"),
   make_option("--ms1_lookup_weight", type = "numeric"),
   make_option("--biosim_weight", type = "numeric"),
-
   make_option("--summaryOutput", action = "store_true"),
-
   make_option("--create_new_database", action = "store_true"),
   make_option("--outdir", type = "character", default = "."),
-
   make_option("--compoundDbType", type = "character", default = "sqlite"),
   make_option("--compoundDbPth", type = "character", default = NA),
   make_option("--compoundDbHost", type = "character", default = NA)
@@ -37,7 +32,7 @@
 if (!is.null(opt$create_new_database)) {
   sm_resultPth <- file.path(opt$outdir, "combined_annotations.sqlite")
   file.copy(opt$sm_resultPth, sm_resultPth)
-}else{
+} else {
   sm_resultPth <- opt$sm_resultPth
 }
 
@@ -45,18 +40,19 @@
   opt$ms1_lookup_checkAdducts <- FALSE
 }
 if (!is.null(opt$ms1_lookup_keepAdducts)) {
-    opt$ms1_lookup_keepAdducts <- gsub("__ob__", "[", opt$ms1_lookup_keepAdducts)
-    opt$ms1_lookup_keepAdducts <- gsub("__cb__", "]", opt$ms1_lookup_keepAdducts)
-    ms1_lookup_keepAdducts <- strsplit(opt$ms1_lookup_keepAdducts, ",")[[1]]
+  opt$ms1_lookup_keepAdducts <- gsub("__ob__", "[", opt$ms1_lookup_keepAdducts)
+  opt$ms1_lookup_keepAdducts <- gsub("__cb__", "]", opt$ms1_lookup_keepAdducts)
+  ms1_lookup_keepAdducts <- strsplit(opt$ms1_lookup_keepAdducts, ",")[[1]]
 }
 
-weights <- list("sm" = opt$sm_weight,
-               "metfrag" = opt$metfrag_weight,
-               "sirius_csifingerid" = opt$sirius_csi_weight,
-               "probmetab" = opt$probmetab_weight,
-               "ms1_lookup" = opt$ms1_lookup_weight,
-               "biosim" = opt$biosim_weight
-               )
+weights <- list(
+  "sm" = opt$sm_weight,
+  "metfrag" = opt$metfrag_weight,
+  "sirius_csifingerid" = opt$sirius_csi_weight,
+  "probmetab" = opt$probmetab_weight,
+  "ms1_lookup" = opt$ms1_lookup_weight,
+  "biosim" = opt$biosim_weight
+)
 print(weights)
 
 if (is.null(opt$probmetab_resultPth)) {
@@ -69,8 +65,8 @@
 
 if (is.null(opt$summaryOutput)) {
   summaryOutput <- FALSE
-}else{
- summaryOutput <- TRUE
+} else {
+  summaryOutput <- TRUE
 }
 
 if (opt$compoundDbType == "local_config") {
@@ -82,7 +78,7 @@
     source(paste(base_dir, fname, sep = "/"))
   }
   source_local("dbconfig.R")
-}else{
+} else {
   compoundDbPth <- opt$compoundDbPth
   compoundDbType <- opt$compoundDbType
   compoundDbName <- NA
@@ -93,31 +89,33 @@
 }
 
 summary_output <- msPurity::combineAnnotations(
-                          sm_resultPth = sm_resultPth,
-                          compoundDbPth = compoundDbPth,
-                          metfrag_resultPth = opt$metfrag_resultPth,
-                          sirius_csi_resultPth = opt$sirius_csi_resultPth,
-                          probmetab_resultPth = opt$probmetab_resultPth,
-                          ms1_lookup_resultPth = opt$ms1_lookup_resultPth,
-                          ms1_lookup_keepAdducts = ms1_lookup_keepAdducts,
-                          ms1_lookup_checkAdducts = opt$ms1_lookup_checkAdducts,
-
-                         compoundDbType = compoundDbType,
-                         compoundDbName = compoundDbName,
-                         compoundDbHost = compoundDbHost,
-                         compoundDbPort = compoundDbPort,
-                         compoundDbUser = compoundDbUser,
-                         compoundDbPass = compoundDbPass,
-                         weights = weights,
-                         summaryOutput = summaryOutput)
+  sm_resultPth = sm_resultPth,
+  compoundDbPth = compoundDbPth,
+  metfrag_resultPth = opt$metfrag_resultPth,
+  sirius_csi_resultPth = opt$sirius_csi_resultPth,
+  probmetab_resultPth = opt$probmetab_resultPth,
+  ms1_lookup_resultPth = opt$ms1_lookup_resultPth,
+  ms1_lookup_keepAdducts = ms1_lookup_keepAdducts,
+  ms1_lookup_checkAdducts = opt$ms1_lookup_checkAdducts,
+  compoundDbType = compoundDbType,
+  compoundDbName = compoundDbName,
+  compoundDbHost = compoundDbHost,
+  compoundDbPort = compoundDbPort,
+  compoundDbUser = compoundDbUser,
+  compoundDbPass = compoundDbPass,
+  weights = weights,
+  summaryOutput = summaryOutput
+)
 if (summaryOutput) {
   write.table(summary_output,
-              file.path(opt$outdir, "combined_annotations.tsv"),
-              sep = "\t", row.names = FALSE)
+    file.path(opt$outdir, "combined_annotations.tsv"),
+    sep = "\t", row.names = FALSE
+  )
 }
 
 write.table(summary_output,
-            file.path(opt$outdir, "combined_annotations.tsv"),
-            sep = "\t", row.names = FALSE)
+  file.path(opt$outdir, "combined_annotations.tsv"),
+  sep = "\t", row.names = FALSE
+)
 
 closeAllConnections()