# HG changeset patch # User tomnl # Date 1525708974 14400 # Node ID cea46ee6596debbb87f435c02f5f95f2f04488cb # Parent b262a6306ffeabf7ceccf19d59e03c6acb4c3903 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 4116082655a03d3007a49e4a4b00fc6ad4698412-dirty diff -r b262a6306ffe -r cea46ee6596d create_sqlite_db.R --- a/create_sqlite_db.R Thu May 03 07:27:48 2018 -0400 +++ b/create_sqlite_db.R Mon May 07 12:02:54 2018 -0400 @@ -57,9 +57,12 @@ make_option("--galaxy_names", type="character"), make_option("--grp_peaklist", type="character"), make_option("--db_name", type="character", default='lcms_data.sqlite'), - make_option("--raw_rt_columns", action="store_true") + make_option("--raw_rt_columns", action="store_true"), + make_option("--metfrag_result", type="character"), + make_option("--sirius_csifingerid_result", type="character") ) + # store options opt<- parse_args(OptionParser(option_list=option_list)) @@ -75,7 +78,7 @@ # Requires pa <- loadRData(opt$pa, 'pa') -print('TESTETSTESTETE') + print(pa@fileList) @@ -126,9 +129,37 @@ rtrawColumns = rtrawColumns) } +con <- DBI::dbConnect(RSQLite::SQLite(), db_pth) + +add_extra_table <- function(name, pth){ + + print('CHECK1') + print(name) + print(pth) + if (!is.null(pth)){ + print('CHECK2') + print(pth) + df <- read.table(pth, header = TRUE, sep='\t', stringsAsFactors = FALSE, comment.char = "") + # bug for repeating headers + df <- df[!df$UID=='UID',] + + # get peakid, an scan id + df_ids <- stringr::str_split_fixed(df$UID, '-', 3) + colnames(df_ids) <- c('grp_id', 'file_id', 'peak_id') + df <- cbind(df_ids, df) + # export to database + + + DBI::dbWriteTable(con, name=name, value=df, row.names=FALSE) + + } + +} + +add_extra_table('metfrag_results', opt$metfrag_result) +add_extra_table('sirius_csifingerid_results', opt$sirius_csifingerid_result) -con <- DBI::dbConnect(RSQLite::SQLite(), db_pth) cmd <- paste('SELECT cpg.grpid, cpg.mz, cpg.mzmin, cpg.mzmax, cpg.rt, cpg.rtmin, cpg.rtmax, c_peaks.cid, ', 'c_peaks.mzmin AS c_peak_mzmin, c_peaks.mzmax AS c_peak_mzmax, ',