Mercurial > repos > christian-h > io_test
comparison ToolShedTest/IO_test.R @ 0:be1a1416cf28 draft
Uploaded
author | christian-h |
---|---|
date | Thu, 09 Jan 2014 07:54:55 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:be1a1416cf28 |
---|---|
1 # AIM: Test some IO features betweent Python/Galaxy and R | |
2 # | |
3 # Author: Christian Hundsrucker | |
4 ############################################################################### | |
5 #options(echo=FALSE) #non-interactive -> galaxy | |
6 #options(echo=TRUE) | |
7 #I/O | |
8 #args: filename input | |
9 cargs <- commandArgs(trailingOnly = TRUE) | |
10 args.no<-length(cargs)-1 #last argument is output-file | |
11 outputfile<-cargs[args.no+1] | |
12 | |
13 #functions | |
14 mapKV<-function(keyValue){ | |
15 if (length(keyValue)>2){ | |
16 stop("Wrong arguments used!") | |
17 } | |
18 if (length(keyValue)==2){ | |
19 value<-keyValue[2] | |
20 names(value)<-keyValue[1] | |
21 }else { | |
22 value<-keyValue[1] | |
23 names(value)<-"" | |
24 } | |
25 return(value) | |
26 } | |
27 | |
28 KVargs<-strsplit(cargs[1:args.no],"([ \t])*=([ \t])*",fixed = FALSE, perl = FALSE, useBytes = FALSE) | |
29 keyValues<-unlist(lapply(KVargs,mapKV)) | |
30 | |
31 output<-paste(names(keyValues),keyValues,sep=" -- ") | |
32 output<-paste(output,"\n","current dir: ",getwd(),"\n",sep="") | |
33 capture.output(print(output),file=outputfile,append=FALSE) |