changeset 11:7e4a5ce0877d draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit b6b8da66a6eef180ca8e333f98fc4b7575bac7b3
author tomnl
date Thu, 27 Jun 2019 12:28:15 -0400
parents b74303b60450
children 2c8b5a640a04
files createDatabase.R flagRemove.xml macros.xml spectralMatching.R test-data/createDatabase_output.sqlite test-data/createDatabase_output_eic.sqlite test-data/spectralMatching_db_with_spectral_matching.sqlite
diffstat 7 files changed, 101 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/createDatabase.R	Tue Jun 25 12:22:50 2019 -0400
+++ b/createDatabase.R	Thu Jun 27 12:28:15 2019 -0400
@@ -154,15 +154,13 @@
   }
 
   xset@peaks <- as.matrix(plyr::ddply(data.frame(xset@peaks), ~ sample, convert2Raw, xset=xset))
-  
+
   # Saves the EICS into the previously created database
-  xgroups <-  as.numeric(as.character(unique(pa@grped_df$grpid)))
-  px <- msPurity::purityX(xset, 
+  px <- msPurity::purityX(xset,
                           saveEIC = TRUE,
                           cores=1,
                           sqlitePth=dbPth,
-                          rtrawColumns = TRUE, 
-                          xgroups = xgroups)
+                          rtrawColumns = TRUE)
 
 }
 
--- a/flagRemove.xml	Tue Jun 25 12:22:50 2019 -0400
+++ b/flagRemove.xml	Thu Jun 27 12:28:15 2019 -0400
@@ -1,4 +1,4 @@
-<tool id="mspurity_flagremove" name="msPurity.flagRemove" version="0.2.4">
+<tool id="mspurity_flagremove" name="msPurity.flagRemove" version="@TOOL_VERSION@+galaxy@GALAXY_TOOL_VERSION@">
     <description>Tool to flag and remove XCMS grouped peaks from the xcmsSet object based on various thresholds
         (e.g. RSD of intensity and retention time).
     </description>
--- a/macros.xml	Tue Jun 25 12:22:50 2019 -0400
+++ b/macros.xml	Thu Jun 27 12:28:15 2019 -0400
@@ -1,11 +1,16 @@
 <?xml version="1.0"?>
 <macros>
+    <token name="@TOOL_VERSION@">1.11.3</token>
+    <token name="@GALAXY_TOOL_VERSION@">0.2.5</token>
+
     <xml name="requirements">
         <requirements>
-           <requirement type="package" version="1.11.2" >bioconductor-mspurity</requirement>
+           <requirement type="package" version="@TOOL_VERSION@" >bioconductor-mspurity</requirement>
             <yield />
         </requirements>
     </xml>
+
+
     <xml name="offsets">
         <param name="minoffset" type="float" label="minoffset" value="0.5" argument='--minoffset'
                help="Offset to the 'left' for the precursor range e.g. if precursor of interest is
@@ -96,7 +101,7 @@
             </when>
         </conditional>
     </xml>
-    
+
 
     <xml name="sm_input" token_ql='Query' token_dblabel="SQLite database"  token_ql_shrt="Q"
          token_user="True" token_mspuritydatalib="False" token_msp="False" token_help="">
@@ -105,28 +110,28 @@
                 <option value="userdb" selected="@USER@" >SQLite database of (LC)-MS/MS data</option>
                 <option value="msPurityData"  selected="@MSPURITYDATALIB@" >Prepared database of MassBank, HMDB, LipidBlast and GNPS</option>
                 <option value="msp" >MSP file (SQLite database will be created using using msp2db)</option>
-            </param>    
+            </param>
             <when value="userdb">
                <param type="data" name="@QL_SHRT@_dbPth" label="@QL@ SQLite database" format="sqlite" help=""/>
             </when>
             <when value="msp">
               <param type="data" name="@QL_SHRT@_msp" label="@QL@ MSP file" format="msp" help=""/>
             </when>
-            
+
             <when value="msPurityData">
             </when>
         </conditional>
     </xml>
-    
-    
+
+
     <xml name="filters" token_ql="Query" token_polarity_positive="false" token_ql_shrt="Q"
          token_sources_select="false" token_instrument_types_select="false">
-      
+
         <section name="@QL_SHRT@_filters" title="Filters" expanded="False">
-            
+
             <param name="@QL_SHRT@_ppmPrec" type="float" value="5" label="ppm error of the precursor for spectra"/>
             <param name="@QL_SHRT@_ppmProd" type="float" value="10" label="ppm error of the product for spectra"/>
-              
+
             <conditional name="@QL_SHRT@_raThres_cond">
                 <param name="@QL_SHRT@_raThres_bool" type="boolean" label="Filter on relative abundance threshold?"/>
                 <when value="true">
@@ -135,7 +140,7 @@
                 <when value="false">
                 </when>
             </conditional>
-            
+
             <conditional name="@QL_SHRT@_polarity_cond">
                 <param name="@QL_SHRT@_polarity_bool" type="boolean" label="Filter on polarity?" help="" />
                 <when value="true">
@@ -148,7 +153,7 @@
                 <when value="false">
                 </when>
             </conditional>
-                                                              
+
             <conditional name="@QL_SHRT@_purity_cond">
                 <param name="@QL_SHRT@_purity_bool" type="boolean" label="Filter on precursor ion purity?"/>
                 <when value="true">
@@ -158,35 +163,35 @@
                 <when value="false">
                 </when>
             </conditional>
-            
+
             <conditional name="@QL_SHRT@_xcmsGroups_cond">
                 <param name="@QL_SHRT@_xcmsGroups_bool" type="boolean" label="Filter on XCMS groups ids?"/>
                 <when value="true">
                     <param name="@QL_SHRT@_xcmsGroups" type="text" value=""
-                          label="XCMS group ids of spectra" 
+                          label="XCMS group ids of spectra"
                           help="comma seperated list of grpids (correspond to column 'grpid in c_peak_group'))
                                 e.g '12,27,30'" />
                 </when>
                 <when value="false">
                 </when>
             </conditional>
-            
-            
+
+
             <conditional name="@QL_SHRT@_pids_cond">
                 <param name="@QL_SHRT@_pids_bool" type="boolean" label="Filter on pids?"/>
                 <when value="true">
                     <param name="@QL_SHRT@_pids" type="text" value=""
-                          label="pids of spectra (correspond to column 'pid; in s_peak_meta)" 
+                          label="pids of spectra (correspond to column 'pid; in s_peak_meta)"
                           help="comma seperated list of pids (correspond to column 'pid; in s_peak_meta))
                                 e.g '3001,5561'" />
                 </when>
                 <when value="false">
                 </when>
             </conditional>
-            
-            
+
+
             <conditional name="@QL_SHRT@_rtrange_cond">
-                <param name="@QL_SHRT@_rtrange_bool" type="boolean" 
+                <param name="@QL_SHRT@_rtrange_bool" type="boolean"
                        label="Filter on retention time range?"
                        help="Filter the spectra between two points of retention time range"/>
                 <when value="true">
@@ -198,32 +203,32 @@
                 <when value="false">
                 </when>
             </conditional>
-            
-            
-            
+
+
+
             <conditional name="@QL_SHRT@_accessions_cond">
-                <param name="@QL_SHRT@_accessions_bool" type="boolean" 
+                <param name="@QL_SHRT@_accessions_bool" type="boolean"
                        label="Filter on accessions?"
                        help="Filter on unique accessions IDs (e.g. from MassBank and MoNA)"/>
                 <when value="true">
                     <param name="@QL_SHRT@_accessions" type="text" value=""
-                          label="Spectra accessions" 
+                          label="Spectra accessions"
                           help="Comma seperated list of accessions))
                                 e.g 'AC000001,BS001003,LIT00001'" />
                 </when>
                 <when value="false">
                 </when>
             </conditional>
-            
-            
+
+
             <conditional name="@QL_SHRT@_sources_cond">
-                <param name="@QL_SHRT@_sources_bool" type="boolean" 
+                <param name="@QL_SHRT@_sources_bool" type="boolean"
                        label="Filter on sources?" help="" value="@SOURCES_SELECT@" />
                 <when value="true">
                     <param name="@QL_SHRT@_sources" type="select" multiple="true"
-                       help="@QL_SHRT@ The default internal SQLite database of library (reference) spectra 
-                       contains fragmentation spectra from MassBank, LipidBlast and GNPS. A copy is 
-                       available from here: 
+                       help="@QL_SHRT@ The default internal SQLite database of library (reference) spectra
+                       contains fragmentation spectra from MassBank, LipidBlast and GNPS. A copy is
+                       available from here:
                        https://bioconductor.org/packages/release/data/experiment/html/msPurityData.html" >
                         <option value="massbank" selected="true">MassBank from MoNa</option>
                         <option value="gnps" selected="true">GNPS</option>
@@ -239,7 +244,7 @@
                 </when>
             </conditional>
             <conditional name="@QL_SHRT@_instrumentTypes_cond">
-                <param name="@QL_SHRT@_instrumentTypes_bool" type="boolean" 
+                <param name="@QL_SHRT@_instrumentTypes_bool" type="boolean"
                        value="@INSTRUMENT_TYPES_SELECT@"
                        label="Filter on instrument type?" help="" />
                 <when value="true">
@@ -278,7 +283,7 @@
                         <option value="none">None</option>
                   </param>
                   <param name="@QL_SHRT@_instrumentTypesUser" type="text" value=""
-                         help="Types of the instruments to be included in the search. Use a comma to 
+                         help="Types of the instruments to be included in the search. Use a comma to
                                separate the instrument types or leave empty to ignore filter."/>
                 </when>
                 <when value="false">
@@ -288,17 +293,17 @@
                 <param name="@QL_SHRT@_instruments_bool" type="boolean" label="Filter on instrument name?" help="" />
                 <when value="true">
                     <param name="@QL_SHRT@_instruments" type="text" value=""
-                         help="Known instrument names to filter on. Use a comma to 
+                         help="Known instrument names to filter on. Use a comma to
                                separate the instrument types or leave empty to ignore filter."/>
                 </when>
                 <when value="false">
                 </when>
             </conditional>
-            
-            
+
+
 
             <conditional name="@QL_SHRT@_spectraTypes_cond">
-                <param name="@QL_SHRT@_spectraTypes_bool" type="boolean" label="Filter on spectral type?" 
+                <param name="@QL_SHRT@_spectraTypes_bool" type="boolean" label="Filter on spectral type?"
                 help="" />
                 <when value="true">
                     <param name="@QL_SHRT@_spectraTypes" type="select" multiple="true"  label="Spectra type" >
@@ -314,14 +319,14 @@
             </conditional>
 
            <param name="@QL_SHRT@_spectraFilter" type="boolean" checked="true"
-                  label="Ignore any peaks flagged in the spectra in previous stages?" 
+                  label="Ignore any peaks flagged in the spectra in previous stages?"
                           help="" />
-            
+
         </section>
     </xml>
-    
+
 
-    
+
 
     <xml name="citations">
         <citations>
--- a/spectralMatching.R	Tue Jun 25 12:22:50 2019 -0400
+++ b/spectralMatching.R	Thu Jun 27 12:28:15 2019 -0400
@@ -8,76 +8,76 @@
   make_option(c("-o", "--outDir"), type="character"),
   make_option("--q_dbPth", type="character"),
   make_option("--l_dbPth", type="character"),
-  
+
   make_option("--q_msp", type="character", default=NA),
   make_option("--l_msp", type="character", default=NA),
-  
+
   make_option("--q_defaultDb", action="store_true"),
   make_option("--l_defaultDb", action="store_true"),
-  
+
   make_option("--q_ppmPrec", type="double"),
   make_option("--l_ppmPrec", type="double"),
-  
+
   make_option("--q_ppmProd", type="double"),
   make_option("--l_ppmProd", type="double"),
-  
+
   make_option("--q_raThres", type="double", default=NA),
   make_option("--l_raThres", type="double", default=NA),
-  
+
   make_option("--q_polarity", type="character", default=NA),
   make_option("--l_polarity", type="character", default=NA),
 
   make_option("--q_purity", type="double", default=NA),
   make_option("--l_purity", type="double", default=NA),
-  
+
   make_option("--q_xcmsGroups", type="character", default=NA),
   make_option("--l_xcmsGroups", type="character", default=NA),
-  
+
   make_option("--q_pids", type="character", default=NA),
   make_option("--l_pids", type="character", default=NA),
-  
+
   make_option("--q_rtrangeMin", type="double", default=NA),
   make_option("--l_rtrangeMin", type="double", default=NA),
-  
+
   make_option("--q_rtrangeMax", type="double", default=NA),
   make_option("--l_rtrangeMax", type="double", default=NA),
-  
+
   make_option("--q_accessions", type="character", default=NA),
   make_option("--l_accessions", type="character", default=NA),
-  
+
   make_option("--q_sources", type="character", default=NA),
   make_option("--l_sources", type="character", default=NA),
-  
+
   make_option("--q_sourcesUser", type="character", default=NA),
   make_option("--l_sourcesUser", type="character", default=NA),
-  
+
   make_option("--q_instrumentTypes", type="character", default=NA),
   make_option("--l_instrumentTypes", type="character", default=NA),
-  
+
   make_option("--q_instrumentTypesUser", type="character", default=NA),
   make_option("--l_instrumentTypesUser", type="character", default=NA),
-  
+
   make_option("--q_instruments", type="character", default=NA),
   make_option("--l_instruments", type="character", default=NA),
-  
+
   make_option("--q_spectraTypes", type="character", default=NA),
   make_option("--l_spectraTypes", type="character", default=NA),
-  
+
   make_option("--q_spectraFilter", action="store_true"),
   make_option("--l_spectraFilter", action="store_true"),
-  
+
   make_option("--usePrecursors", action="store_true"),
-  
+
   make_option("--mzW", type="double"),
   make_option("--raW", type="double"),
-  
+
   make_option("--rttol", type="double", default=NA),
-  
+
   make_option("--updateDb", action="store_true"),
   make_option("--copyDb", action="store_true"),
   make_option("--cores", default=1)
-  
-  
+
+
 )
 
 # store options
@@ -93,7 +93,7 @@
      param <- NA
   }
   return(param)
-  
+
 }
 
 if(!is.null(opt$q_defaultDb)){
@@ -192,48 +192,48 @@
 
 sm <- msPurity::spectralMatching(q_dbPth = q_dbPth,
                            l_dbPth = l_dbPth,
-                           
+
                            q_purity =  opt$q_purity,
                            l_purity =  opt$l_purity,
-                           
+
                            q_ppmProd =  opt$q_ppmProd,
                            l_ppmProd =  opt$l_ppmProd,
-                           
+
                            q_ppmPrec =  opt$q_ppmPrec,
                            l_ppmPrec =  opt$l_ppmPrec,
-    
+
                            q_raThres =  opt$q_raThres,
                            l_raThres =  opt$l_raThres,
-                           
+
                            q_pol =  q_polarity,
                            l_pol =  l_polarity,
-                           
+
                            q_xcmsGroups = q_xcmsGroups,
                            l_xcmsGroups = l_xcmsGroups,
-                           
+
                            q_pids = q_pids,
                            l_pids = l_pids,
-                           
+
                            q_sources = q_sources,
                            l_sources = l_sources,
-                           
+
                            q_instrumentTypes = q_instrumentTypes,
                            l_instrumentTypes = l_instrumentTypes,
-                           
+
                            q_spectraFilter= q_spectraFilter,
                            l_spectraFilter= l_spectraFilter,
-                           
+
                            l_rtrange=c(l_rtrangeMin, l_rtrangeMax),
                            q_rtrange=c(q_rtrangeMin, q_rtrangeMax),
-                           
+
                            q_accessions = opt$q_accessions,
                            l_accessions= opt$l_accessions,
-                           
+
                            raW = opt$raW,
                            mzW = opt$mzW,
                            rttol=opt$rttol,
                            cores=opt$cores,
-                           
+
                            copyDb=copyDb,
                            updateDb=updateDb,
                            outPth = "db_with_spectral_matching.sqlite"
@@ -254,34 +254,34 @@
     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")){
+  if (DBI::dbExistsTable(l_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 
+
+  }else if(DBI::dbExistsTable(l_con, "library_spectra")){
+    l_s_peaks <- DBI::dbGetQuery(l_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')
+
+  if (DBI::dbExistsTable(l_con, "source")){
+    l_source <- DBI::dbGetQuery(l_con, 'SELECT  * FROM source')
+  }else if (DBI::dbExistsTable(l_con, "library_spectra_source")) {
+    l_source <- DBI::dbGetQuery(l_con, 'SELECT  * FROM 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)
   }
-  
+
 }
 
 
Binary file test-data/createDatabase_output.sqlite has changed
Binary file test-data/createDatabase_output_eic.sqlite has changed
Binary file test-data/spectralMatching_db_with_spectral_matching.sqlite has changed