changeset 74:2bb6b44093ba draft

Uploaded 20170619
author fabio
date Mon, 19 Jun 2017 12:08:59 -0400
parents 156b29da2f0b
children 0a17de046de0
files ._loadandplot.R ._plotwithscale.R ._testandplot.R loadandplot.R loadandplot.xml plotwithscale.R plotwithscale.xml test-data/._.DS_Store test-data/input/._Controls_regions.bed test-data/input/._Elements1_regions.bed test-data/input/._Elements2_regions.bed test-data/input/._Elements3_regions.bed test-data/input/._Feature1.bed test-data/input/._Feature2.bed test-data/input/._features.header.bed.txt test-data/input/._regions.header.txt test-data/output_loadandplot/._iwtomics.loadandplot.RData test-data/output_loadandplot/._iwtomics.loadandplot.features.txt test-data/output_loadandplot/._iwtomics.loadandplot.pdf test-data/output_loadandplot/._iwtomics.loadandplot.regions.txt test-data/output_plotwithscale/._iwtomics.plotwithscale.adjustedpvalue.txt test-data/output_plotwithscale/._iwtomics.plotwithscale.iwtomicstestresults.pdf test-data/output_plotwithscale/._iwtomics.plotwithscale.summaryplot.pdf test-data/output_testandplot/._iwtomics.testandplot.RData test-data/output_testandplot/._iwtomics.testandplot.adjustedpvalue.matrix.txt test-data/output_testandplot/._iwtomics.testandplot.iwtomicstestresults.pdf test-data/output_testandplot/._iwtomics.testandplot.selectedfeatures.txt test-data/output_testandplot/._iwtomics.testandplot.summaryplot.pdf test-data/output_testandplot/._iwtomics.testandplot.tests.txt testandplot.R testandplot.xml
diffstat 31 files changed, 31 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
Binary file ._loadandplot.R has changed
Binary file ._plotwithscale.R has changed
Binary file ._testandplot.R has changed
--- a/loadandplot.R	Wed Jun 14 15:20:56 2017 -0400
+++ b/loadandplot.R	Mon Jun 19 12:08:59 2017 -0400
@@ -19,14 +19,14 @@
       regionsheader=read.delim(args_values$regionsheaderfile,header=FALSE,stringsAsFactors=FALSE,row.names=1,sep="\t")
       regionsfilenames=unlist(strsplit(args_values$regionsfilenames,'\\|'))
       if(length(setdiff(regionsfilenames,row.names(regionsheader)))) {
+        write("IWTomics message: Not all region files are present in the first column of header file for regions.", stderr())
         quit(save="no", status=11)
-        stop('Not all regionsfilenames are present in the first column of regionsheader.')
       }
       id_regions=regionsheader[regionsfilenames,1]
       name_regions=regionsheader[regionsfilenames,2]
     }, error = function(err) {
+      write("IWTomics message: An error has occurred reading the header file for regions. Please try again.", stderr())
       quit(save="no", status=10) #error on header file
-      stop(err)
     })
   }else{
     eval(parse(text=args[[which(args_names=='regionsgalaxyids')]]))
@@ -41,14 +41,14 @@
       featuresheader=read.delim(args_values$featuresheaderfile,header=FALSE,stringsAsFactors=FALSE,row.names=1,sep="\t")
       featuresfilenames=unlist(strsplit(args_values$featuresfilenames,'\\|'))
       if(length(setdiff(featuresfilenames,row.names(featuresheader)))) {
+        write("IWTomics message: Not all feature files are present in the first column of header file for features.", stderr())
         quit(save="no", status=21)
-        stop('Not all featuresfilenames are present in the first column of featuresheader.')
       }
       id_features=featuresheader[featuresfilenames,1]
       name_features=featuresheader[featuresfilenames,2]
     }, error = function(err) {
+      write("IWTomics message: An error has occurred reading the header file for features. Please try again.", stderr())
       quit(save="no", status=20) #error on header file
-      stop(err)
     })
   }else{
     eval(parse(text=args[[which(args_names=='featuresgalaxyids')]]))
@@ -67,24 +67,27 @@
                                 id_regions,name_regions,id_features,name_features,start.are.0based=start.are.0based)
   }, error = function(err) {
     if(grepl('invalid format',err$message)){
+      write("IWTomics message: Not enough columns in input file.", stderr())
       quit(save="no", status=31) # error, not enough columns in input file
     }else if(grepl('duplicated regions',err$message)){
+      write("IWTomics message: Duplicated regions in region file.", stderr())
       quit(save="no", status=32) # error, duplicated regions in region file
     }else if(grepl('duplicated windows',err$message)){
+      write("IWTomics message: Duplicated windows in feature file.", stderr())
       quit(save="no", status=33) # error, duplicated windows in feature file
     }else if(grepl('overlapping windows',err$message)){
+      write("IWTomics message: Overlapping windows in feature file.", stderr())
       quit(save="no", status=34) # error, overlapping windows in feature file
     }else if(grepl('not all regions in datasets',err$message)){
+      write("IWTomics message: Windows in feature files do not cover all regions in region files.", stderr())
       quit(save="no", status=35) # error, windows in feature files do not cover all regions in region files
     }else if(grepl('ifferent size windows',err$message)){
+      write("IWTomics message: All windows in a feature file must have the same size.", stderr())
       quit(save="no", status=36) # error, all windows in a feature files must have the same size
     }
     #error loading data
-
-    stop(err)
-
-    quit(save="no", status=30)
-    
+    write("IWTomics message: An error has occurred reading the data. Please try again.", stderr())
+    quit(save="no", status=30)    
  })
   
   # smooth data
@@ -111,8 +114,8 @@
                               bandwidth=bandwidth,degree=degree,dist_knots=dist_knots)
       }
     }, error = function(err) {
+      write("IWTomics message: An error has occurred smoothing the data. Please try again.", stderr())
       quit(save="no", status=40) #error on smoothing
-      stop(err)
     })
   }
   
@@ -136,6 +139,6 @@
   write.table(as.data.frame(t(idFeatures(regionsFeatures))),file=outfeatures,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
   save(regionsFeatures,file=outrdata)
 }else{
+  write("IWTomics message: Missing IWTomics package. Please be sure to have it installed before using this tool.", stderr())
   quit(save="no", status=255)
-  stop("Missing IWTomics package")
 }
\ No newline at end of file
--- a/loadandplot.xml	Wed Jun 14 15:20:56 2017 -0400
+++ b/loadandplot.xml	Mon Jun 19 12:08:59 2017 -0400
@@ -4,24 +4,8 @@
     <import>macros.xml</import>
   </macros>
   <expand macro="requirements" />
-  <stdio>
-    <exit_code range="255" level="fatal" description="Missing IWTomics package. Please be sure to have it installed before using this tool." />
-    <exit_code range="10" level="fatal" description="An error has occurred reading the header file for regions. Please try again." />
-    <exit_code range="11" level="fatal" description="Not all region files are present in the first column of header file for regions." />
-    <exit_code range="20" level="fatal" description="An error has occurred reading the header file for features. Please try again." />
-    <exit_code range="21" level="fatal" description="Not all feature files are present in the first column of header file for features." />
-    <exit_code range="30" level="fatal" description="An error has occurred reading the data. Please try again." />
-    <exit_code range="31" level="fatal" description="Not enough columns in input file." />
-    <exit_code range="32" level="fatal" description="Duplicated regions in region file." />
-    <exit_code range="33" level="fatal" description="Duplicated windows in feature file." />
-    <exit_code range="34" level="fatal" description="Overlapping windows in feature file." />
-    <exit_code range="35" level="fatal" description="Windows in feature files do not cover all regions in region files." />
-    <exit_code range="36" level="fatal" description="All windows in a feature file must have the same size." />
-    <exit_code range="40" level="fatal" description="An error has occurred smoothing the data. Please try again." />
-    <regex match="Error" source="both" level="fatal" description="An error has occurred. Please try again." />
-  </stdio>
 
-  <command>
+  <command detect_errors="exit_code">
 <![CDATA[
     Rscript '$__tool_directory__/loadandplot.R' outrdata='${outrdata}' outregions='${outregions}' outfeatures='${outfeatures}' outpdf='${outpdf}'
 
@@ -86,14 +70,8 @@
         #else:
           probs='c(${plotres.conditionalplottype.probabilitiessection.prob0},${plotres.conditionalplottype.probabilitiessection.prob1},${plotres.conditionalplottype.probabilitiessection.prob2})'
         #end if
-      #end if
-
-      >& /dev/null
+      #end if      
 ]]>
-    <!--
-    to print the stack add the following line at the end of the command and enable the corresponding entry in output
-    2> "${stackerr}"
-    -->
   </command>
 
   <inputs>
@@ -225,7 +203,6 @@
   </inputs>
 
   <outputs>
-    <!--<data format="txt" name="stackerr" label="iwtomics.loadandplot.stackerr.txt" from_work_dir="iwtomics.loadandplot.stackerr.txt" />-->
     <data format="rdata" name="outrdata" label="${tool.name} on ${on_string}: IWTomicsData Object" from_work_dir="iwtomics.loadandplot.RData" />
     <data format="tabular" name="outregions" label="${tool.name} on ${on_string}: Region Dataset IDs" from_work_dir="iwtomics.loadandplot.regions.txt" />
     <data format="tabular" name="outfeatures" label="${tool.name} on ${on_string}: Feature IDs" from_work_dir="iwtomics.loadandplot.features.txt" />
--- a/plotwithscale.R	Wed Jun 14 15:20:56 2017 -0400
+++ b/plotwithscale.R	Mon Jun 19 12:08:59 2017 -0400
@@ -40,18 +40,18 @@
   featureids=as.character(read.delim(iwtomicsselectedfeatures,header=FALSE,sep='\t',stringsAsFactors=FALSE))
   id_features_subset=featureids[feature_subset]
   if(sum(testids!=paste(testInput(regionsFeatures_test)$id_region1,'vs',testInput(regionsFeatures_test)$id_region2))){
+    write("Wrong test ids.", stderr())
     quit(save="no", status=10)
-    stop('Wrong test ids')
   }
   if(sum(featureids!=idFeatures(regionsFeatures_test))){
+    write("Wrong feature ids.", stderr())
     quit(save="no", status=20)
-    stop('Wrong feature ids')
   }
   # retrieve test and features_subset ids
   id_features_subset=featureids[feature_subset]
   if(sum(duplicated(paste0(test_subset,id_features_subset)))){
+    write("Two scale thresholds selected for the same test and feature.", stderr())
     quit(save="no", status=30)
-    stop('Two scale thresholds selected for the same test and feature.')
   }
   # If scale_subset=0, do not change the threshold
   default=(scale_subset==0)
@@ -64,8 +64,8 @@
                          function(result) unlist(lapply(result,function(feature) feature$max_scale)))
   for(i in seq_along(test_subset)){
     if(scale_threshold[[test_subset[i]]][id_features_subset[i]]<scale_subset[i]){
+      write("Scale threshold too high.", stderr())
       quit(save="no", status=40)
-      stop('Scale threshold too high.')
     }
     scale_threshold[[test_subset[i]]][id_features_subset[i]]=scale_subset[i]
   }
@@ -103,15 +103,15 @@
       dev.off()
     }, error = function(err) {
       if (grepl('selected features with different resolution',err$message)) {
+        write("Group by 'test' but selected features with different resolution.", stderr())
         quit(save="no", status=50) #error: groupby 'test' but selected features with different resolution.
-        stop(err)
       }
+      write("Summary plot error. Please try again.", stderr())
       quit(save="no", status=60) #error 
-      stop(err)
     })
   }
   
 }else{
+  write("Missing IWTomics package. Please be sure to have it installed before using this tool.", stderr())
   quit(save="no", status=255)
-  stop("Missing IWTomics package")
 }
\ No newline at end of file
--- a/plotwithscale.xml	Wed Jun 14 15:20:56 2017 -0400
+++ b/plotwithscale.xml	Mon Jun 19 12:08:59 2017 -0400
@@ -4,18 +4,8 @@
     <import>macros.xml</import>
   </macros>
   <expand macro="requirements" />
-  <stdio>
-    <exit_code range="-1" level="fatal" description="Missing IWTomics package. Please be sure to have it installed before using this tool." />
-    <exit_code range="10" level="fatal" description="Wrong test ids." />
-    <exit_code range="20" level="fatal" description="Wrong feature ids." />
-    <exit_code range="30" level="fatal" description="Two scale thresholds selected for the same test and feature." />
-    <exit_code range="40" level="fatal" description="Scale threshold too high." />
-    <exit_code range="50" level="fatal" description="Group by 'test' but selected features with different resolution." />
-    <exit_code range="60" level="fatal" description="Summary plot error. Please try again." />
-    <regex match="Error" source="both" level="fatal" description="An error has occurred. Please try again." />
-  </stdio>
-
-  <command>
+  
+  <command detect_errors="exit_code">
 <![CDATA[
     Rscript '$__tool_directory__/plotwithscale.R' adjustedpvalue='${adjustedpvalue}' iwtomicsrespdf='${iwtomicsrespdf}' iwtomicssumpdf='${iwtomicssumpdf}'
       iwtomicsrdata='${rdata}'
Binary file test-data/._.DS_Store has changed
Binary file test-data/input/._Controls_regions.bed has changed
Binary file test-data/input/._Elements1_regions.bed has changed
Binary file test-data/input/._Elements2_regions.bed has changed
Binary file test-data/input/._Elements3_regions.bed has changed
Binary file test-data/input/._Feature1.bed has changed
Binary file test-data/input/._Feature2.bed has changed
Binary file test-data/input/._features.header.bed.txt has changed
Binary file test-data/input/._regions.header.txt has changed
Binary file test-data/output_loadandplot/._iwtomics.loadandplot.RData has changed
Binary file test-data/output_loadandplot/._iwtomics.loadandplot.features.txt has changed
Binary file test-data/output_loadandplot/._iwtomics.loadandplot.pdf has changed
Binary file test-data/output_loadandplot/._iwtomics.loadandplot.regions.txt has changed
Binary file test-data/output_plotwithscale/._iwtomics.plotwithscale.adjustedpvalue.txt has changed
Binary file test-data/output_plotwithscale/._iwtomics.plotwithscale.iwtomicstestresults.pdf has changed
Binary file test-data/output_plotwithscale/._iwtomics.plotwithscale.summaryplot.pdf has changed
Binary file test-data/output_testandplot/._iwtomics.testandplot.RData has changed
Binary file test-data/output_testandplot/._iwtomics.testandplot.adjustedpvalue.matrix.txt has changed
Binary file test-data/output_testandplot/._iwtomics.testandplot.iwtomicstestresults.pdf has changed
Binary file test-data/output_testandplot/._iwtomics.testandplot.selectedfeatures.txt has changed
Binary file test-data/output_testandplot/._iwtomics.testandplot.summaryplot.pdf has changed
Binary file test-data/output_testandplot/._iwtomics.testandplot.tests.txt has changed
--- a/testandplot.R	Wed Jun 14 15:20:56 2017 -0400
+++ b/testandplot.R	Mon Jun 19 12:08:59 2017 -0400
@@ -32,16 +32,16 @@
   id_region2=regionids[region2]
   id_features_subset=featureids[features_subset]
   if(length(setdiff(c(id_region1,id_region2),idRegions(regionsFeatures)))!=0){
+    write("Wrong region ids.", stderr())
     quit(save="no", status=10)
-    stop('Wrong region ids')
   }
   if(length(setdiff(id_features_subset,idFeatures(regionsFeatures)))!=0){
+    write("Wrong feature ids.", stderr())
     quit(save="no", status=20)
-    stop('Wrong feature ids')
   }
   if(sum(duplicated(paste0(id_region1,id_region2)))){
+    write("Same test repeated multiple times.", stderr())
     quit(save="no", status=30)
-    stop('Same test repeated multiple times.')
   }
   
   # perform test
@@ -67,8 +67,8 @@
       }
     }
   }, error = function(err) {
+    write("Testing error.", stderr())
     quit(save="no", status=40) #error testing
-    stop(err)
   })
   
   # plot test results
@@ -94,6 +94,6 @@
   write.table(as.data.frame(t(idFeatures(regionsFeatures_test))),file=iwtomicsselectedfeatures,quote=FALSE,sep='\t',row.names=FALSE,col.names=FALSE)
   save(regionsFeatures_test,file=iwtomicsrdata)
 }else{
+  write("Missing IWTomics package. Please be sure to have it installed before using this tool.", stderr())
   quit(save="no", status=255)
-  stop("Missing IWTomics package")
 }
\ No newline at end of file
--- a/testandplot.xml	Wed Jun 14 15:20:56 2017 -0400
+++ b/testandplot.xml	Mon Jun 19 12:08:59 2017 -0400
@@ -4,16 +4,8 @@
     <import>macros.xml</import>
   </macros>
   <expand macro="requirements" />
-  <stdio>
-    <exit_code range="-1" level="fatal" description="Missing IWTomics package. Please be sure to have it installed before using this tool." />
-    <exit_code range="10" level="fatal" description="Wrong region ids." />
-    <exit_code range="20" level="fatal" description="Wrong feature ids." />
-    <exit_code range="30" level="fatal" description="Same test repeated multiple times." />
-    <exit_code range="40" level="fatal" description="Testing error." />
-    <regex match="Error" source="both" level="fatal" description="An error has occurred. Please try again." />
-  </stdio>
 
-  <command>
+  <command detect_errors="exit_code">
 <![CDATA[
     Rscript '$__tool_directory__/testandplot.R' adjustedpvaluematrix='${adjustedpvaluematrix}' iwtomicsrespdf='${iwtomicsrespdf}' iwtomicssumpdf='${iwtomicssumpdf}' iwtomicsrdata='${iwtomicsrdata}' iwtomicstests='${iwtomicstests}' iwtomicsselectedfeatures='${iwtomicsselectedfeatures}'
       regionids='${regionids}'