annotate charts.r @ 4:b079b17dcb4a draft

Uploaded
author guerler
date Thu, 17 Apr 2014 11:19:54 -0400
parents
children f294f5c9608c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
1 #!/usr/bin/Rscript
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
2
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
3 #' Returns file name of calling Rscript
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
4 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
5 #' \code{get_Rscript_filename} returns the file name of calling Rscript
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
6 #' @return A string with the filename of the calling script.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
7 #' If not found (i.e. you are in a interactive session) returns NA.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
8 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
9 #' @export
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
10 get_Rscript_filename <- function() {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
11 prog <- sub("--file=", "", grep("--file=", commandArgs(), value=TRUE)[1])
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
12 if( .Platform$OS.type == "windows") {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
13 prog <- gsub("\\\\", "\\\\\\\\", prog)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
14 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
15 prog
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
16 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
17
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
18 #' Recursively sorts a list
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
19 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
20 #' \code{sort_list} returns a sorted list
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
21 #' @param unsorted_list A list.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
22 #' @return A sorted list.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
23 #' @export
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
24 sort_list <- function(unsorted_list) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
25 for(ii in seq(along=unsorted_list)) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
26 if(is.list(unsorted_list[[ii]])) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
27 unsorted_list[[ii]] <- sort_list(unsorted_list[[ii]])
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
28 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
29 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
30 unsorted_list[sort(names(unsorted_list))]
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
31 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
32
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
33 #' #!/path/to/Rscript
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
34 #' library('getopt');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
35 #' #get options, using the spec as defined by the enclosed list.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
36 #' #we read the options from the default: commandArgs(TRUE).
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
37 #' spec = matrix(c(
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
38 #' 'verbose', 'v', 2, "integer",
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
39 #' 'help' , 'h', 0, "logical",
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
40 #' 'count' , 'c', 1, "integer",
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
41 #' 'mean' , 'm', 1, "double",
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
42 #' 'sd' , 's', 1, "double"
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
43 #' ), byrow=TRUE, ncol=4);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
44 #' opt = getopt(spec);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
45 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
46 #' # if help was asked for print a friendly message
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
47 #' # and exit with a non-zero error code
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
48 #' if ( !is.null(opt$help) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
49 #' cat(getopt(spec, usage=TRUE));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
50 #' q(status=1);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
51 #' }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
52 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
53 #' #set some reasonable defaults for the options that are needed,
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
54 #' #but were not specified.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
55 #' if ( is.null(opt$mean ) ) { opt$mean = 0 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
56 #' if ( is.null(opt$sd ) ) { opt$sd = 1 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
57 #' if ( is.null(opt$count ) ) { opt$count = 10 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
58 #' if ( is.null(opt$verbose ) ) { opt$verbose = FALSE }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
59 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
60 #' #print some progress messages to stderr, if requested.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
61 #' if ( opt$verbose ) { write("writing...",stderr()); }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
62 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
63 #' #do some operation based on user input.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
64 #' cat(paste(rnorm(opt$count,mean=opt$mean,sd=opt$sd),collapse="\n"));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
65 #' cat("\n");
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
66 #'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
67 #' #signal success and exit.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
68 #' #q(status=0);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
69 getopt = function (spec=NULL,opt=commandArgs(TRUE),command=get_Rscript_filename(),usage=FALSE,debug=FALSE) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
70
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
71 # littler compatibility - map argv vector to opt
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
72 if (exists("argv", where = .GlobalEnv, inherits = FALSE)) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
73 opt = get("argv", envir = .GlobalEnv);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
74 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
75
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
76 ncol=4;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
77 maxcol=6;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
78 col.long.name = 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
79 col.short.name = 2;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
80 col.has.argument = 3;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
81 col.mode = 4;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
82 col.description = 5;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
83
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
84 flag.no.argument = 0;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
85 flag.required.argument = 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
86 flag.optional.argument = 2;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
87
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
88 result = list();
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
89 result$ARGS = vector(mode="character");
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
90
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
91 #no spec. fail.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
92 if ( is.null(spec) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
93 stop('argument "spec" must be non-null.');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
94
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
95 #spec is not a matrix. attempt to coerce, if possible. issue a warning.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
96 } else if ( !is.matrix(spec) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
97 if ( length(spec)/4 == as.integer(length(spec)/4) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
98 warning('argument "spec" was coerced to a 4-column (row-major) matrix. use a matrix to prevent the coercion');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
99 spec = matrix( spec, ncol=ncol, byrow=TRUE );
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
100 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
101 stop('argument "spec" must be a matrix, or a character vector with length divisible by 4, rtfm.');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
102 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
103
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
104 #spec is a matrix, but it has too few columns.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
105 } else if ( dim(spec)[2] < ncol ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
106 stop(paste('"spec" should have at least ",ncol," columns.',sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
107
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
108 #spec is a matrix, but it has too many columns.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
109 } else if ( dim(spec)[2] > maxcol ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
110 stop(paste('"spec" should have no more than ",maxcol," columns.',sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
111
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
112 #spec is a matrix, and it has some optional columns.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
113 } else if ( dim(spec)[2] != ncol ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
114 ncol = dim(spec)[2];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
115 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
116
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
117 #sanity check. make sure long names are unique, and short names are unique.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
118 if ( length(unique(spec[,col.long.name])) != length(spec[,col.long.name]) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
119 stop(paste('redundant long names for flags (column ',col.long.name,').',sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
120 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
121 if ( length(na.omit(unique(spec[,col.short.name]))) != length(na.omit(spec[,col.short.name])) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
122 stop(paste('redundant short names for flags (column ',col.short.name,').',sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
123 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
124 # convert numeric type to double type
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
125 spec[,4] <- gsub("numeric", "double", spec[,4])
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
126
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
127 # if usage=TRUE, don't process opt, but generate a usage string from the data in spec
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
128 if ( usage ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
129 ret = '';
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
130 ret = paste(ret,"Usage: ",command,sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
131 for ( j in 1:(dim(spec))[1] ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
132 ret = paste(ret,' [-[-',spec[j,col.long.name],'|',spec[j,col.short.name],']',sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
133 if (spec[j,col.has.argument] == flag.no.argument) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
134 ret = paste(ret,']',sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
135 } else if (spec[j,col.has.argument] == flag.required.argument) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
136 ret = paste(ret,' <',spec[j,col.mode],'>]',sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
137 } else if (spec[j,col.has.argument] == flag.optional.argument) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
138 ret = paste(ret,' [<',spec[j,col.mode],'>]]',sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
139 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
140 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
141 # include usage strings
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
142 if ( ncol >= 5 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
143 max.long = max(apply(cbind(spec[,col.long.name]),1,function(x)length(strsplit(x,'')[[1]])));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
144 ret = paste(ret,"\n",sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
145 for (j in 1:(dim(spec))[1] ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
146 ret = paste(ret,sprintf(paste(" -%s|--%-",max.long,"s %s\n",sep=''),
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
147 spec[j,col.short.name],spec[j,col.long.name],spec[j,col.description]
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
148 ),sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
149 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
150 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
151 else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
152 ret = paste(ret,"\n",sep='');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
153 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
154 return(ret);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
155 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
156
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
157 #XXX check spec validity here. e.g. column three should be convertible to integer
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
158
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
159 i = 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
160
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
161 while ( i <= length(opt) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
162 if ( debug ) print(paste("processing",opt[i]));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
163
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
164 current.flag = 0; #XXX use NA
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
165 optstring = opt[i];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
166
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
167
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
168 #long flag
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
169 if ( substr(optstring, 1, 2) == '--' ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
170 if ( debug ) print(paste(" long option:",opt[i]));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
171
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
172 optstring = substring(optstring,3);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
173
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
174 this.flag = NA;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
175 this.argument = NA;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
176 kv = strsplit(optstring, '=')[[1]];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
177 if ( !is.na(kv[2]) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
178 this.flag = kv[1];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
179 this.argument = paste(kv[-1], collapse="=");
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
180 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
181 this.flag = optstring;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
182 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
183
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
184 rowmatch = grep( this.flag, spec[,col.long.name],fixed=TRUE );
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
185
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
186 #long flag is invalid, matches no options
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
187 if ( length(rowmatch) == 0 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
188 stop(paste('long flag "', this.flag, '" is invalid', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
189
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
190 #long flag is ambiguous, matches too many options
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
191 } else if ( length(rowmatch) > 1 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
192 # check if there is an exact match and use that
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
193 rowmatch = which(this.flag == spec[,col.long.name])
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
194 if(length(rowmatch) == 0) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
195 stop(paste('long flag "', this.flag, '" is ambiguous', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
196 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
197 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
198
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
199 #if we have an argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
200 if ( !is.na(this.argument) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
201 #if we can't accept the argument, bail out
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
202 if ( spec[rowmatch, col.has.argument] == flag.no.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
203 stop(paste('long flag "', this.flag, '" accepts no arguments', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
204
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
205 #otherwise assign the argument to the flag
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
206 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
207 storage.mode(this.argument) = spec[rowmatch, col.mode];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
208 result[spec[rowmatch, col.long.name]] = this.argument;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
209 i = i + 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
210 next;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
211 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
212
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
213 #otherwise, we don't have an argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
214 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
215 #if we require an argument, bail out
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
216 ###if ( spec[rowmatch, col.has.argument] == flag.required.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
217 ### stop(paste('long flag "', this.flag, '" requires an argument', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
218
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
219 #long flag has no attached argument. set flag as present. set current.flag so we can peek ahead later and consume the argument if it's there
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
220 ###} else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
221 result[spec[rowmatch, col.long.name]] = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
222 current.flag = rowmatch;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
223 ###}
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
224 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
225
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
226 #short flag(s)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
227 } else if ( substr(optstring, 1, 1) == '-' ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
228 if ( debug ) print(paste(" short option:",opt[i]));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
229
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
230 these.flags = strsplit(optstring,'')[[1]];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
231
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
232 done = FALSE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
233 for ( j in 2:length(these.flags) ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
234 this.flag = these.flags[j];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
235 rowmatch = grep( this.flag, spec[,col.short.name],fixed=TRUE );
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
236
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
237 #short flag is invalid, matches no options
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
238 if ( length(rowmatch) == 0 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
239 stop(paste('short flag "', this.flag, '" is invalid', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
240
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
241 #short flag is ambiguous, matches too many options
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
242 } else if ( length(rowmatch) > 1 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
243 stop(paste('short flag "', this.flag, '" is ambiguous', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
244
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
245 #short flag has an argument, but is not the last in a compound flag string
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
246 } else if ( j < length(these.flags) & spec[rowmatch,col.has.argument] == flag.required.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
247 stop(paste('short flag "', this.flag, '" requires an argument, but has none', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
248
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
249 #short flag has no argument, flag it as present
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
250 } else if ( spec[rowmatch,col.has.argument] == flag.no.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
251 result[spec[rowmatch, col.long.name]] = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
252 done = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
253
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
254 #can't definitively process this flag yet, need to see if next option is an argument or not
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
255 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
256 result[spec[rowmatch, col.long.name]] = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
257 current.flag = rowmatch;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
258 done = FALSE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
259 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
260 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
261 if ( done ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
262 i = i + 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
263 next;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
264 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
265 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
266
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
267 #invalid opt
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
268 if ( current.flag == 0 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
269 stop(paste('"', optstring, '" is not a valid option, or does not support an argument', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
270 #TBD support for positional args
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
271 #if ( debug ) print(paste('"', optstring, '" not a valid option. It is appended to getopt(...)$ARGS', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
272 #result$ARGS = append(result$ARGS, optstring);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
273
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
274 # some dangling flag, handle it
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
275 } else if ( current.flag > 0 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
276 if ( debug ) print(' dangling flag');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
277 if ( length(opt) > i ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
278 peek.optstring = opt[i + 1];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
279 if ( debug ) print(paste(' peeking ahead at: "',peek.optstring,'"',sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
280
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
281 #got an argument. attach it, increment the index, and move on to the next option. we don't allow arguments beginning with '-' UNLESS
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
282 #specfile indicates the value is an "integer" or "double", in which case we allow a leading dash (and verify trailing digits/decimals).
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
283 if ( substr(peek.optstring, 1, 1) != '-' |
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
284 #match negative double
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
285 ( substr(peek.optstring, 1, 1) == '-'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
286 & regexpr('^-[0123456789]*\\.?[0123456789]+$',peek.optstring) > 0
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
287 & spec[current.flag, col.mode]== 'double'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
288 ) |
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
289 #match negative integer
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
290 ( substr(peek.optstring, 1, 1) == '-'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
291 & regexpr('^-[0123456789]+$',peek.optstring) > 0
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
292 & spec[current.flag, col.mode]== 'integer'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
293 )
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
294 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
295 if ( debug ) print(paste(' consuming argument *',peek.optstring,'*',sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
296
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
297 storage.mode(peek.optstring) = spec[current.flag, col.mode];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
298 result[spec[current.flag, col.long.name]] = peek.optstring;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
299 i = i + 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
300
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
301 #a lone dash
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
302 } else if ( substr(peek.optstring, 1, 1) == '-' & length(strsplit(peek.optstring,'')[[1]]) == 1 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
303 if ( debug ) print(' consuming "lone dash" argument');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
304 storage.mode(peek.optstring) = spec[current.flag, col.mode];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
305 result[spec[current.flag, col.long.name]] = peek.optstring;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
306 i = i + 1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
307
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
308 #no argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
309 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
310 if ( debug ) print(' no argument!');
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
311
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
312 #if we require an argument, bail out
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
313 if ( spec[current.flag, col.has.argument] == flag.required.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
314 stop(paste('flag "', this.flag, '" requires an argument', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
315
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
316 #otherwise set flag as present.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
317 } else if (
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
318 spec[current.flag, col.has.argument] == flag.optional.argument |
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
319 spec[current.flag, col.has.argument] == flag.no.argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
320 ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
321 x = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
322 storage.mode(x) = spec[current.flag, col.mode];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
323 result[spec[current.flag, col.long.name]] = x;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
324 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
325 stop(paste("This should never happen.",
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
326 "Is your spec argument correct? Maybe you forgot to set",
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
327 "ncol=4, byrow=TRUE in your matrix call?"));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
328 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
329 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
330 #trailing flag without required argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
331 } else if ( spec[current.flag, col.has.argument] == flag.required.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
332 stop(paste('flag "', this.flag, '" requires an argument', sep=''));
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
333
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
334 #trailing flag without optional argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
335 } else if ( spec[current.flag, col.has.argument] == flag.optional.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
336 x = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
337 storage.mode(x) = spec[current.flag, col.mode];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
338 result[spec[current.flag, col.long.name]] = x;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
339
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
340 #trailing flag without argument
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
341 } else if ( spec[current.flag, col.has.argument] == flag.no.argument ) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
342 x = TRUE;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
343 storage.mode(x) = spec[current.flag, col.mode];
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
344 result[spec[current.flag, col.long.name]] = x;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
345 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
346 stop("this should never happen (2). please inform the author.");
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
347 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
348 #no dangling flag, nothing to do.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
349 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
350 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
351
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
352 i = i+1;
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
353 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
354 return(result);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
355 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
356
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
357 # convert multi parameter string (i.e. key1: value, key2: value, ...) to object
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
358 split <- function(argument){
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
359 # process parameter string
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
360 options <- list()
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
361 list <- gsub("\\s","", argument)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
362 list <- strsplit(list, ",")
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
363 if (length(list) > 0) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
364 list <- list[[1]]
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
365 for (entry in list) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
366 pair <- strsplit(entry, ":")
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
367 if (length(pair) > 0) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
368 pair <- pair[[1]]
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
369 if (length(pair) == 2) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
370 options[[pair[1]]] <- pair[2]
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
371 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
372 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
373 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
374 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
375 return(options)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
376 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
377
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
378 # get options, using the spec as defined by the enclosed list.
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
379 spec = matrix(c(
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
380 'workdir', 'w', 1, 'character', 'Work directory',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
381 'module', 'm', 1, 'character', 'Module name',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
382 'input', 'i', 1, 'character', 'Input tabular file',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
383 'columns', 'c', 1, 'character', 'Columns string',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
384 'settings', 's', 1, 'character', 'Settings string',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
385 'output', 'o', 1, 'character', 'Output tabular file',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
386 'help', 'h', 0, '', 'Help',
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
387 'verbose', 'v', 0, '', 'Verbose'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
388 ), byrow=TRUE, ncol=5);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
389 opt = getopt(spec);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
390
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
391 # show help
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
392 if ( !is.null(opt$help) ||
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
393 is.null(opt$module) ||
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
394 is.null(opt$input) ||
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
395 is.null(opt$columns) ||
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
396 is.null(opt$output)) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
397 cat(getopt(spec, usage=TRUE))
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
398 q(status=1);
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
399 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
400
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
401 # read columns/settings
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
402 columns = split(opt$columns)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
403 settings = split(opt$settings)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
404
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
405 # read table
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
406 table <- read.table(opt$input)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
407
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
408 # identify module file
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
409 module_file = paste(opt$workdir, opt$module, '.r', sep='')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
410
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
411 # source module
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
412 source(module_file)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
413
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
414 # run module
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
415 l = wrapper (table, columns, settings)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
416
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
417 # header
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
418 header_title <- '# title - Chart Utilities (charts)'
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
419 header_date <- paste('# date -', Sys.time(), sep=' ')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
420 header_module <- paste('# module -', opt$module, sep=' ')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
421 header_settings <- paste('# settings -', opt$settings, sep=' ')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
422 header_columns <- paste('# columns -', opt$columns, sep=' ')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
423
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
424 # fill gaps
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
425 if (length(l) > 0) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
426 # print details
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
427 if (!is.null(opt$verbose)) {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
428 print ('Columns:')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
429 print (columns)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
430 print ('Settings:')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
431 print (settings)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
432 print ('Result:')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
433 print (l)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
434 }
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
435
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
436 # create output file
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
437 output <- file(opt$output, open='wt')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
438
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
439 # write header
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
440 writeLines('#', output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
441 writeLines(header_title, output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
442 writeLines(header_date, output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
443 writeLines(header_module, output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
444 writeLines(header_settings, output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
445 writeLines(header_columns, output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
446 writeLines('#', output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
447
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
448 # write table
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
449 write.table(l, file=output, row.names=FALSE, col.names = FALSE, quote=FALSE, sep='\t')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
450
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
451 # close file
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
452 close(output)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
453 } else {
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
454 print ('Columns:')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
455 print (columns)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
456 print ('Settings:')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
457 print (settings)
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
458 print ('No output generated.')
b079b17dcb4a Uploaded
guerler
parents:
diff changeset
459 }