Debian Codegraph @

doc/tutorials/defining_new_interfaces.rst

raw ◀ ▶
1 Debian patch touch this file
1 .. _defining-new-interfaces:
2
3 Defining new interfaces
4 =======================
5
6 After defining a new ``Command`` and its API, as covered in :ref:`defining-new-commands`, you're ready to create a first user interface for that command. In this tutorial we'll define a command line interface for the ``SequenceCollectionSummarizer`` command.
7
8 The main differences that need to be handled when defining a command line interface are that we'll want the user to provide their sequence collection on the command line, and we'll want to write the output to a filepath that the user specifies on the command line. This is different than what happens in ``SequenceCollectionSummarizer``, where the input and output are python objects. This is a very important distinction - since our derived ``Commands`` are meant to be interface-independent, they should not do things like require files as input. In some rare circumstances, it may be required for a ``Command`` to write files as its output (for example, if storing the output in memory is intractable).
9
10 pyqi currently provides support for building command line interfaces based on python's `optparse <http://docs.python.org/2/library/optparse.html>`_ module. Your interface will ultimately be an instance of ``pyqi.interfaces.optparse.OptparseInterface``, but the interface class itself is generated dynamically. As a developer, you only define the configuration for the interface via an *interface configuration file* (which is a valid python file) - you won't actually define the interface class itself. If this sounds confusing, just get started - it's easier than it sounds.
11
12 Stubbing a new command line interface
13 -------------------------------------
14
15 pyqi provides a command, ``make-optparse``, that allows developers to easily stub (i.e., create templates for) their optparse interface configuration files. After installing pyqi, you can get usage information by calling::
16
17 pyqi make-optparse -h
18
19 To create your interface, you'll need to pass the ``Command`` as a fully specified python module name, the name of the module where that ``Command`` is defined, and the path where the new configuration file should be written. For example, to create a stub for an ``OptparseInterface`` for our ``SequenceCollectionSummarizer`` command, you could run the following::
20
21 pyqi make-optparse -c sequence_collection_summarizer.SequenceCollectionSummarizer -m sequence_collection_summarizer --credits "Greg Caporaso" -o summarize_sequence_collection.py
22
23 .. warning:: For the above command to work, the directory containing ``sequence_collection_summarizer.py`` will need to be in your ``$PYTHONPATH``.
24
25 The resulting file will look something like this::
26
•27 #!/usr/bin/python3
28 from __future__ import division
29
30 __credits__ = ["Greg Caporaso"]
31
32 from pyqi.core.interfaces.optparse import (OptparseUsageExample,
33 OptparseOption, OptparseResult)
34 from pyqi.core.command import (make_command_in_collection_lookup_f,
35 make_command_out_collection_lookup_f)
36 from sequence_collection_summarizer import CommandConstructor
37
38 # If you need access to input or output handlers provided by pyqi, consider
39 # importing from the following modules:
40 # pyqi.core.interfaces.optparse.input_handler
41 # pyqi.core.interfaces.optparse.output_handler
42 # pyqi.interfaces.optparse.input_handler
43 # pyqi.interfaces.optparse.output_handler
44
45 # Convenience function for looking up parameters by name.
46 cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor)
47 cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor)
48
49 # Examples of how the command can be used from the command line using an
50 # optparse interface.
51 usage_examples = [
52 OptparseUsageExample(ShortDesc="A short single sentence description of the example",
53 LongDesc="A longer, more detailed description",
54 Ex="%prog --foo --bar some_file")
55 ]
56
57 # inputs map command line arguments and values onto Parameters. It is possible
58 # to define options here that do not exist as parameters, e.g., an output file.
59 inputs = [
60 # An example option that has a direct relationship with a Parameter.
61 # OptparseOption(Parameter=cmd_in_lookup('name_of_a_command_in'),
62 # Type='existing_filepath', # the optparse type of input
63 # Action='store', # the optparse action
64 # Handler=None, # Apply a function to the input value to convert it into the type expected by Parameter.DataType
65 # ShortName='n', # a parameter short name, can be None
66 # # Name='foo', # implied by Parameter.Name. Can be overwritten here if desired
67 # # Required=False, # implied by Parameter.Required. Can be promoted by setting True
68 # # Help='help', # implied by Parameter.Description. Can be overwritten here if desired
69 # # Default=None, # implied by Parameter.Default. Can be overwritten here if desired
70 # # DefaultDescription=None, # implied by Parameter.DefaultDescription. Can be overwritten here if desired
71 # convert_to_dashed_name=True), # whether the Name (either implied by Parameter or defined above) should have underscores converted to dashes when displayed to the user
72 #
73 # An example option that does not have an associated Parameter.
74 # OptparseOption(Parameter=None,
75 # Type='new_filepath',
76 # Action='store',
77 # Handler=None, # we don't need a Handler because this option isn't being converted into a format that a Parameter expects
78 # ShortName='o',
79 # Name='output-fp',
80 # Required=True,
81 # Help='output filepath')
82
83 OptparseOption(Parameter=cmd_in_lookup('seqs'),
84 Type=<type 'list'>,
85 Action='store', # default is 'store', change if desired
86 Handler=None, # must be defined if desired
87 ShortName=None, # must be defined if desired
88 # Name='seqs', # implied by Parameter
89 # Required=True, # implied by Parameter
90 # Help='sequences to be summarized', # implied by Parameter
91 ),
92 OptparseOption(Parameter=cmd_in_lookup('suppress_length_summary'),
93 Type=None,
94 Action='store_true', # default is 'store', change if desired
95 Handler=None, # must be defined if desired
96 ShortName=None, # must be defined if desired
97 # Name='suppress_length_summary', # implied by Parameter
98 # Required=False, # implied by Parameter
99 # Help='do not generate summary information on the sequence lengths', # implied by Parameter
100 # Default=False, # implied by Parameter
101 # DefaultDescription=None, # implied by Parameter),
102 ]
103
104 # outputs map result keys to output options and handlers. It is not necessary
105 # to supply an associated option, but if you do, it must be an option from the
106 # inputs list (above).
107 outputs = [
108 # An example option that maps to a CommandIn.
109 # OptparseResult(Parameter=cmd_out_lookup('name_of_a_command_out'),
110 # Handler=write_string, # a function applied to the output of the Command
111 # # the name of the option (defined in inputs, above), whose
112 # # value will be made available to Handler. This name
113 # # can be either an underscored or dashed version of the
114 # # option name (e.g., 'output_fp' or 'output-fp')
115 # InputName='output-fp'),
116 #
117 # An example option that does not map to a CommandIn.
118 # OptparseResult(Parameter=cmd_out_lookup('some_other_result'),
119 # Handler=print_string)
120
121 OptparseResult(Parameter=cmd_out_lookup('max_length'),
122 Handler=None, # must be defined
123 InputName=None), # define if tying to an OptparseOption
124 OptparseResult(Parameter=cmd_out_lookup('min_length'),
125 Handler=None, # must be defined
126 InputName=None), # define if tying to an OptparseOption
127 OptparseResult(Parameter=cmd_out_lookup('num_seqs'),
128 Handler=None, # must be defined
129 InputName=None), # define if tying to an OptparseOption
130 ]
131
132 There are three lists of values that we'll need to populate here to define the optparse interface for our ``SequenceCollectionSummarizer`` command. These are the ``inputs``, the ``outputs``, and the ``usage_examples``. We'll also need to define an input handler and an output handler to tell the ``OptparseInterface`` how to take input from the command line and turn it into something that ``SequenceCollectionSummarizer`` can use, and to take output from ``SequenceCollectionSummarizer`` and turn it into something a command line user will want. ``make-optparse`` will auto-populate the ``inputs`` and ``outputs`` based on the ``CommandIns`` and ``CommandOuts``, but some changes will usually be required (detailed below). The following sections describe each of these steps.
133
134 Defining usage examples
135 -----------------------
136
137 The first thing to do when defining the ``OptparseInterface`` for our ``SequenceCollectionSummarizer`` command is define a set of usage examples. While in practice this documentation step may seem like something you'd want to do last, it's really helpful to do first to get you thinking about how you'd like to interact with your command from the command line.
138
139 Usage examples are defined as instances of the ``pyqi.core.interfaces.optparse.OptparseUsageExample`` class, and are instantiated with three parameters: ``ShortDescription``, ``LongDescription``, and ``Ex``. ``Ex`` is the usage example itself, ``ShortDescription`` is a one sentence description of what ``Ex`` will do, and ``LongDescription`` elaborates on what ``Ex`` does. Find the ``usage_examples`` list in your new ``summarize_sequence_collection.py`` file, and replace its definition with::
140
141 usage_examples = [
142 OptparseUsageExample(ShortDesc="Summarize the input sequence collection and write the result to file.",
143 LongDesc="Read the file specified by -i, and compute the number of sequences in the file, and the minimum and maximum sequence lengths. Write all of that information to path specified by -o.",
144 Ex="%prog -i seqs.fna -o seqs.summary.txt"),
145 OptparseUsageExample(ShortDesc="Summarize the input sequence collection and write the result to file, excluding information on sequence lengths.",
146 LongDesc="Read the file specified by -i, compute the number of sequences in the file, and write that information to path specified by -o.",
147 Ex="%prog -i seqs.fna -o seqs.summary.txt --suppress-length-summary")
148 ]
149
150 Here we define two usage examples, each of which gives us an idea about how we want our script to behave: we want it to take an ``i`` parameter (where the user passes their input file name), an ``o`` parameter (where the user passes their output file name), and an optional parameter called ``suppress-length-summary`` which controls some of the script behavior.
151
152 .. warning:: You shouldn't ever include the name of the script when defining ``OptparseUsageExample.Ex``, but instead include the text ``%prog``. This will be automatically replaced with the script name, so if you ever change the name of the script in the future, the change will take effect in all of your usage examples without you having to remember to update them.
153
154 Defining inputs
155 ---------------
156
157 Next we'll define the list of ``inputs`` that should be associated with our ``OptparseInterface``. Each of these inputs will be an instance of a ``pyqi.core.interface.optparse.OptparseOption`` object. These will roughly map on to the ``CommandIns`` that we defined for ``SequenceCollectionSummarizer``, but there are usually additional interface options relative to command parameters, as we'll see here.
158
159 For the ``OptparseOptions`` that map onto ``CommandIns`` directly, you can look up the corresponding ``CommandIn`` in the ``cmd_in_lookup`` dictionary (which is created for you by ``make-optparse``), and most of the information in the ``OptparseOption`` will be auto-populated for you. ``make-optparse`` will actually fill in as much information as possible for each ``OptparseOption`` that corresponds to an existing ``CommandIn``.
160
161 In our example, you'll notice that there are two ``OptparseOptions`` that are already defined. There are a few values that may need to be changed here. In almost all cases, you'll need to change the ``Type``, which is set to the ``CommandIn``'s ``DataType`` value by default, but should be updated to the ``optparse`` type. You can find discussion of these types in the :ref:`optparse type definitions <optparse-types>` section. Note that the ``Type`` should be ``None`` for command line flags, as the type describes the value that is passed via that option, and command line flags don't take a value. The other value that often will need to be changed is ``Handler``, which tells ``OptparseInterface`` how to transform the ``OptparseOption`` into the corresponding ``CommandIn``. In our case, for our ``seqs`` ``OptparseOption``, that involves converting a filepath into a list of tuples of (sequence id, sequence) pairs. First let's define the ``OptparseOptions``, and then we'll define a new ``Handler``.
162
163 The ``OptparseOptions`` corresponding to the existing ``CommandIns`` should look like this::
164
165 inputs = [
166
167 OptparseOption(Parameter=cmd_in_lookup('seqs'),
168 Type='existing_filepath',
169 Action='store',
170 Handler=parse_fasta,
171 ShortName='i'),
172
173 OptparseOption(Parameter=cmd_in_lookup('suppress_length_summary'),
174 Type=None,
175 Action='store_true',
176 Handler=None,
177 ShortName=None),
178 ]
179
180 These definitions are exactly as generated by ``make-optparse``, except that many of the comments have been removed, and we've modified the ``Types`` and the ``Handler`` for our ``seqs`` option. In the :ref:`next section <defining-input-handlers>` we'll define this new ``parse_fasta`` input handler, but first we'll add one more ``OptparseOption`` which is specific to our command line interface.
181
182 The output from our ``SequenceCollectionSummarizer`` is a dictionary, where some of the values are integers and some of the values may be ``None``. Generally a command line user will want to have information printed to stdout or to file. We'll define our interface so that the output is written to file with some basic formatting put in place. To do this, we need to define a new ``OptparseOption`` to allow the user to specify the path where output should be written. This ``OptparseOption`` does not map onto one of our existing ``CommandIns``, and should be defined as follows::
183
184 OptparseOption(Parameter=None,
185 Type='new_filepath',
186 Action='store',
187 ShortName='o',
188 Name='output-fp',
189 Required=True,
190 Help='path where output should be written')
191
192 Notice the ``Parameter=None`` parameter here: this indicates that this ``OptparseOption`` does not correspond to one of the ``SequenceCollectionSummarizer`` ``CommandIns``.
193
194 You should include this ``OptparseOption`` definition in the ``inputs`` list to define the three options for our command line interface.
195
196 .. _defining-input-handlers:
197
198 Defining input handlers
199 -----------------------
200
201 Input handlers tell the ``OptparseInterface`` class how to take input from the command line and get it into the form that the ``Command`` is expecting. In our case, the user will be providing a filepath on the command line, and our ``SequenceCollectionSummarizer`` expects to receive a list (or other iterable object) of tuples of (sequence id, sequence) pairs. Our input handler is therefore a simple fasta parser, which is a `generator <http://docs.python.org/2/tutorial/classes.html#generators>`_ of (sequence id, sequence) tuples. We can define this as follows::
202
203 def parse_fasta(fp):
204 """
205 fp: path to a fasta-formatted file
206
207 This function is a fasta record generator, yielding
208 (sequence id, sequence) pairs when provided with a
209 valid fasta file.
210
211 NO ERROR CHECKING IS PERFORMED!
212 """
213 # Always open files for reading in python using mode 'U'
214 # to correctly handle different types of line breaks
215 f = open(fp,'U')
216 seq_id = None
217 seq = []
218 for line in f:
219 line = line.strip()
220 if line.startswith('>'):
221 if len(seq) != 0:
222 # we've completed a fasta record
223 yield seq_id, ''.join(seq)
224 seq_id = line[1:]
225 seq = []
226 else:
227 seq.append(line)
228 yield seq_id, ''.join(seq)
229 f.close()
230
231 This definition can go in the interface configuration file that we've been working on in this tutorial. Alternatively, if your input handler is generally useful for your project you can centralize it within your project (see :ref:`organizing-your-repository`), or if you think it's generally useful for pyqi users, you should consider submitting it to the pyqi project :ref:`contributing it to pyqi <contributing-to-pyqi>`.
232
233 Defining outputs
234 ----------------
235
236 The last thing we need to do is define which of the outputs generated by ``SequenceCollectionSummarizer`` are things we care about with this interface, and tell our ``OptparseInterface`` how to handle those. We do this by defining the ``outputs`` list of ``pyqi.core.interfaces.optparse.OptparseResult`` objects. In our case, we'll want to write all of the values that are not ``None`` to the filepath specified by the user with ``output-fp``. To do that, we need to handle three possible outputs, so we'll define those outputs and write an output handler. You should start with the stubbed ``outputs`` list to define how you want to handle each of the parameters. We'll do this as follows::
237
238 outputs = [
239 OptparseResult(Parameter=cmd_out_lookup('num_seqs'),
240 Handler=append_datum_to_file,
241 InputName='output-fp'),
242 OptparseResult(Parameter=cmd_out_lookup('min_length'),
243 Handler=append_datum_to_file,
244 InputName='output-fp'),
245 OptparseResult(Parameter=cmd_out_lookup('max_length'),
246 Handler=append_datum_to_file,
247 InputName='output-fp'),
248
249 ]
250
251 In this case, each of our ``OptparseResults`` are associated with a single ``InputName``: ``output-fp``. We do this because each of these should be written to the same file, but in practice each of these could be associated with different ``InputNames`` (e.g., if each should be written to a different file), or ``InputName=None``, if (for example) a particular result should be written to stdout or stderr. We'll next define the new output handler, ``append_datum_to_file``, used by each of these ``OptparseResult`` objects.
252
253 Defining output handlers
254 ------------------------
255
256 Each of these ``OptparseResult`` objects use the same ``Handler``, which we need to define now. This will take the result and write it to the file specified by the user as ``output-fp``. This should look like the following::
257
258 def append_datum_to_file(result_key, data, option_value=None):
259 """Append summary information to a file.
260 """
261 # don't do anything if data is None
262 if data is None:
263 return
264
265 # If option_value is None when this output handler is called,
266 # the interface developer did something wrong when defining
267 # the OptparseResults. Politely alert the developer that
268 # this output handler isn't associated with an option
269 # (it needs to be associated with an output filepath).
270 if option_value is None:
271 raise IncompetentDeveloperError(
272 "Cannot write output without a filepath.")
273
274 # open the output file for appending, and write the
275 # summary information to a single tab-separated line
276 with open(option_value, 'a') as f:
277 f.write('%s\t%d\n' % (result_key, data))
278
279 Complete OptparseInterface configuration file
280 ---------------------------------------------
281
282 At this stage we've fully configured our interface. The final interface configuration file should look like this::
283
•284 #!/usr/bin/python3
285 from __future__ import division
286
287 __credits__ = ["Greg Caporaso"]
288
289 from pyqi.core.interfaces.optparse import (OptparseUsageExample,
290 OptparseOption, OptparseResult)
291 from pyqi.core.command import (make_command_in_collection_lookup_f,
292 make_command_out_collection_lookup_f)
293 from sequence_collection_summarizer import CommandConstructor
294
295 cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor)
296 cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor)
297
298 def parse_fasta(fp):
299 """
300 fp: path to a fasta-formatted file
301
302 This function is a fasta record generator, yielding
303 (sequence id, sequence) pairs when provided with a
304 valid fasta file.
305
306 NO ERROR CHECKING IS PERFORMED!
307 """
308 # Always open files for reading in python using mode 'U'
309 # to correctly handle different types of line breaks
310 f = open(fp,'U')
311 seq_id = None
312 seq = []
313 for line in f:
314 line = line.strip()
315 if line.startswith('>'):
316 if len(seq) != 0:
317 # we've completed a fasta record
318 yield seq_id, ''.join(seq)
319 seq_id = line[1:]
320 seq = []
321 else:
322 seq.append(line)
323 yield seq_id, ''.join(seq)
324 f.close()
325
326 def append_datum_to_file(result_key, data, option_value=None):
327 """Append summary information to a file.
328 """
329 # don't do anything if data is None
330 if data is None:
331 return
332
333 # If option_value is None when this output handler is called,
334 # the interface developer did something wrong when defining
335 # the OptparseResults. Politely alert the developer that
336 # this output handler isn't associated with an option
337 # (it needs to be associated with an output filepath).
338 if option_value is None:
339 raise IncompetentDeveloperError(
340 "Cannot write output without a filepath.")
341
342 # open the output file for appending, and write the
343 # summary information to a single tab-separated line
344 with open(option_value, 'a') as f:
345 f.write('%s\t%d\n' % (result_key, data))
346
347 usage_examples = [
348 OptparseUsageExample(ShortDesc="Summarize the input sequence collection and write the result to file.",
349 LongDesc="Read the file specified by -i, and compute the number of sequences in the file, and the minimum and maximum sequence lengths. Write all of that information to path specified by -o.",
350 Ex="%prog -i seqs.fna -o seqs.summary.txt"),
351 OptparseUsageExample(ShortDesc="Summarize the input sequence collection and write the result to file, excluding information on sequence lengths.",
352 LongDesc="Read the file specified by -i, compute the number of sequences in the file, and write that information to path specified by -o.",
353 Ex="%prog -i seqs.fna -o seqs.summary.txt --suppress-length-summary")
354 ]
355
356 inputs = [
357 OptparseOption(Parameter=cmd_in_lookup('seqs'),
358 Type='existing_filepath',
359 Action='store',
360 Handler=parse_fasta,
361 ShortName='i'),
362 OptparseOption(Parameter=cmd_in_lookup('suppress_length_summary'),
363 Type=None,
364 Action='store_true',
365 Handler=None,
366 ShortName=None),
367 OptparseOption(Parameter=None,
368 Type='new_filepath',
369 Action='store',
370 ShortName='o',
371 Name='output-fp',
372 Required=True,
373 Help='path where output should be written')
374 ]
375
376 outputs = [
377 OptparseResult(Parameter=cmd_out_lookup('num_seqs'),
378 Handler=append_datum_to_file,
379 InputName='output-fp'),
380 OptparseResult(Parameter=cmd_out_lookup('min_length'),
381 Handler=append_datum_to_file,
382 InputName='output-fp'),
383 OptparseResult(Parameter=cmd_out_lookup('max_length'),
384 Handler=append_datum_to_file,
385 InputName='output-fp')
386 ]
387
388 .. _running-our-command:
389
390 Running our Command via its OptparseInterface
391 ---------------------------------------------
392
393 To run this, there are a couple of additional things you need to do. First, you need to confirm that the directory where you've written these files is accessible via your ``PYTHONPATH``. For example, if you've been working in ``$HOME/code/pyqi_experiments/``, you should have ``$HOME/code/`` in your ``PYTHONPATH``. You can add that as follows::
394
395 export PYTHONPATH=$HOME/code/:$PYTHONPATH
396
397 Next, so you can import from that directory, it'll need to contain an ``__init__.py`` file. You can do this as follows::
398
399 echo '__version__ = "0.0.0"' > $HOME/code/pyqi_experiments/__init__.py
400
401 .. note:: pyqi requires that the top-level module containing the configuration files has a ``__version__`` attribute defined. ``__version__`` should store a version string, e.g., ``"0.0.0"``. In this example, the top-level module is ``pyqi_experiments``, so we must create an ``__init__.py`` that contains a ``__version__`` attribute.
402
403 Now we're ready to run our ``Command`` via its ``OptparseInterface``. You can do this as follows::
404
405 pyqi --command-config-module pyqi_experiments -- summarize-sequence-collection -h
406
407 This will print the help text associated with the ``summarize_sequence_collection`` ``OptparseInterface`` configuration file that we just created.
408
409 .. note:: The ``pyqi`` driver that we used above recognizes command names that match an ``OptparseInterface`` configuration file in the ``--command-config-module`` directory, minus the ``.py``. For example, we created a ``summarize_sequence_collection.py`` configuration file in the ``pyqi_experiments`` directory, so the ``pyqi`` driver recognizes the ``summarize_sequence_collection`` command. It also recognizes the dashed version of a command name, such as ``summarize-sequence-collection``. These names both map to the same command.
410
411 You can test the command by applying it to some sequence collection as follows::
412
413 pyqi --command-config-module pyqi_experiments -- summarize-sequence-collection -i seqs.fna -o seqs.summary.txt
414
415 If ``seqs.fna`` contains the following::
416
417 >s1
418 ACCTTTAACC
419 >s2
420 CCGG
421 >s3
422 AAAAAAAAAAAAAAAAAAAAAAAAAAA
423
424 The resulting ``seqs.summary.txt`` should contain the following lines::
425
426 num-seqs 3
427 min-length 4
428 max-length 27
429
430 Calling your command via the pyqi driver itself, as we're doing here, is a little clunky. Creating a project-specific driver however is very simple (it's a two-line shell script) and is covered in :ref:`defining-your-command-driver`.
431
432 .. _optparse-types:
433
434 OptparseOption Types
435 --------------------
436 pyqi defines several new option types in addition to the optparse's built-in option types. All of the available option types are:
437
438 +------------------------------+------------------------------------------------------------+
439 | option type | brief description |
440 +==============================+============================================================+
441 | string | a string |
442 +------------------------------+------------------------------------------------------------+
443 | int | an int |
444 +------------------------------+------------------------------------------------------------+
445 | long | a long |
446 +------------------------------+------------------------------------------------------------+
447 | float | a float |
448 +------------------------------+------------------------------------------------------------+
449 | complex | a complex number |
450 +------------------------------+------------------------------------------------------------+
451 | choice | one value from a list of choices |
452 +------------------------------+------------------------------------------------------------+
453 | existing_path | path to an existing file or directory |
454 +------------------------------+------------------------------------------------------------+
455 | new_path | path to a new file or directory |
456 +------------------------------+------------------------------------------------------------+
457 | existing_filepath | path to an existing file |
458 +------------------------------+------------------------------------------------------------+
459 | existing_filepaths | path to one or more existing files |
460 +------------------------------+------------------------------------------------------------+
461 | new_filepath | path to a new file |
462 +------------------------------+------------------------------------------------------------+
463 | existing_dirpath | path to an existing directory |
464 +------------------------------+------------------------------------------------------------+
465 | existing_dirpaths | path to one or more existing directories |
466 +------------------------------+------------------------------------------------------------+
467 | new_dirpath | path to a new directory |
468 +------------------------------+------------------------------------------------------------+
469 | multiple_choice | one or more values from a list of choices |
470 +------------------------------+------------------------------------------------------------+
471 | blast_db | a blast database |
472 +------------------------------+------------------------------------------------------------+
473
474 Thoughts and guidelines on designing command line interfaces
475 ------------------------------------------------------------
476
477 Based on our experiences developing command line interfaces for `QIIME <http://www.qiime.org>`_, we've compiled some thoughts on best practices, which you can find in :ref:`optparse-guidelines`.