view combineAnnotations.R @ 6:530dc7c80add draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 781bf118b12bf8f32e540932f4aaa3170f88b2ce
author tomnl
date Tue, 18 Jun 2019 14:51:42 -0400
parents 7a3f8bd7757d
children d2b3e81e8f70
line wrap: on
line source

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="."),
  make_option("--eic", action="store_true")
)
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)


closeAllConnections()