changeset 19:ceb96c265bd1 draft

Trying to set environment r lib path dependencies.
author nikos
date Wed, 11 Feb 2015 08:05:10 -0500
parents c139b9abe064
children 4821a9e5dcf6
files k2n.R summarize_unique_barcodes.sh summarize_unique_barcodes.xml tool_dependencies.xml
diffstat 4 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/k2n.R	Wed Feb 11 07:32:32 2015 -0500
+++ b/k2n.R	Wed Feb 11 08:05:10 2015 -0500
@@ -1,11 +1,18 @@
+## Setup R error handling to go to stderr
+options( show.error.messages = FALSE, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
+
+# we need that to not crash galaxy with an UTF8 error on German LC settings.
+Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
+
 options(stringAsfactors = FALSE, useFancyQuotes = FALSE)
 args <- commandArgs(trailingOnly = TRUE)
 
-library(RNAprobR)
+.libPaths(args[1])
+suppressMessages(require(RNAprobR))
 
 # Read inputs
-merged <- args[1]
-unique_barcodes <- args[2]
-output <- args[3]
+merged <- args[2]
+unique_barcodes <- args[3]
+output <- args[4]
 
 k2n_calc( merged, unique_barcodes, output )
--- a/summarize_unique_barcodes.sh	Wed Feb 11 07:32:32 2015 -0500
+++ b/summarize_unique_barcodes.sh	Wed Feb 11 08:05:10 2015 -0500
@@ -25,9 +25,10 @@
 -t: Trim untemplated nucleotides.
 -k: Produce k2n file. Warning: Can be sloooow!
 -r: Rscript path
+-l: R lib path
 -o: Output folder (default: "output_dir")
 -------------------------------------
-Usage : summarize_unique_barcodes.sh -f <BAM_file> -b <BARCODES> -p <PRIMING_POSITION> -t -k -r <R_SCRIPT_PATH>
+Usage : summarize_unique_barcodes.sh -f <BAM_file> -b <BARCODES> -p <PRIMING_POSITION> -t -k -r <R_SCRIPT_PATH> -l <R_LIB_PATH>
 End-of-message
 exit
 }
@@ -37,7 +38,7 @@
 trim_flag="False"
 
 #parse input
-while getopts hf:b::p:o:ktr: myarg
+while getopts hf:b::p:o:ktr:l: myarg
 do  case "$myarg" in
     h)  print_help
         exit ;;
@@ -48,6 +49,7 @@
     p)  priming_pos="$OPTARG" ;;
     o)  output_dir="$OPTARG" ;;
     r)  R_SCRIPT_PATH="$OPTARG" ;; #required
+    l)  R_LIB_PATH="$OPTARG" ;; #required
     [?])  echo "ERROR: Unknown parameter"
         print_help
         exit 1 ;;
@@ -220,7 +222,7 @@
 
 #Produce k2n file
 if [ "$k2n" == "True" ]; then
-    Rscript $R_SCRIPT_PATH/k2n.R merged_temp.gz $output_dir/unique_barcodes.txt $output_dir/k2n.txt
+    Rscript $R_SCRIPT_PATH/k2n.R $R_LIB_PATH merged_temp.gz $output_dir/unique_barcodes.txt $output_dir/k2n.txt
 fi
 
 #Remove temp files
--- a/summarize_unique_barcodes.xml	Wed Feb 11 07:32:32 2015 -0500
+++ b/summarize_unique_barcodes.xml	Wed Feb 11 08:05:10 2015 -0500
@@ -8,7 +8,7 @@
         <requirement type="R-module">RNAprobR</requirement>
         <requirement type="package" version="1.0.0">RNAprobR</requirement>
         <requirement type="set_environment">RNA_PROBING_SCRIPT_PATH</requirement>
-        <requirement type="set_environment">RNAprobR_PATH</requirement>
+        <requirement type="set_environment">RNA_PROBING_LIB_PATH</requirement>
 
     </requirements>
 
@@ -32,7 +32,9 @@
             -t
         #end if
 
-        -r \$RNAprobR_PATH
+        -r \$RNA_PROBING_SCRIPT_PATH
+        -l \$RNA_PROBING_LIB_PATH
+
     </command>
 
     <!-- basic error handling -->
--- a/tool_dependencies.xml	Wed Feb 11 07:32:32 2015 -0500
+++ b/tool_dependencies.xml	Wed Feb 11 08:05:10 2015 -0500
@@ -11,6 +11,9 @@
     </package>
     <package name="RNAprobR" version="1.0.0">
         <repository changeset_revision="cabd73083325" name="package_rna_probing_0_99_0" owner="nikos" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+        <set_environment version="1.0">
+            <environment_variable action="set_to" name="RNA_PROBING_LIB_PATH">$REPOSITORY_INSTALL_DIR</environment_variable>
+        </set_environment>
     </package>
     <set_environment version="1.0">
         <environment_variable action="set_to" name="RNA_PROBING_SCRIPT_PATH">$REPOSITORY_INSTALL_DIR</environment_variable>