Exemple #1
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = argparse.ArgumentParser(
        prog="mtsv-plugin",
        description="Plugins and extensions to MTSv",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.set_defaults(
        timestamp=datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))

    subparsers = parser.add_subparsers(title="commands",
                                       metavar="COMMANDS",
                                       help="Plugin Commands")

    for command, cmd_class in COMMANDS.items():
        make_sub_parser(subparsers, command, cmd_class)

    # Return help if no command is passed
    if len(argv) == 1:
        parser.print_help(sys.stdout)
        sys.exit(0)
    try:
        setup_and_run(argv, parser)
    except KeyboardInterrupt:
        error("\n-- Stopped by user --", exception=False)
Exemple #2
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = argparse.ArgumentParser(
        prog="mtsv-setup",
        description="Download and build sequence databases and indices",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    subparsers = parser.add_subparsers(title="commands",
                                       metavar="COMMAND",
                                       help="Setup Commands")

    for command, cmd_class in COMMANDS.items():
        make_sub_parser(subparsers, command, cmd_class)
    p = subparsers.add_parser("json_update")
    p.add_argument("--path")
    p = subparsers.add_parser("oneclick")
    p = subparsers.add_parser("json_combine")
    p.add_argument("--path", type=str)
    p.add_argument("--custom_db", nargs='+', type=str)
    p.add_argument("--partitions", type=str)
    p.add_argument("--output", type=str)

    p = subparsers.add_parser("ff_list")
    p.add_argument("--path")

    for command, cmd_class in COMMANDS.items():
        for arg, desc in get_global_config(cmd_class.config_section).items():
            if "_meta" in arg:
                continue
            if 'type' in desc:
                desc['type'] = TYPES[desc['type']]
            if 'default' in desc and 'help' in desc:
                desc['help'] += " (default: {})".format(desc['default'])
            if 'action' in desc and desc['action'] in ACTIONS:
                desc['action'] = getattr(sys.modules[__name__], desc['action'])
            arg = "--{}".format(arg)
            if 'positional' in desc:
                del desc['positional']
            try:
                p.add_argument(arg, **desc)
            except argparse.ArgumentError:
                continue
        try:
            add_default_arguments(p)
        except argparse.ArgumentError:
            pass

    if len(argv) == 1:
        parser.print_help(sys.stdout)
        sys.exit(1)
    try:
        setup_and_run(parser)
    except KeyboardInterrupt:
        error("\n-- Stopped by user --", exception=False)
Exemple #3
0
def main(argv=None):
    if argv is None:
        argv = sys.argv

    parser = argparse.ArgumentParser(
        prog="mtsv",
        description="Metagenomic analysis pipeline",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.set_defaults(
        timestamp=datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))

    subparsers = parser.add_subparsers(title="commands",
                                       metavar="COMMAND",
                                       help="Pipeline Commands")

    parser_init = subparsers.add_parser(
        'init',
        help="Initializes a directory with a pre-filled parameters file")
    parser_init.add_argument(
        "-c",
        "--config",
        type=TYPES['write_handle_type'],
        default=DEFAULT_CFG_FNAME,
        help="Specify path to write config file, "
        "not required if using default config (Default: ./mtsv.cfg)")
    parser_init.add_argument('-wd',
                             "--working_dir",
                             type=str,
                             default=os.getcwd(),
                             help="Specify working directory to place output. "
                             "(default: {})".format(os.getcwd()))
    parser_init.set_defaults(cmd_class=Init)

    for command, cmd_class in COMMANDS.items():
        make_sub_parser(subparsers, command, cmd_class)

    # Return help if no command is passed
    if len(argv) == 1:
        parser.print_help(sys.stdout)
        sys.exit(0)
    try:
        setup_and_run(argv, parser)
    except KeyboardInterrupt:
        error("\n-- Stopped by user --", exception=False)