# HG changeset patch # User tomnl # Date 1561457106 14400 # Node ID e6a78f89ee0709e354b3311506cc44ecb5ca03e0 # Parent 736f8fd48db2a940f9b63df201fffdd5d6fd4406 planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 74e7bfbb5e70ec6e665114fa9e9863dafd7bced5 diff -r 736f8fd48db2 -r e6a78f89ee07 createDatabase.R --- a/createDatabase.R Wed Jun 19 09:22:35 2019 -0400 +++ b/createDatabase.R Tue Jun 25 06:05:06 2019 -0400 @@ -5,8 +5,6 @@ print(sessionInfo()) print('CREATING DATABASE') - - xset_pa_filename_fix <- function(opt, pa, xset){ if (!is.null(opt$mzML_files) && !is.null(opt$galaxy_names)){ @@ -156,11 +154,15 @@ } xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset)) - closeAllConnections() + # Saves the EICS into the previously created database - px <- msPurity::purityX(xset, saveEIC = TRUE, - cores=1, sqlitePth=dbPth, - rtrawColumns = TRUE) + xgroups <- as.numeric(as.character(unique(pa@grped_df$grpid))) + px <- msPurity::purityX(xset, + saveEIC = TRUE, + cores=1, + sqlitePth=dbPth, + rtrawColumns = TRUE, + xgroups = xgroups) } diff -r 736f8fd48db2 -r e6a78f89ee07 spectralMatching.R --- a/spectralMatching.R Wed Jun 19 09:22:35 2019 -0400 +++ b/spectralMatching.R Tue Jun 25 06:05:06 2019 -0400 @@ -243,3 +243,48 @@ write.table(sm$matchedResults, 'matched_results.tsv', sep = '\t', row.names = FALSE, col.names = TRUE) write.table(sm$xcmsMatchedResults, 'xcms_matched_results.tsv', sep = '\t', row.names = FALSE, col.names = TRUE) + + +# Add extra details from library spectra in resulting database +# First get all the ids from the l_s_peak_meta from the query database +if(updateDb){ + message('Adding extra details to database') + q_con <- DBI::dbConnect(RSQLite::SQLite(),sm$q_dbPth) + if (DBI::dbExistsTable(q_con, "l_s_peak_meta")){ + l_s_peak_meta <- DBI::dbGetQuery(q_con, 'SELECT * FROM l_s_peak_meta') + colnames(l_s_peak_meta)[1] <- 'pid' + } + + l_con <- DBI::dbConnect(RSQLite::SQLite(),l_dbPth) + if (DBI::dbExistsTable(q_con, "s_peaks")){ + l_s_peaks <- DBI::dbGetQuery(q_con, sprintf("SELECT * FROM s_peaks WHERE pid in (%s)", paste(unique(l_s_peak_meta$pid), collapse=','))) + + }else if(DBI::dbExistsTable(q_con, "library_spectra")){ + l_s_peaks <- DBI::dbGetQuery(q_con, sprintf("SELECT * FROM library_spectra + WHERE library_spectra_meta_id in (%s)", paste(unique(l_s_peak_meta$pid), collapse=','))) + }else{ + l_s_peaks = NULL + } + + if (DBI::dbExistsTable(q_con, "source")){ + l_source <- DBI::dbGetQuery(q_con, 'SELECT * FROM source') + }else if (DBI::dbExistsTable(q_con, "library_spectra_source")) { + l_source <- DBI::dbGetQuery(q_con, 'library_spectra_source') + }else{ + l_source = NULL + } + + if (!is.null(l_s_peaks)){ + DBI::dbWriteTable(q_con, name='l_s_peaks', value=l_s_peaks, row.names=FALSE, append=TRUE) + } + + if (!is.null(l_source)){ + DBI::dbWriteTable(q_con, name='l_source', value=l_source, row.names=FALSE, append=TRUE) + } + +} + + + + + diff -r 736f8fd48db2 -r e6a78f89ee07 test-data/createDatabase_output.sqlite Binary file test-data/createDatabase_output.sqlite has changed diff -r 736f8fd48db2 -r e6a78f89ee07 test-data/createDatabase_output_eic.sqlite Binary file test-data/createDatabase_output_eic.sqlite has changed diff -r 736f8fd48db2 -r e6a78f89ee07 test-data/spectralMatching_db_with_spectral_matching.sqlite Binary file test-data/spectralMatching_db_with_spectral_matching.sqlite has changed