comparison combineAnnotations.R @ 2:379b5c1dbe19 draft

"planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 242de155f13acd6cb88946e89b5196ac55578aa8"
author computational-metabolomics
date Wed, 01 Apr 2020 11:15:01 -0400
parents e96082a25ff0
children 090775983be7
comparison
equal deleted inserted replaced
1:3959cddb01a6 2:379b5c1dbe19
18 make_option("--metfrag_weight", type="numeric"), 18 make_option("--metfrag_weight", type="numeric"),
19 make_option("--sirius_csi_weight", type="numeric"), 19 make_option("--sirius_csi_weight", type="numeric"),
20 make_option("--probmetab_weight", type="numeric"), 20 make_option("--probmetab_weight", type="numeric"),
21 make_option("--ms1_lookup_weight", type="numeric"), 21 make_option("--ms1_lookup_weight", type="numeric"),
22 make_option("--biosim_weight", type="numeric"), 22 make_option("--biosim_weight", type="numeric"),
23 23
24 make_option("--summaryOutput", action="store_true"),
25
24 make_option("--create_new_database", action="store_true"), 26 make_option("--create_new_database", action="store_true"),
25 make_option("--outdir", type="character", default="."), 27 make_option("--outdir", type="character", default="."),
26 28
27 make_option("--compoundDbType", type="character", default="sqlite"), 29 make_option("--compoundDbType", type="character", default="sqlite"),
28 make_option("--compoundDbPth", type="character", default=NA), 30 make_option("--compoundDbPth", type="character", default=NA),
54 'probmetab'=opt$probmetab_weight, 56 'probmetab'=opt$probmetab_weight,
55 'ms1_lookup'=opt$ms1_lookup_weight, 57 'ms1_lookup'=opt$ms1_lookup_weight,
56 'biosim'=opt$biosim_weight 58 'biosim'=opt$biosim_weight
57 ) 59 )
58 print(weights) 60 print(weights)
61
62 if (is.null(opt$probmetab_resultPth)){
63 opt$probmetab_resultPth = NA
64 }
65
59 if (round(!sum(unlist(weights),0)==1)){ 66 if (round(!sum(unlist(weights),0)==1)){
67 stop(paste0('The weights should sum to 1 not ', sum(unlist(weights))))
68 }
60 69
61 stop(paste0('The weights should sum to 1 not ', sum(unlist(weights)))) 70 if (is.null(opt$summaryOutput)){
71 summaryOutput = FALSE
72 }else{
73 summaryOutput = TRUE
62 } 74 }
63 75
64 if (opt$compoundDbType=='local_config'){ 76 if (opt$compoundDbType=='local_config'){
65 # load in compound config 77 # load in compound config
66 # Soure local function taken from workflow4metabolomics 78 # Soure local function taken from workflow4metabolomics
74 compoundDbPort = NA 86 compoundDbPort = NA
75 compoundDbUser = NA 87 compoundDbUser = NA
76 compoundDbPass = NA 88 compoundDbPass = NA
77 } 89 }
78 90
79
80
81 summary_output <- msPurity::combineAnnotations( 91 summary_output <- msPurity::combineAnnotations(
82 sm_resultPth = sm_resultPth, 92 sm_resultPth = sm_resultPth,
83 compoundDbPth = compoundDbPth, 93 compoundDbPth = compoundDbPth,
84 metfrag_resultPth = opt$metfrag_resultPth, 94 metfrag_resultPth = opt$metfrag_resultPth,
85 sirius_csi_resultPth = opt$sirius_csi_resultPth, 95 sirius_csi_resultPth = opt$sirius_csi_resultPth,
92 compoundDbName = compoundDbName, 102 compoundDbName = compoundDbName,
93 compoundDbHost = compoundDbHost, 103 compoundDbHost = compoundDbHost,
94 compoundDbPort = compoundDbPort, 104 compoundDbPort = compoundDbPort,
95 compoundDbUser = compoundDbUser, 105 compoundDbUser = compoundDbUser,
96 compoundDbPass = compoundDbPass, 106 compoundDbPass = compoundDbPass,
97 weights = weights) 107 weights = weights,
108 summaryOutput = summaryOutput)
109 if (summaryOutput){
110 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE)
111 }
112
98 113
99 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE) 114 write.table(summary_output, file.path(opt$outdir, 'combined_annotations.tsv'), sep = '\t', row.names = FALSE)
100 115
101 116
102 closeAllConnections() 117 closeAllConnections()