def test_init(self): obj = OptparseUsageExample(ShortDesc='a', LongDesc='b', Ex='c') self.assertEqual(obj.ShortDesc, 'a') self.assertEqual(obj.LongDesc, 'b') self.assertEqual(obj.Ex, 'c') with self.assertRaises(IncompetentDeveloperError): _ = OptparseUsageExample('a', 'b', Ex=None)
def setUp(self): self.obj = optparse_factory( ghetto, [OptparseUsageExample('a', 'b', 'c')], [ OptparseOption( Type=str, Parameter=ghetto.CommandIns['c'], ShortName='n') ], [ OptparseResult(Type=str, Parameter=ghetto.CommandOuts['itsaresult'], Handler=oh) ], '2.0-dev')
__author__ = "Jai Ram Rideout" __copyright__ = "Copyright 2011-2013, The BIOM Format Development Team" __credits__ = ["Jai Ram Rideout", "Greg Caporaso", "Morgan Langille", "Daniel McDonald"] __license__ = "BSD" __url__ = "http://biom-format.org" __maintainer__ = "Jai Ram Rideout" __email__ = "*****@*****.**" cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Adding sample metadata", LongDesc="Add sample metadata to a BIOM table", Ex="%prog -i otu_table.biom -o " "table_with_sample_metadata.biom -m " "sample_metadata.txt") ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('table'), Type='existing_filepath', Handler=load_biom_table, ShortName='i', Name='input-fp'), OptparseOption(Parameter=cmd_in_lookup('sample_metadata'), Type='existing_filepath', Handler=file_reading_handler, ShortName='m', Name='sample-metadata-fp'),
__copyright__ = "Copyright 2011-2013, The BIOM Format Development Team" __credits__ = [ "Jai Ram Rideout", "Daniel McDonald", "Jose Antonio Navas Molina" ] __license__ = "BSD" __url__ = "http://biom-format.org" __maintainer__ = "Jai Ram Rideout" __email__ = "*****@*****.**" cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Subsetting a json BIOM table", LongDesc="Choose a subset of the observations in " "table.biom and write them to subset.biom", Ex="%prog -j table.biom -a observations -s " "observation_ids.txt -o subset.biom"), OptparseUsageExample(ShortDesc="Subsetting a hdf5 BIOM table", LongDesc="Choose a subset of the observations in " "table.biom and write them to subset.biom", Ex="%prog -i table.biom -a observations -s " "observation_ids.txt -o subset.biom") ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('hdf5_table'), Type='existing_filepath', Handler=None, ShortName='i', Name='input-hdf5-fp',
from pyqi.core.interfaces.optparse import (OptparseOption, OptparseUsageExample, OptparseResult) from pyqi.core.interfaces.optparse.output_handler import write_string from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from pyqi.commands.make_bash_completion import CommandConstructor cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample( ShortDesc="Create a bash completion script", LongDesc="Create a bash completion script for use with a pyqi driver", Ex= "%prog --command-config-module pyqi.interfaces.optparse.config --driver-name pyqi -o ~/.bash_completion.d/pyqi" ) ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('command_config_module')), OptparseOption(Parameter=cmd_in_lookup('driver_name')), OptparseOption(Parameter=None, Type='new_filepath', ShortName='o', Name='output-fp', Required=True, Help='output filepath') ]
#!/usr/bin/env python from __future__ import division __credits__ = ["Daniel McDonald"] from pyqi.core.interfaces.optparse import (OptparseUsageExample, OptparseOption, OptparseResult) from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from pyqi.commands.make_release import CommandConstructor # Convenience function for looking up parameters by name. cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Make a release", LongDesc="Make a release, tag it, update version " "strings and upload to pypi", Ex="%prog --package-name=pyqi --real-run") ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('package_name')), OptparseOption(Parameter=cmd_in_lookup('real_run'), Action='store_true'), ] outputs = []
from pyqi.core.interfaces.optparse.output_handler import write_string from scaling.commands.bench_suite_maker import CommandConstructor from scaling.interfaces.optparse.input_handler import (get_bench_paths, load_parameters) # Convenience function for looking up parameters by name. cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) # Examples of how the command can be used from the command line using an # optparse interface. usage_examples = [ OptparseUsageExample(ShortDesc="Parameters example usage", LongDesc="Test the command \"pick_otus.py\" using " "different similarity values. The file parameters.txt" " should follow these structure\nsimilarity<tab>" "val1,val2,val3", Ex="%prog -c \"pick_otus.py -i seqs.fna\" -p " "parameters.txt -o pick_otus_bench_suite.sh"), OptparseUsageExample(ShortDesc="Input files example usage", LongDesc="Test the command \"pick_otus.py\" using " "different input files. The folder bench_files should" " include only the input files used by the command", Ex="%prog -c \"pick_otus.py\" -i bench_files -o " "pick_otus_bench_suite.sh"), OptparseUsageExample(ShortDesc="Multiple input files example usage", LongDesc="Test the command \"split_librarires_fastq." "py\" using different input files. These command " "takes the input file in pairs so we provide the " "input files in two different folders", Ex="%prog -c \"split_librarires_fastq.py -m "
OptparseOption, OptparseResult) from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from readgood.commands.readgooder import CommandConstructor from readgood.interfaces.optparse.input_handler import driver from readgood.interfaces.optparse.output_handler import box_writer # Convenience function for looking up parameters by name. cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) # Examples of how the command can be used from the command line using an # optparse interface. usage_examples = [ OptparseUsageExample(ShortDesc="Write all the text", LongDesc="Read gooder", Ex="%prog --text=some_file") ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('tickmark_in_box_index'), Type=int, Action='store', # default is 'store', change if desired ShortName=None, # must be defined if desired ), OptparseOption(Parameter=cmd_in_lookup('text'), Type=str, Action='store', Handler=driver ), OptparseOption(Parameter=cmd_in_lookup('box_width'),
OptparseOption, OptparseResult) from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from pyqi.core.interfaces.optparse.input_handler import string_list_handler from scaling.commands.bench_results_comparator import CommandConstructor from scaling.interfaces.optparse.output_handler import write_matplotlib_figure # Convenience function for looking up parameters by name. cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) # Examples of how the command can be used from the command line using an # optparse interface. usage_examples = [ OptparseUsageExample( ShortDesc="A short single sentence description of the example", LongDesc="A longer, more detailed description", Ex="%prog --foo --bar some_file") ] # inputs map command line arguments and values onto Parameters. It is possible # to define options here that do not exist as parameters, e.g., an output file. inputs = [ OptparseOption( Parameter=cmd_in_lookup('input_dirs'), Type='existing_dirpaths', Action='store', # default is 'store', change if desired Handler=None, # must be defined if desired ShortName='i', # must be defined if desired # Name='input_dirs', # implied by Parameter # Required=True, # implied by Parameter # Help='List with the path to the directories with the time results of different runs of the same bench suite', # implied by Parameter
def _get_usage_examples(self): return [OptparseUsageExample('a', 'b', 'c')]
cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) def report_table_validity(result_key, data, option_value=None): if data: print "The input file is a valid BIOM-formatted file." sys.exit(0) else: print "The input file is not a valid BIOM-formatted file." sys.exit(1) usage_examples = [ OptparseUsageExample(ShortDesc="Validating a BIOM file", LongDesc="Validate the contents of table.biom for " "adherence to the BIOM format specification", Ex="%prog -i table.biom") ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('table'), Type='existing_filepath', Handler=None, ShortName='i', Name='input-fp', Help='the input filepath to validate against the BIOM ' 'format specification'), OptparseOption(Parameter=cmd_in_lookup('is_json'), Type=None, Action='store_true'), OptparseOption(Parameter=cmd_in_lookup('format_version'), ShortName='f'),
from pyqi.core.interfaces.optparse import (OptparseOption, OptparseResult, OptparseUsageExample) from pyqi.core.interfaces.optparse.input_handler import string_list_handler from pyqi.core.interfaces.optparse.output_handler import write_list_of_strings from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from pyqi.commands.make_command import CommandConstructor cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample( ShortDesc="Basic Command", LongDesc="Create a basic Command with appropriate attribution", Ex= '%prog -n example -a "some author" -c "Copyright 2013, The pyqi project" -e "*****@*****.**" -l BSD --command-version "0.1" --credits "someone else","and another person" -o example.py' ) ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('name'), ShortName='n'), OptparseOption(Parameter=cmd_in_lookup('author'), ShortName='a'), OptparseOption(Parameter=cmd_in_lookup('email'), ShortName='e'), OptparseOption(Parameter=cmd_in_lookup('license'), ShortName='l'), OptparseOption(Parameter=cmd_in_lookup('copyright'), ShortName='c'), OptparseOption(Parameter=cmd_in_lookup('version'), Name='command-version'), OptparseOption(Parameter=cmd_in_lookup('credits'), Handler=string_list_handler, Help='comma-separated list of other authors'), OptparseOption(Parameter=cmd_in_lookup('test_code'),
from pyqi.core.interfaces.optparse import (OptparseUsageExample, OptparseResult) from pyqi.core.command import make_command_out_collection_lookup_f from pyqi.core.interfaces.optparse.output_handler import print_list_of_strings from biom.commands.installation_informer import CommandConstructor __author__ = "Jai Ram Rideout" __copyright__ = "Copyright 2011-2013, The BIOM Format Development Team" __credits__ = ["Jai Ram Rideout", "Greg Caporaso", "Daniel McDonald"] __license__ = "BSD" __url__ = "http://biom-format.org" __maintainer__ = "Jai Ram Rideout" __email__ = "*****@*****.**" cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Displaying installation info", LongDesc="Display biom-format installation " "information", Ex="%prog") ] inputs = [] outputs = [ OptparseResult(Parameter=cmd_out_lookup('install_info_lines'), Handler=print_list_of_strings) ]
OptparseResult) from pyqi.core.interfaces.optparse.input_handler import (command_handler, string_list_handler) from pyqi.core.interfaces.optparse.output_handler import write_list_of_strings from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from pyqi.commands.make_optparse import CommandConstructor cmdin_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmdout_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample( ShortDesc="Create an optparse config template", LongDesc= "Construct the beginning of an optparse configuration file based on the Parameters required by the Command.", Ex= '%prog -c pyqi.commands.make_optparse.MakeOptparse -m pyqi.commands.make_optparse -a "some author" --copyright "Copyright 2013, The pyqi project" -e "*****@*****.**" -l BSD --config-version "0.1" --credits "someone else","and another person" -o pyqi/interfaces/optparse/config/make_optparse.py' ), OptparseUsageExample( ShortDesc="Create a different optparse config template", LongDesc= "Construct the beginning of an optparse configuration file based on the Parameters required by the Command. This command corresponds to the pyqi tutorial example where a sequence_collection_summarizer command line interface is created for a SequenceCollectionSummarizer Command.", Ex= '%prog -c sequence_collection_summarizer.SequenceCollectionSummarizer -m sequence_collection_summarizer -a "Greg Caporaso" --copyright "Copyright 2013, Greg Caporaso" -e "*****@*****.**" -l BSD --config-version 0.0.1 -o summarize_sequence_collection.py' ) ] inputs = [ OptparseOption(Parameter=cmdin_lookup('command'), ShortName='c',
__author__ = "Michael Shaffer" __copyright__ = "Copyright 2011-2013, The BIOM Format Development Team" __credits__ = ["Michael Shaffer"] __license__ = "BSD" __url__ = "http://biom-format.org" __maintainer__ = "Michael Shaffer" __email__ = "*****@*****.**" cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Normalizing a BIOM table to relative" "abundnace", LongDesc="Take a BIOM table and replace all values " "with their relative abundance in relation " "to the sample", Ex="%prog -i table.biom -r -o " "normalized_table.biom"), OptparseUsageExample(ShortDesc="Converting a BIOM table to a " "presence/absence table", LongDesc="Take a BIOM table and convert the values " "to 0's and 1's based on presensce or " "absence of observations", Ex="%prog -i table.biom -p -o converted_table.biom") ] inputs = [ # table input OptparseOption(Parameter=cmd_in_lookup('biom_table'), Type='existing_filepath',
from pyqi.core.interfaces.optparse import (OptparseUsageExample, OptparseOption, OptparseResult) from pyqi.core.command import (make_command_in_collection_lookup_f, make_command_out_collection_lookup_f) from biom.interfaces.optparse.input_handler import (load_biom_table, load_metadata) from biom.interfaces.optparse.output_handler import write_biom_table from biom.commands.table_converter import CommandConstructor cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Converting from classic to BIOM format", LongDesc="Convert the classic file table.txt to a " "sparse BIOM format OTU table", Ex='%prog -i table.txt -o table.biom ' '--table-type "otu table"') ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('table'), Type='existing_filepath', Handler=load_biom_table, ShortName='i', Name='input-fp', Help='the input table filepath, either in BIOM or classic ' 'format'), OptparseOption(Parameter=cmd_in_lookup('sample_metadata'), Type='existing_filepath', Handler=load_metadata,
from scaling.commands.bench_results_comparator import CommandConstructor from scaling.interfaces.optparse.input_handler import ( load_summarized_results_list) from scaling.interfaces.optparse.output_handler import write_comp_results # Convenience function for looking up parameters by name. cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) # Examples of how the command can be used from the command line using an # optparse interface. usage_examples = [ OptparseUsageExample(ShortDesc="Compare different runs results of the same" " bench suite", LongDesc="Takes a comma-separated list with paths to " "directories with benchmark results and generates a " "plot with the wall time and a plot with the memory " "consumption of the different runs, allowing " "performance comparison between them.", Ex="%prog -i timing1,timing2 -l run1,run2 -o plots") ] # inputs map command line arguments and values onto Parameters. It is possible # to define options here that do not exist as parameters, e.g., an output file. inputs = [ OptparseOption(Parameter=cmd_in_lookup('bench_results'), Type='existing_filepaths', Action='store', Handler=load_summarized_results_list, ShortName='i', Name='input_dirs', Required=True,
make_command_out_collection_lookup_f) from pyqi.core.interfaces.optparse import (OptparseOption, OptparseUsageExample, OptparseResult) from pyqi.core.interfaces.optparse.output_handler import ( write_or_print_list_of_strings) from biom.commands.table_summarizer import CommandConstructor from biom.interfaces.optparse.input_handler import ( load_biom_table_with_file_contents) cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample(ShortDesc="Basic script usage", LongDesc="Write a summary of table.biom to " "table_summary.txt", Ex="%prog -i table.biom -o table_summary.txt") ] inputs = [ OptparseOption(Parameter=cmd_in_lookup('table'), Type="existing_filepath", Handler=load_biom_table_with_file_contents, ShortName='i', Name='input-fp'), OptparseOption(Parameter=cmd_in_lookup('qualitative'), Type=None, Action="store_true"), OptparseOption(Parameter=None, Type='new_filepath', ShortName='o',
from pyqi.core.interfaces.optparse.input_handler import string_list_handler from scaling.commands.bench_results_processer import CommandConstructor from scaling.interfaces.optparse.output_handler import write_bench_results from scaling.interfaces.optparse.input_handler import parse_timing_directory # Convenience function for looking up parameters by name. cmd_in_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmd_out_lookup = make_command_out_collection_lookup_f(CommandConstructor) # Examples of how the command can be used from the command line using an # optparse interface. usage_examples = [ OptparseUsageExample(ShortDesc="Processes the benchmark suite results", LongDesc="Takes the benchmark suite output directory " "and processes the benchmark measurements, creating " "plots and collapsing results in a usable form.", Ex="%prog -i timing -o plots"), OptparseUsageExample(ShortDesc="Wait for a set of PBS jobs to complete and" " process the benchmark suite results", LongDesc="Takes a list of PBS job ids, wait for its " "completion and then takes the benchmark suite output" " directory and processes the benchmark measurements," " creating plots and collapsing results in a usable " "form.", Ex="%prog -i timing -o plots -w 124311,124312,124313") ] # inputs map command line arguments and values onto Parameters. It is possible # to define options here that do not exist as parameters, e.g., an output file. inputs = [
__credits__ = ["Evan Bolyen"] from pyqi.core.interfaces.optparse import (OptparseOption, OptparseResult, OptparseUsageExample) from pyqi.core.interfaces.optparse.input_handler import string_list_handler from pyqi.core.interfaces.optparse.output_handler import print_string from pyqi.core.command import make_command_in_collection_lookup_f, make_command_out_collection_lookup_f from pyqi.commands.serve_html_interface import CommandConstructor cmdin_lookup = make_command_in_collection_lookup_f(CommandConstructor) cmdout_lookup = make_command_out_collection_lookup_f(CommandConstructor) usage_examples = [ OptparseUsageExample( ShortDesc="Start html interface", LongDesc= "Starts an html interface server on the specified --port and --interface-module", Ex='%prog -p 8080 -m pyqi.interfaces.html.config') ] inputs = [ OptparseOption(Parameter=cmdin_lookup('port'), ShortName='p', Type=int), OptparseOption(Parameter=cmdin_lookup('interface_module'), ShortName='m', Required=True) ] outputs = [ OptparseResult(Parameter=cmdout_lookup('result'), Handler=print_string) ]