Repository 'maldi_quant_peak_detection'
hg clone https://toolshed.g2.bx.psu.edu/repos/galaxyp/maldi_quant_peak_detection

Changeset 5:e66f552a3c47 (2020-03-19)
Previous changeset 4:e9300ef37403 (2019-03-22) Next changeset 6:d286ff4600dd (2020-04-16)
Commit message:
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/MALDIquant commit 218c44b9ba1b5f0f47edb743ed70075fb661386e"
modified:
maldi_quant_peakdetection.xml
b
diff -r e9300ef37403 -r e66f552a3c47 maldi_quant_peakdetection.xml
--- a/maldi_quant_peakdetection.xml Fri Mar 22 08:26:23 2019 -0400
+++ b/maldi_quant_peakdetection.xml Thu Mar 19 18:09:47 2020 -0400
[
@@ -1,4 +1,4 @@
-<tool id="maldi_quant_peak_detection" name="MALDIquant peak detection" version="@VERSION@.4">
+<tool id="maldi_quant_peak_detection" name="MALDIquant peak detection" version="@VERSION@.5">
     <description>
         Peak detection, binning and filtering for mass-spectrometry imaging data
     </description>
@@ -16,9 +16,10 @@
             cp '${infile.extra_files_path}/img' infile.img &&
             cp '${infile.extra_files_path}/t2m' infile.t2m &&
         #else
-            ln -s $infile infile.RData &&
+            ln -s '$infile' infile.RData &&
         #end if
-        Rscript '${maldi_quant_peak_detection}'&&
+        cat '${maldi_quant_peak_detection}' &&
+        Rscript '${maldi_quant_peak_detection}' &&
         mkdir $outfile_imzml.files_path &&
         mv ./out.imzMl "${os.path.join($outfile_imzml.files_path, 'imzml')}" | true &&
         mv ./out.ibd "${os.path.join($outfile_imzml.files_path, 'ibd')}" | true &&
@@ -359,16 +360,43 @@
                     ## 2) warp spectra:
                         peaks_new_list = warpMassPeaks(list(peaks[[pixelnb]]), warping_function, emptyNoMatches=$method.methods_conditional.empty_nomatch)
                 }
-                peaks_new = peaks_new_list
+                peaks = peaks_new_list
 
             #end if
 
         #end if
 
+        #if $method.methods_conditional.remove_empty:
+            print(paste(length(findEmptyMassObjects(peaks)), " empty spectra were removed", sep=" "))
+
+            ## only if there are empty spectra to remove
+
+            if (length(findEmptyMassObjects(peaks))>0)
+
+                {
+                    #if $infile.ext == 'rdata'
+                        cardinal_coordinates = cardinal_coordinates[-findEmptyMassObjects(peaks),,drop=FALSE] ## remove coordinates of empty spectra for Cardinal RData input
+                    #end if
+
+                    peaks = removeEmptyMassObjects(peaks)
+            }
+        #end if
+
         ## QC plot and numbers
         par(mfrow = c(2, 2), oma=c(0,0,2,0))
+
         for (random_sample in random_spectra){
-            plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", pixelnames[random_sample]))}
+
+
+        tryCatch(
+                {
+                    plot(peaks[[random_sample]], sub="", main=paste0("spectrum ", pixelnames[random_sample]))},
+                error=function(cond) {
+                    plot(NULL, xlim=c(0,0), ylim=c(0,0), ylab="intensity", xlab="m/z")
+                }
+            )
+}
+
         title("Aligned spectra", outer=TRUE, line=0)
         minmz = round(min(unlist(lapply(peaks,mass))), digits=4)
         maxmz = round(max(unlist(lapply(peaks,mass))), digits=4)