Mercurial > repos > vandelj > giant_volcano_plot
annotate src/getopt.R @ 2:866eec4605b0 draft default tip
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit 89b7d0e8812f53222691cffe29bd48be6519829d"
author | vandelj |
---|---|
date | Fri, 25 Sep 2020 08:53:21 +0000 |
parents | c9a38c1eadf1 |
children |
rev | line source |
---|---|
0
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
1 # Copyright (c) 2008-2010 Allen Day |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
2 # Copyright (c) 2011-2013 Trevor L. Davis <trevor.l.davis@stanford.edu> |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
3 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
4 # Modified by J.Vandel 2017 to consider situation of multiple identical flag |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
5 # and concatenate as a vector the set of parameter for the same flag instead of |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
6 # keeping only the last value as done by the previous version. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
7 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
8 # This file is free software: you may copy, redistribute and/or modify it |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
9 # under the terms of the GNU General Public License as published by the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
10 # Free Software Foundation, either version 2 of the License, or (at your |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
11 # option) any later version. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
12 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
13 # This file is distributed in the hope that it will be useful, but |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
14 # WITHOUT ANY WARRANTY; without even the implied warranty of |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
16 # General Public License for more details. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
17 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
18 # You should have received a copy of the GNU General Public License |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
20 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
21 #' C-like getopt behavior |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
22 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
23 #' getopt is primarily intended to be used with ``\link{Rscript}''. It |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
24 #' facilitates writing ``\#!'' shebang scripts that accept short and long |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
25 #' flags/options. It can also be used from ``R'' directly, but is probably less |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
26 #' useful in this context. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
27 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
28 #' getopt() returns a \link{list} data structure containing \link{names} of the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
29 #' flags that were present in the \link{character} \link{vector} passed in under |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
30 #' the \emph{opt} argument. Each value of the \link{list} is coerced to the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
31 #' data type specified according to the value of the \emph{spec} argument. See |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
32 #' below for details. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
33 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
34 #' Notes on naming convention: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
35 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
36 #' 1. An \emph{option} is one of the shell-split input strings. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
37 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
38 #' 2. A \emph{flag} is a type of \emph{option}. a \emph{flag} can be defined as |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
39 #' having no \emph{argument} (defined below), a required \emph{argument}, or an |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
40 #' optional \emph{argument}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
41 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
42 #' 3. An \emph{argument} is a type of \emph{option}, and is the value associated |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
43 #' with a flag. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
44 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
45 #' 4. A \emph{long flag} is a type of \emph{flag}, and begins with the string |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
46 #' ``--''. If the \emph{long flag} has an associated \emph{argument}, it may be |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
47 #' delimited from the \emph{long flag} by either a trailing \emph{=}, or may be |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
48 #' the subsequent \emph{option}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
49 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
50 #' 5. A \emph{short flag} is a type of \emph{flag}, and begins with the string |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
51 #' ``-''. If a \emph{short flag} has an associated \emph{argument}, it is the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
52 #' subsequent \emph{option}. \emph{short flags} may be bundled together, |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
53 #' sharing a single leading ``-'', but only the final \emph{short flag} is able |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
54 #' to have a corresponding \emph{argument}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
55 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
56 #' Many users wonder whether they should use the getopt package, optparse package, |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
57 #' or argparse package. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
58 #' Here is some of the major differences: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
59 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
60 #' Features available in \code{getopt} unavailable in \code{optparse} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
61 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
62 #' 1. As well as allowing one to specify options that take either |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
63 #' no argument or a required argument like \code{optparse}, |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
64 #' \code{getopt} also allows one to specify option with an optional argument. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
65 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
66 #' Some features implemented in \code{optparse} package unavailable in \code{getopt} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
67 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
68 #' 1. Limited support for capturing positional arguments after the optional arguments |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
69 #' when \code{positional_arguments} set to TRUE in \code{parse_args} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
70 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
71 #' 2. Automatic generation of an help option and printing of help text when encounters an "-h" |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
72 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
73 #' 3. Option to specify default arguments for options as well the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
74 #' variable name to store option values |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
75 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
76 #' There is also new package \code{argparse} introduced in 2012 which contains |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
77 #' all the features of both getopt and optparse but which has a dependency on |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
78 #' Python 2.7 or 3.2+ and has not been used in production since 2008 or 2009 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
79 #' like the getopt and optparse packages. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
80 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
81 #' Some Features unlikely to be implemented in \code{getopt}: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
82 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
83 #' 1. Support for multiple, identical flags, e.g. for "-m 3 -v 5 -v", the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
84 #' trailing "-v" overrides the preceding "-v 5", result is v=TRUE (or equivalent |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
85 #' typecast). |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
86 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
87 #' 2. Support for multi-valued flags, e.g. "--libpath=/usr/local/lib |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
88 #' --libpath=/tmp/foo". |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
89 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
90 #' 3. Support for lists, e.g. "--define os=linux --define os=redhat" would |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
91 #' set result$os$linux=TRUE and result$os$redhat=TRUE. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
92 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
93 #' 4. Support for incremental, argument-less flags, e.g. "/path/to/script |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
94 #' -vvv" should set v=3. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
95 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
96 #' 5. Support partial-but-unique string match on options, e.g. "--verb" and |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
97 #' "--verbose" both match long flag "--verbose". |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
98 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
99 #' 6. No support for mixing in positional arguments or extra arguments that |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
100 #' don't match any options. For example, you can't do "my.R --arg1 1 foo bar |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
101 #' baz" and recover "foo", "bar", "baz" as a list. Likewise for "my.R foo |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
102 #' --arg1 1 bar baz". |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
103 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
104 #' @aliases getopt getopt-package |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
105 #' @param spec The getopt specification, or spec of what options are considered |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
106 #' valid. The specification must be either a 4-5 column \link{matrix}, or a |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
107 #' \link{character} \link{vector} coercible into a 4 column \link{matrix} using |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
108 #' \link{matrix}(x,ncol=4,byrow=TRUE) command. The \link{matrix}/\link{vector} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
109 #' contains: |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
110 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
111 #' Column 1: the \emph{long flag} name. A multi-\link{character} string. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
112 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
113 #' Column 2: \emph{short flag} alias of Column 1. A single-\link{character} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
114 #' string. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
115 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
116 #' Column 3: \emph{Argument} mask of the \emph{flag}. An \link{integer}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
117 #' Possible values: 0=no argument, 1=required argument, 2=optional argument. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
118 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
119 #' Column 4: Data type to which the \emph{flag}'s argument shall be cast using |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
120 #' \link{storage.mode}. A multi-\link{character} string. This only considered |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
121 #' for same-row Column 3 values of 1,2. Possible values: \link{logical}, |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
122 #' \link{integer}, \link{double}, \link{complex}, \link{character}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
123 #' If \link{numeric} is encountered then it will be converted to double. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
124 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
125 #' Column 5 (optional): A brief description of the purpose of the option. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
126 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
127 #' The terms \emph{option}, \emph{flag}, \emph{long flag}, \emph{short flag}, |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
128 #' and \emph{argument} have very specific meanings in the context of this |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
129 #' document. Read the ``Description'' section for definitions. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
130 #' @param opt This defaults to the return value of \link{commandArgs}(TRUE). |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
131 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
132 #' If R was invoked directly via the ``R'' command, this corresponds to all |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
133 #' arguments passed to R after the ``--args'' flag. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
134 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
135 #' If R was invoked via the ``\link{Rscript}'' command, this corresponds to all |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
136 #' arguments after the name of the R script file. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
137 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
138 #' Read about \link{commandArgs} and \link{Rscript} to learn more. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
139 #' @param command The string to use in the usage message as the name of the |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
140 #' script. See argument \emph{usage}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
141 #' @param usage If TRUE, argument \emph{opt} will be ignored and a usage |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
142 #' statement (character string) will be generated and returned from \emph{spec}. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
143 #' @param debug This is used internally to debug the getopt() function itself. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
144 #' @author Allen Day |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
145 #' @seealso \code{\link{getopt}} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
146 #' @keywords data |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
147 #' @export |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
148 #' @examples |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
149 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
150 #' #!/path/to/Rscript |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
151 #' library('getopt'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
152 #' #get options, using the spec as defined by the enclosed list. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
153 #' #we read the options from the default: commandArgs(TRUE). |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
154 #' spec = matrix(c( |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
155 #' 'verbose', 'v', 2, "integer", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
156 #' 'help' , 'h', 0, "logical", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
157 #' 'count' , 'c', 1, "integer", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
158 #' 'mean' , 'm', 1, "double", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
159 #' 'sd' , 's', 1, "double" |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
160 #' ), byrow=TRUE, ncol=4); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
161 #' opt = getopt(spec); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
162 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
163 #' # if help was asked for print a friendly message |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
164 #' # and exit with a non-zero error code |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
165 #' if ( !is.null(opt$help) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
166 #' cat(getopt(spec, usage=TRUE)); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
167 #' q(status=1); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
168 #' } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
169 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
170 #' #set some reasonable defaults for the options that are needed, |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
171 #' #but were not specified. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
172 #' if ( is.null(opt$mean ) ) { opt$mean = 0 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
173 #' if ( is.null(opt$sd ) ) { opt$sd = 1 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
174 #' if ( is.null(opt$count ) ) { opt$count = 10 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
175 #' if ( is.null(opt$verbose ) ) { opt$verbose = FALSE } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
176 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
177 #' #print some progress messages to stderr, if requested. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
178 #' if ( opt$verbose ) { write("writing...",stderr()); } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
179 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
180 #' #do some operation based on user input. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
181 #' cat(paste(rnorm(opt$count,mean=opt$mean,sd=opt$sd),collapse="\n")); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
182 #' cat("\n"); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
183 #' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
184 #' #signal success and exit. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
185 #' #q(status=0); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
186 getopt = function (spec=NULL,opt=commandArgs(TRUE),command=get_Rscript_filename(),usage=FALSE,debug=FALSE) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
187 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
188 # littler compatibility - map argv vector to opt |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
189 if (exists("argv", where = .GlobalEnv, inherits = FALSE)) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
190 opt = get("argv", envir = .GlobalEnv); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
191 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
192 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
193 ncol=4; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
194 maxcol=6; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
195 col.long.name = 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
196 col.short.name = 2; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
197 col.has.argument = 3; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
198 col.mode = 4; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
199 col.description = 5; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
200 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
201 flag.no.argument = 0; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
202 flag.required.argument = 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
203 flag.optional.argument = 2; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
204 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
205 result = list(); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
206 result$ARGS = vector(mode="character"); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
207 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
208 #no spec. fail. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
209 if ( is.null(spec) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
210 stop('argument "spec" must be non-null.'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
211 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
212 #spec is not a matrix. attempt to coerce, if possible. issue a warning. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
213 } else if ( !is.matrix(spec) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
214 if ( length(spec)/4 == as.integer(length(spec)/4) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
215 warning('argument "spec" was coerced to a 4-column (row-major) matrix. use a matrix to prevent the coercion'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
216 spec = matrix( spec, ncol=ncol, byrow=TRUE ); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
217 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
218 stop('argument "spec" must be a matrix, or a character vector with length divisible by 4, rtfm.'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
219 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
220 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
221 #spec is a matrix, but it has too few columns. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
222 } else if ( dim(spec)[2] < ncol ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
223 stop(paste('"spec" should have at least ",ncol," columns.',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
224 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
225 #spec is a matrix, but it has too many columns. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
226 } else if ( dim(spec)[2] > maxcol ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
227 stop(paste('"spec" should have no more than ",maxcol," columns.',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
228 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
229 #spec is a matrix, and it has some optional columns. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
230 } else if ( dim(spec)[2] != ncol ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
231 ncol = dim(spec)[2]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
232 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
233 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
234 #sanity check. make sure long names are unique, and short names are unique. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
235 if ( length(unique(spec[,col.long.name])) != length(spec[,col.long.name]) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
236 stop(paste('redundant long names for flags (column ',col.long.name,').',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
237 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
238 if ( length(na.omit(unique(spec[,col.short.name]))) != length(na.omit(spec[,col.short.name])) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
239 stop(paste('redundant short names for flags (column ',col.short.name,').',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
240 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
241 # convert numeric type to double type |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
242 spec[,4] <- gsub("numeric", "double", spec[,4]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
243 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
244 # if usage=TRUE, don't process opt, but generate a usage string from the data in spec |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
245 if ( usage ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
246 ret = ''; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
247 ret = paste(ret,"Usage: ",command,sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
248 for ( j in 1:(dim(spec))[1] ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
249 ret = paste(ret,' [-[-',spec[j,col.long.name],'|',spec[j,col.short.name],']',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
250 if (spec[j,col.has.argument] == flag.no.argument) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
251 ret = paste(ret,']',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
252 } else if (spec[j,col.has.argument] == flag.required.argument) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
253 ret = paste(ret,' <',spec[j,col.mode],'>]',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
254 } else if (spec[j,col.has.argument] == flag.optional.argument) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
255 ret = paste(ret,' [<',spec[j,col.mode],'>]]',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
256 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
257 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
258 # include usage strings |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
259 if ( ncol >= 5 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
260 max.long = max(apply(cbind(spec[,col.long.name]),1,function(x)length(strsplit(x,'')[[1]]))); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
261 ret = paste(ret,"\n",sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
262 for (j in 1:(dim(spec))[1] ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
263 ret = paste(ret,sprintf(paste(" -%s|--%-",max.long,"s %s\n",sep=''), |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
264 spec[j,col.short.name],spec[j,col.long.name],spec[j,col.description] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
265 ),sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
266 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
267 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
268 else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
269 ret = paste(ret,"\n",sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
270 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
271 return(ret); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
272 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
273 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
274 #XXX check spec validity here. e.g. column three should be convertible to integer |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
275 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
276 i = 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
277 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
278 while ( i <= length(opt) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
279 if ( debug ) print(paste("processing",opt[i])); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
280 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
281 current.flag = 0; #XXX use NA |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
282 optstring = opt[i]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
283 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
284 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
285 #long flag |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
286 if ( substr(optstring, 1, 2) == '--' ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
287 if ( debug ) print(paste(" long option:",opt[i])); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
288 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
289 optstring = substring(optstring,3); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
290 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
291 this.flag = NA; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
292 this.argument = NA; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
293 kv = strsplit(optstring, '=')[[1]]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
294 if ( !is.na(kv[2]) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
295 this.flag = kv[1]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
296 this.argument = paste(kv[-1], collapse="="); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
297 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
298 this.flag = optstring; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
299 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
300 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
301 rowmatch = grep( this.flag, spec[,col.long.name],fixed=TRUE ); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
302 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
303 #long flag is invalid, matches no options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
304 if ( length(rowmatch) == 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
305 stop(paste('long flag "', this.flag, '" is invalid', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
306 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
307 #long flag is ambiguous, matches too many options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
308 } else if ( length(rowmatch) > 1 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
309 # check if there is an exact match and use that |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
310 rowmatch = which(this.flag == spec[,col.long.name]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
311 if(length(rowmatch) == 0) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
312 stop(paste('long flag "', this.flag, '" is ambiguous', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
313 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
314 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
315 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
316 #if we have an argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
317 if ( !is.na(this.argument) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
318 #if we can't accept the argument, bail out |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
319 if ( spec[rowmatch, col.has.argument] == flag.no.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
320 stop(paste('long flag "', this.flag, '" accepts no arguments', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
321 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
322 #otherwise assign the argument to the flag |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
323 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
324 storage.mode(this.argument) = spec[rowmatch, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
325 #don't need here to remove the last value of the vector as argument is in the same string as |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
326 #the flag name "--flag=argument" so no spurious TRUE was added |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
327 result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],this.argument); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
328 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
329 next; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
330 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
331 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
332 #otherwise, we don't have an argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
333 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
334 #if we require an argument, bail out |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
335 ###if ( spec[rowmatch, col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
336 ### stop(paste('long flag "', this.flag, '" requires an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
337 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
338 #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 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
339 ###} else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
340 result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],TRUE); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
341 current.flag = rowmatch; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
342 ###} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
343 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
344 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
345 #short flag(s) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
346 } else if ( substr(optstring, 1, 1) == '-' ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
347 if ( debug ) print(paste(" short option:",opt[i])); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
348 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
349 these.flags = strsplit(optstring,'')[[1]]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
350 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
351 done = FALSE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
352 for ( j in 2:length(these.flags) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
353 this.flag = these.flags[j]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
354 rowmatch = grep( this.flag, spec[,col.short.name],fixed=TRUE ); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
355 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
356 #short flag is invalid, matches no options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
357 if ( length(rowmatch) == 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
358 stop(paste('short flag "', this.flag, '" is invalid', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
359 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
360 #short flag is ambiguous, matches too many options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
361 } else if ( length(rowmatch) > 1 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
362 stop(paste('short flag "', this.flag, '" is ambiguous', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
363 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
364 #short flag has an argument, but is not the last in a compound flag string |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
365 } else if ( j < length(these.flags) & spec[rowmatch,col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
366 stop(paste('short flag "', this.flag, '" requires an argument, but has none', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
367 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
368 #short flag has no argument, flag it as present |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
369 } else if ( spec[rowmatch,col.has.argument] == flag.no.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
370 result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],TRUE); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
371 done = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
372 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
373 #can't definitively process this flag yet, need to see if next option is an argument or not |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
374 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
375 result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],TRUE); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
376 current.flag = rowmatch; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
377 done = FALSE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
378 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
379 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
380 if ( done ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
381 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
382 next; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
383 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
384 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
385 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
386 #invalid opt |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
387 if ( current.flag == 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
388 stop(paste('"', optstring, '" is not a valid option, or does not support an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
389 #TBD support for positional args |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
390 #if ( debug ) print(paste('"', optstring, '" not a valid option. It is appended to getopt(...)$ARGS', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
391 #result$ARGS = append(result$ARGS, optstring); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
392 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
393 # some dangling flag, handle it |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
394 } else if ( current.flag > 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
395 if ( debug ) print(' dangling flag'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
396 if ( length(opt) > i ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
397 peek.optstring = opt[i + 1]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
398 if ( debug ) print(paste(' peeking ahead at: "',peek.optstring,'"',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
399 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
400 #got an argument. attach it, increment the index, and move on to the next option. we don't allow arguments beginning with '-' UNLESS |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
401 #specfile indicates the value is an "integer" or "double", in which case we allow a leading dash (and verify trailing digits/decimals). |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
402 if ( substr(peek.optstring, 1, 1) != '-' | |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
403 #match negative double |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
404 ( substr(peek.optstring, 1, 1) == '-' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
405 & regexpr('^-[0123456789]*\\.?[0123456789]+$',peek.optstring) > 0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
406 & spec[current.flag, col.mode]== 'double' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
407 ) | |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
408 #match negative integer |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
409 ( substr(peek.optstring, 1, 1) == '-' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
410 & regexpr('^-[0123456789]+$',peek.optstring) > 0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
411 & spec[current.flag, col.mode]== 'integer' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
412 ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
413 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
414 if ( debug ) print(paste(' consuming argument *',peek.optstring,'*',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
415 storage.mode(peek.optstring) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
416 #remove the last argument put in result for current.flag that should be a TRUE and concatenate argument with previous ones |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
417 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]][-length(result[[spec[current.flag, col.long.name]]])],peek.optstring); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
418 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
419 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
420 #a lone dash |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
421 } else if ( substr(peek.optstring, 1, 1) == '-' & length(strsplit(peek.optstring,'')[[1]]) == 1 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
422 if ( debug ) print(' consuming "lone dash" argument'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
423 storage.mode(peek.optstring) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
424 #remove the last argument put in result for current.flag that should be a TRUE and concatenate argument with previous ones |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
425 result[[spec[current.flag, col.long.name]]] =c(result[[spec[current.flag, col.long.name]]][-length(result[[spec[current.flag, col.long.name]]])],peek.optstring); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
426 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
427 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
428 #no argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
429 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
430 if ( debug ) print(' no argument!'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
431 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
432 #if we require an argument, bail out |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
433 if ( spec[current.flag, col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
434 stop(paste('flag "', this.flag, '" requires an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
435 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
436 #otherwise set flag as present. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
437 } else if ( |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
438 spec[current.flag, col.has.argument] == flag.optional.argument | |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
439 spec[current.flag, col.has.argument] == flag.no.argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
440 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
441 x = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
442 storage.mode(x) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
443 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]],x); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
444 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
445 stop(paste("This should never happen.", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
446 "Is your spec argument correct? Maybe you forgot to set", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
447 "ncol=4, byrow=TRUE in your matrix call?")); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
448 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
449 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
450 #trailing flag without required argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
451 } else if ( spec[current.flag, col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
452 stop(paste('flag "', this.flag, '" requires an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
453 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
454 #trailing flag without optional argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
455 } else if ( spec[current.flag, col.has.argument] == flag.optional.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
456 x = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
457 storage.mode(x) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
458 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]],x); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
459 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
460 #trailing flag without argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
461 } else if ( spec[current.flag, col.has.argument] == flag.no.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
462 x = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
463 storage.mode(x) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
464 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]],x); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
465 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
466 stop("this should never happen (2). please inform the author."); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
467 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
468 #no dangling flag, nothing to do. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
469 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
470 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
471 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
472 i = i+1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
473 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
474 return(result); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
475 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
476 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
477 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
478 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
479 ######################### |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
480 #set a modified version using only long named parameters |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
481 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
482 getoptLong = function (spec=NULL,opt=commandArgs(TRUE),command=get_Rscript_filename(),usage=FALSE,debug=FALSE) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
483 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
484 # littler compatibility - map argv vector to opt |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
485 if (exists("argv", where = .GlobalEnv, inherits = FALSE)) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
486 opt = get("argv", envir = .GlobalEnv); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
487 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
488 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
489 ncol=4; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
490 maxcol=6; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
491 col.long.name = 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
492 #col.short.name = 2; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
493 col.has.argument = 3; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
494 col.mode = 4; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
495 col.description = 5; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
496 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
497 flag.no.argument = 0; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
498 flag.required.argument = 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
499 flag.optional.argument = 2; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
500 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
501 result = list(); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
502 result$ARGS = vector(mode="character"); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
503 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
504 #no spec. fail. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
505 if ( is.null(spec) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
506 stop('argument "spec" must be non-null.'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
507 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
508 #spec is not a matrix. attempt to coerce, if possible. issue a warning. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
509 } else if ( !is.matrix(spec) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
510 if ( length(spec)/4 == as.integer(length(spec)/4) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
511 warning('argument "spec" was coerced to a 4-column (row-major) matrix. use a matrix to prevent the coercion'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
512 spec = matrix( spec, ncol=ncol, byrow=TRUE ); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
513 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
514 stop('argument "spec" must be a matrix, or a character vector with length divisible by 4, rtfm.'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
515 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
516 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
517 #spec is a matrix, but it has too few columns. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
518 } else if ( dim(spec)[2] < ncol ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
519 stop(paste('"spec" should have at least ",ncol," columns.',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
520 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
521 #spec is a matrix, but it has too many columns. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
522 } else if ( dim(spec)[2] > maxcol ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
523 stop(paste('"spec" should have no more than ",maxcol," columns.',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
524 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
525 #spec is a matrix, and it has some optional columns. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
526 } else if ( dim(spec)[2] != ncol ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
527 ncol = dim(spec)[2]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
528 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
529 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
530 #sanity check. make sure long names are unique, and short names are unique. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
531 if ( length(unique(spec[,col.long.name])) != length(spec[,col.long.name]) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
532 stop(paste('redundant long names for flags (column ',col.long.name,').',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
533 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
534 # if ( length(na.omit(unique(spec[,col.short.name]))) != length(na.omit(spec[,col.short.name])) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
535 # stop(paste('redundant short names for flags (column ',col.short.name,').',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
536 # } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
537 # convert numeric type to double type |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
538 spec[,4] <- gsub("numeric", "double", spec[,4]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
539 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
540 # if usage=TRUE, don't process opt, but generate a usage string from the data in spec |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
541 if ( usage ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
542 ret = ''; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
543 ret = paste(ret,"Usage: ",command,sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
544 for ( j in 1:(dim(spec))[1] ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
545 ret = paste(ret,' [-[-',spec[j,col.long.name],']',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
546 if (spec[j,col.has.argument] == flag.no.argument) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
547 ret = paste(ret,']',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
548 } else if (spec[j,col.has.argument] == flag.required.argument) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
549 ret = paste(ret,' <',spec[j,col.mode],'>]',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
550 } else if (spec[j,col.has.argument] == flag.optional.argument) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
551 ret = paste(ret,' [<',spec[j,col.mode],'>]]',sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
552 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
553 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
554 # include usage strings |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
555 if ( ncol >= 5 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
556 max.long = max(apply(cbind(spec[,col.long.name]),1,function(x)length(strsplit(x,'')[[1]]))); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
557 ret = paste(ret,"\n",sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
558 for (j in 1:(dim(spec))[1] ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
559 ret = paste(ret,sprintf(paste("--%-",max.long,"s %s\n",sep='') |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
560 ,spec[j,col.long.name],spec[j,col.description] |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
561 ),sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
562 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
563 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
564 else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
565 ret = paste(ret,"\n",sep=''); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
566 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
567 return(ret); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
568 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
569 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
570 #XXX check spec validity here. e.g. column three should be convertible to integer |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
571 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
572 i = 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
573 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
574 while ( i <= length(opt) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
575 if ( debug ) print(paste("processing",opt[i])); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
576 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
577 current.flag = 0; #XXX use NA |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
578 optstring = opt[i]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
579 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
580 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
581 #long flag |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
582 if ( substr(optstring, 1, 2) == '--' ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
583 if ( debug ) print(paste(" long option:",opt[i])); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
584 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
585 optstring = substring(optstring,3); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
586 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
587 this.flag = NA; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
588 this.argument = NA; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
589 kv = strsplit(optstring, '=')[[1]]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
590 if ( !is.na(kv[2]) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
591 this.flag = kv[1]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
592 this.argument = paste(kv[-1], collapse="="); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
593 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
594 this.flag = optstring; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
595 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
596 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
597 rowmatch = grep( this.flag, spec[,col.long.name],fixed=TRUE ); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
598 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
599 #long flag is invalid, matches no options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
600 if ( length(rowmatch) == 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
601 stop(paste('long flag "', this.flag, '" is invalid', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
602 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
603 #long flag is ambiguous, matches too many options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
604 } else if ( length(rowmatch) > 1 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
605 # check if there is an exact match and use that |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
606 rowmatch = which(this.flag == spec[,col.long.name]) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
607 if(length(rowmatch) == 0) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
608 stop(paste('long flag "', this.flag, '" is ambiguous', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
609 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
610 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
611 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
612 #if we have an argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
613 if ( !is.na(this.argument) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
614 #if we can't accept the argument, bail out |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
615 if ( spec[rowmatch, col.has.argument] == flag.no.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
616 stop(paste('long flag "', this.flag, '" accepts no arguments', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
617 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
618 #otherwise assign the argument to the flag |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
619 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
620 storage.mode(this.argument) = spec[rowmatch, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
621 #don't need here to remove the last value of the vector as argument is in the same string as |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
622 #the flag name "--flag=argument" so no spurious TRUE was added |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
623 result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],this.argument); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
624 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
625 next; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
626 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
627 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
628 #otherwise, we don't have an argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
629 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
630 #if we require an argument, bail out |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
631 ###if ( spec[rowmatch, col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
632 ### stop(paste('long flag "', this.flag, '" requires an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
633 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
634 #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 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
635 ###} else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
636 result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],TRUE); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
637 current.flag = rowmatch; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
638 ###} |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
639 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
640 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
641 #short flag(s) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
642 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
643 #else if ( substr(optstring, 1, 1) == '-' ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
644 # if ( debug ) print(paste(" short option:",opt[i])); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
645 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
646 # these.flags = strsplit(optstring,'')[[1]]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
647 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
648 # done = FALSE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
649 # for ( j in 2:length(these.flags) ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
650 # this.flag = these.flags[j]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
651 # rowmatch = grep( this.flag, spec[,col.short.name],fixed=TRUE ); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
652 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
653 # #short flag is invalid, matches no options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
654 # if ( length(rowmatch) == 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
655 # stop(paste('short flag "', this.flag, '" is invalid', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
656 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
657 # #short flag is ambiguous, matches too many options |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
658 # } else if ( length(rowmatch) > 1 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
659 # stop(paste('short flag "', this.flag, '" is ambiguous', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
660 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
661 # #short flag has an argument, but is not the last in a compound flag string |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
662 # } else if ( j < length(these.flags) & spec[rowmatch,col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
663 # stop(paste('short flag "', this.flag, '" requires an argument, but has none', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
664 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
665 # #short flag has no argument, flag it as present |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
666 # } else if ( spec[rowmatch,col.has.argument] == flag.no.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
667 # result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],TRUE); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
668 # done = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
669 # |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
670 # #can't definitively process this flag yet, need to see if next option is an argument or not |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
671 # } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
672 # result[[spec[rowmatch, col.long.name]]] = c(result[[spec[rowmatch, col.long.name]]],TRUE); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
673 # current.flag = rowmatch; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
674 # done = FALSE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
675 # } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
676 # } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
677 # if ( done ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
678 # i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
679 # next; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
680 # } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
681 # } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
682 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
683 #invalid opt |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
684 if ( current.flag == 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
685 stop(paste('"', optstring, '" is not a valid option, or does not support an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
686 #TBD support for positional args |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
687 #if ( debug ) print(paste('"', optstring, '" not a valid option. It is appended to getopt(...)$ARGS', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
688 #result$ARGS = append(result$ARGS, optstring); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
689 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
690 # some dangling flag, handle it |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
691 } else if ( current.flag > 0 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
692 if ( debug ) print(' dangling flag'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
693 if ( length(opt) > i ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
694 peek.optstring = opt[i + 1]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
695 if ( debug ) print(paste(' peeking ahead at: "',peek.optstring,'"',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
696 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
697 #got an argument. attach it, increment the index, and move on to the next option. we don't allow arguments beginning with '-' UNLESS |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
698 #specfile indicates the value is an "integer" or "double", in which case we allow a leading dash (and verify trailing digits/decimals). |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
699 if ( substr(peek.optstring, 1, 1) != '-' | |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
700 #match negative double |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
701 ( substr(peek.optstring, 1, 1) == '-' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
702 & regexpr('^-[0123456789]*\\.?[0123456789]+$',peek.optstring) > 0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
703 & spec[current.flag, col.mode]== 'double' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
704 ) | |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
705 #match negative integer |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
706 ( substr(peek.optstring, 1, 1) == '-' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
707 & regexpr('^-[0123456789]+$',peek.optstring) > 0 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
708 & spec[current.flag, col.mode]== 'integer' |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
709 ) |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
710 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
711 if ( debug ) print(paste(' consuming argument *',peek.optstring,'*',sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
712 storage.mode(peek.optstring) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
713 #remove the last argument put in result for current.flag that should be a TRUE and concatenate argument with previous ones |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
714 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]][-length(result[[spec[current.flag, col.long.name]]])],peek.optstring); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
715 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
716 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
717 #a lone dash |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
718 } else if ( substr(peek.optstring, 1, 1) == '-' & length(strsplit(peek.optstring,'')[[1]]) == 1 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
719 if ( debug ) print(' consuming "lone dash" argument'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
720 storage.mode(peek.optstring) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
721 #remove the last argument put in result for current.flag that should be a TRUE and concatenate argument with previous ones |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
722 result[[spec[current.flag, col.long.name]]] =c(result[[spec[current.flag, col.long.name]]][-length(result[[spec[current.flag, col.long.name]]])],peek.optstring); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
723 i = i + 1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
724 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
725 #no argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
726 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
727 if ( debug ) print(' no argument!'); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
728 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
729 #if we require an argument, bail out |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
730 if ( spec[current.flag, col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
731 stop(paste('flag "', this.flag, '" requires an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
732 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
733 #otherwise set flag as present. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
734 } else if ( |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
735 spec[current.flag, col.has.argument] == flag.optional.argument | |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
736 spec[current.flag, col.has.argument] == flag.no.argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
737 ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
738 x = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
739 storage.mode(x) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
740 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]],x); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
741 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
742 stop(paste("This should never happen.", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
743 "Is your spec argument correct? Maybe you forgot to set", |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
744 "ncol=4, byrow=TRUE in your matrix call?")); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
745 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
746 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
747 #trailing flag without required argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
748 } else if ( spec[current.flag, col.has.argument] == flag.required.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
749 stop(paste('flag "', this.flag, '" requires an argument', sep='')); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
750 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
751 #trailing flag without optional argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
752 } else if ( spec[current.flag, col.has.argument] == flag.optional.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
753 x = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
754 storage.mode(x) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
755 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]],x); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
756 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
757 #trailing flag without argument |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
758 } else if ( spec[current.flag, col.has.argument] == flag.no.argument ) { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
759 x = TRUE; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
760 storage.mode(x) = spec[current.flag, col.mode]; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
761 result[[spec[current.flag, col.long.name]]] = c(result[[spec[current.flag, col.long.name]]],x); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
762 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
763 stop("this should never happen (2). please inform the author."); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
764 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
765 #no dangling flag, nothing to do. |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
766 } else { |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
767 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
768 |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
769 i = i+1; |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
770 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
771 return(result); |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
772 } |
c9a38c1eadf1
"planemo upload for repository https://github.com/juliechevalier/GIANT/tree/master commit cb276a594444c8f32e9819fefde3a21f121d35df"
vandelj
parents:
diff
changeset
|
773 |