# HG changeset patch
# User mnhn65mo
# Date 1533636149 14400
# Node ID 10212598b005cb737ca418256374d0a139e0e60e
Uploaded
diff -r 000000000000 -r 10212598b005 rdata_extractor.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rdata_extractor.R Tue Aug 07 06:02:29 2018 -0400
@@ -0,0 +1,79 @@
+#!/usr/bin/env Rscript
+#Use a Rdata file and attributes to extract
+#Get every argument and write a file with its values(s)
+
+
+#get the rdata file
+args = commandArgs(trailingOnly=TRUE)
+rdata<-load(args[1])
+rdata<-get(rdata)
+sum<-summary(rdata)
+
+#get the selected attributes to explore
+attributes_selected <- commandArgs(trailingOnly=TRUE)[2]
+attributes<-strsplit(attributes_selected, ",") #List of elements
+
+write.table(sum,file = "summary.tabular",sep='\t',row.names=FALSE)
+len<-length(attributes[[1]])-1
+bind<-tail(args,n=1)
+
+#file type definition
+file_ext<-function(ext){
+ file<-paste(attributes[[1]][i],ext,sep="") #Filename definition
+ file<-paste("outputs/",file,sep="")
+ return(file)
+}
+
+for (i in 1:len){
+ attribute<-attributes[[1]][i] #Get the attribute i
+ if(! any(names(rdata)==attribute)){
+ error<-paste(attribute, " doesn't exist in the RData. Check the inputs files")
+ write(error, stderr())
+ }
+
+ attribute_val<-eval(parse(text=paste("rdata$",attribute,sep=""))) #Extract the value(s)
+
+ if(is.null(attribute_val)){ #Galaxy can't produce output if NULL
+ file<-file_ext(".txt")
+ write("Return NULL value",file=file)
+ next #Exit loop
+ }
+
+ if (typeof(attribute_val)=="list"){ #Need to be corrected, fail in galaxy but not in R
+ if(length(attribute_val)=="0"){
+ file<-file_ext(".txt")
+ sink(file=file)
+ print("Empty list :") #If the list is empty without element, file is empty and an error occur in galaxy
+ print(attribute_val)
+ sink()
+ next
+ }else{
+ attribute_val<-as.data.frame(do.call(rbind, attribute_val))
+ file<-file_ext(".tabular")
+ write.table(attribute_val,file=file,row.names=FALSE)
+ next
+ }
+ }else if (typeof(attribute_val)=="language"){ #OK
+ attribute_val<-toString(attribute_val,width = NULL)
+ file<-file_ext(".txt")
+ write(attribute_val,file=file)
+ next
+ }
+ file<-file_ext(".tabular")
+ dataframe<-as.data.frame(attribute_val)
+ names(dataframe)<-attribute
+ if(bind=="nobind"){
+ write.table(dataframe,file=file,row.names=FALSE,sep=" ")
+ }else{
+ if(!exists("alldataframe")){
+ alldataframe<-dataframe
+ }else{
+ alldataframe<-cbind(alldataframe, dataframe)
+ }
+ }
+}
+
+if(exists("alldataframe")&&bind=="bind"){
+ write.table(alldataframe,file=file,row.names=FALSE,sep=" ")
+}
+q('no')
diff -r 000000000000 -r 10212598b005 rdata_extractor.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rdata_extractor.xml Tue Aug 07 06:02:29 2018 -0400
@@ -0,0 +1,57 @@
+
+
+ r-getopt
+ readline
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r 10212598b005 rdata_reader.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rdata_reader.R Tue Aug 07 06:02:29 2018 -0400
@@ -0,0 +1,8 @@
+#!/usr/bin/env Rscript
+#Return list of attributes from a Rdata file
+
+args = commandArgs(trailingOnly=TRUE)
+rda<-load(args[1]) #Load the rdata
+rdata<-get(rda)
+names<-names(rdata) #Get the attributes
+write(names, file = "rdata_list_attr")
diff -r 000000000000 -r 10212598b005 rdata_reader.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rdata_reader.xml Tue Aug 07 06:02:29 2018 -0400
@@ -0,0 +1,33 @@
+
+
+ r-getopt
+ readline
+
+
+
+
+
+
+
+
+
+
+==========================
+Rdata reader
+==========================
+**What it does**
+
+The Rdata reader tool give information on the content of a binary R file.
+
+It produces a list of the available dimensions in the Rdata (tabular output file).
+
+Use this tool before considering use "Rdata parser".
+
+|
+
+**How to use it**
+
+Select a file in the Rdata format and execute the tool.
+
+