diff combineAnnotations.R @ 2:d7c5fa406ea8 draft

"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 242de155f13acd6cb88946e89b5196ac55578aa8"
author computational-metabolomics
date Wed, 01 Apr 2020 11:02:37 -0400
parents a141be614e76
children 6b9a83e08467
line wrap: on
line diff
--- a/combineAnnotations.R	Thu Dec 05 07:36:31 2019 -0500
+++ b/combineAnnotations.R	Wed Apr 01 11:02:37 2020 -0400
@@ -20,7 +20,9 @@
   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="."),
 
@@ -56,11 +58,21 @@
                'biosim'=opt$biosim_weight
                )
 print(weights)
-if (round(!sum(unlist(weights),0)==1)){
+
+if (is.null(opt$probmetab_resultPth)){
+  opt$probmetab_resultPth = NA
+}
 
+if (round(!sum(unlist(weights),0)==1)){
   stop(paste0('The weights should sum to 1 not ', sum(unlist(weights))))
 }
 
+if (is.null(opt$summaryOutput)){
+  summaryOutput = FALSE
+}else{
+ summaryOutput = TRUE
+}
+
 if (opt$compoundDbType=='local_config'){
   # load in compound config
   # Soure local function taken from workflow4metabolomics
@@ -76,8 +88,6 @@
   compoundDbPass = NA
 }
 
-
-
 summary_output <- msPurity::combineAnnotations(
                             sm_resultPth = sm_resultPth,
                             compoundDbPth = compoundDbPth,
@@ -94,7 +104,12 @@
                             compoundDbPort = compoundDbPort,
                             compoundDbUser = compoundDbUser,
                             compoundDbPass = compoundDbPass,
-                            weights = weights)
+                            weights = weights,
+                            summaryOutput = summaryOutput)
+if (summaryOutput){
+  write.table(summary_output, 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)