diff combineAnnotations.R @ 0:df2efceff4cd draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 2948ce35fa7fffe5a64711cb30be971031e79019-dirty
author tomnl
date Fri, 24 May 2019 09:06:56 -0400
parents
children 13985cdcf0ba
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combineAnnotations.R	Fri May 24 09:06:56 2019 -0400
@@ -0,0 +1,47 @@
+library(optparse)
+library(msPurity)
+print(sessionInfo())
+
+# Get the parameter
+option_list <- list(
+  make_option(c("-s","--sm_resultPth"),type="character"),
+  make_option(c("-m","--metfrag_resultPth"),type="character"),
+  make_option(c("-c","--sirius_csi_resultPth"),type="character"),
+  make_option(c("-p","--probmetab_resultPth"),type="character"),
+  make_option(c("-sw","--sm_weight"),type="numeric"),
+  make_option(c("-mw","--metfrag_weight"),type="numeric"),
+  make_option(c("-cw","--sirius_csi_weight"),type="numeric"),
+  make_option(c("-pw","--probmetab_weight"),type="numeric"),
+  make_option("--create_new_database", action="store_true"),
+  make_option(c("-o","--outdir"),type="character", default=".")
+)
+opt <- parse_args(OptionParser(option_list=option_list))
+
+print(opt)
+
+if (!is.null(opt$create_new_database)){
+  sm_resultPth <-  file.path(opt$outdir, 'combined_annotations.sqlite')
+  file.copy(opt$sm_resultPth, sm_resultPth)
+}else{
+  sm_resultPth <- opt$sm_resultPth
+}
+
+
+weights <-list('sm'=opt$sm_weight,
+               'metfrag'=opt$metfrag_weight,
+               'sirius_csifingerid'= opt$sirius_csi_weight,
+               'probmetab'=opt$probmetab_weight
+               )
+
+if (round(!sum(unlist(weights),0)==1)){
+
+  stop(paste0('The weights should sum to 1 not ', sum(unlist(weights))))
+}
+
+summary_output <- msPurity::combineAnnotations(sm_resultPth,
+                             opt$metfrag_resultPth,
+                             opt$sirius_csi_resultPth,
+                             opt$probmetab_resultPth,
+                             weights = weights)
+
+write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE)