Beispiel #1
0
def _main() -> None:
    """ Downloads, decompresses, and compiles large databases. Also ensures
        antiSMASH's module data is prepared.
    """
    # Small dance to grab the antiSMASH config for the database dir.
    # We don't actually want to keep anything else, but we need to load all the
    # modules to make sure we can parse the file.
    all_modules = antismash.get_detection_modules() + antismash.get_analysis_modules()
    config = antismash.config.build_config(args=[], parser=None, isolated=True, modules=all_modules)

    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--database-dir",
        default=config.database_dir,
        metavar="DIR",
        help="Base directory for the antiSMASH databases (default: %(default)s).",
    )

    args = parser.parse_args()
    download(args)
    try:
        antismash.main.prepare_module_data()
    except Exception as err:  # pylint: disable=broad-except
        print("Error encountered while preparing module data:", str(err), file=sys.stderr)
        sys.exit(1)
Beispiel #2
0
def main(args):
    all_modules = antismash.get_detection_modules(
    ) + antismash.get_analysis_modules()
    parser = antismash.config.args.build_parser(from_config_file=True,
                                                modules=all_modules)

    # if --help, show help texts and exit
    if set(args).intersection({"-h", "--help", "--help-showall"}):
        parser.print_help(None, "--help-showall" in args)
        return 0

    options = antismash.config.build_config(args, parser=parser)

    if options.write_config_file:
        parser.write_to_config_file(options.write_config_file,
                                    options.__dict__)
        return 0

    # if -V, show version text and exit
    if options.version:
        print("antiSMASH %s" % get_version())
        return 0

    if len(options.sequences) > 1:
        parser.error("Only one sequence file should be provided")
        return 1
    if len(options.sequences) < 1 and not options.reuse_results \
            and not options.check_prereqs_only and not options.list_plugins:
        parser.error(
            "One of an input file or --reuse-results must be specified")
        return 1
    if options.sequences and options.reuse_results:
        parser.error("Provide a sequence file or results to reuse, not both.")
        return 1
    if options.sequences:
        sequence = options.sequences[0]
        options.__dict__.pop("sequences")
    else:
        sequence = ""

    options.version = get_version()

    return antismash.run_antismash(sequence, options)