Exemplo n.º 1
0
    def test_nisin_complete(self):
        with TemporaryDirectory() as output_dir:
            args = [
                "--minimal", "--enable-tta", "--tta-threshold", "0",
                "--output-dir", output_dir,
                helpers.get_path_to_nisin_genbank()
            ]
            options = build_config(args,
                                   isolated=True,
                                   modules=antismash.get_all_modules())
            antismash.run_antismash(helpers.get_path_to_nisin_genbank(),
                                    options)

            # regen the results
            update_config(
                {"reuse_results": os.path.join(output_dir, "nisin.json")})
            prior_results = read_data(None, options)
            record = prior_results.records[0]
            results = prior_results.results[0]
            tta_results = tta.regenerate_previous_results(
                results.get("antismash.modules.tta"), record, options)
            assert isinstance(tta_results, tta.TTAResults)
            assert len(tta_results.features) == 174

            # raise the threshold above the gc_content and ensure regenned has no hits
            update_config({"tta_threshold": 0.65})
            tta_results = tta.regenerate_previous_results(
                results.get("antismash.modules.tta"), record, options)
            assert isinstance(tta_results, tta.TTAResults)
            assert not tta_results.features
    def test_nisin_complete(self):
        with TemporaryDirectory() as output_dir:
            args = [
                "run_antismash.py", "--minimal", "--enable-lanthipeptides",
                "--output-dir", output_dir
            ]
            options = build_config(args,
                                   isolated=True,
                                   modules=antismash.get_all_modules())
            antismash.run_antismash(helpers.get_path_to_nisin_genbank(),
                                    options)

            # make sure the html_output section was tested
            with open(os.path.join(output_dir, "index.html")) as handle:
                content = handle.read()
                assert "nisA leader / core peptide" in content
Exemplo n.º 3
0
def main(args: List[str]) -> int:
    """ The entrypoint of antiSMASH as if it was on the command line

        Arguments:
            args: a list of args as would be given on the command line
                    e.g. ["inputfile", "--minimal", "--enable-nrps_pks"]

        Returns:
            zero if successful, non-zero otherwise

    """
    all_modules = antismash.get_all_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]
        if not os.path.exists(sequence):
            parser.error("Input file does not exist: %s" % sequence)
            return 1
    else:
        sequence = ""

    if options.reuse_results and not os.path.exists(options.reuse_results):
        parser.error("Input file does not exist: %s" % options.reuse_results)
        return 1

    options.version = get_version()

    return antismash.run_antismash(sequence, options)
Exemplo n.º 4
0
    def test_trees_complete(self):
        with TemporaryDirectory() as output_dir:
            args = [
                "--minimal", "--enable-genefunctions", "--smcog-trees",
                "--output-dir", output_dir,
                helpers.get_path_to_nisin_genbank()
            ]
            options = build_config(args,
                                   isolated=True,
                                   modules=antismash.get_all_modules())
            antismash.run_antismash(helpers.get_path_to_nisin_genbank(),
                                    options)

            with open(os.path.join(output_dir, "nisin.json")) as res_file:
                assert "antismash.modules.smcog_trees" in res_file.read()

            tree_files = list(
                glob.glob(os.path.join(output_dir, "smcogs", "*.png")))
            assert len(tree_files) == 7
            sample_tree = tree_files[0]

            # regen the results
            update_config(
                {"reuse_results": os.path.join(output_dir, "nisin.json")})
            prior_results = read_data(None, options)
            record = prior_results.records[0]
            results = prior_results.results[0]
            tree_results = results["antismash.modules.smcog_trees"]

            smcogs_results = smcog_trees.regenerate_previous_results(
                tree_results, record, options)
            assert len(smcogs_results.tree_images) == 7
            assert os.path.exists(sample_tree)

            os.unlink(sample_tree)
            assert not os.path.exists(sample_tree)

            # attempt to regen the results, the deleted tree image will prevent it
            prior_results = read_data(None, options)
            record = prior_results.records[0]
            results = prior_results.results[0]
            smcogs_results = smcog_trees.regenerate_previous_results(
                tree_results, record, options)
            assert smcogs_results is None
Exemplo n.º 5
0
    def test_nisin_complete(self):
        with TemporaryDirectory() as output_dir:
            args = [
                "--minimal", "--tta", "--output-dir", output_dir,
                helpers.get_path_to_nisin_genbank()
            ]
            options = build_config(args,
                                   isolated=True,
                                   modules=antismash.get_all_modules())
            antismash.run_antismash(helpers.get_path_to_nisin_genbank(),
                                    options)

            # regen the results
            update_config(
                {"reuse_results": os.path.join(output_dir, "nisin.json")})
            prior_results = read_data(None, options)
            record = prior_results.records[0]
            results = prior_results.results[0]
            regenned = regenerate_results_for_record(record, options, [tta],
                                                     results)
            tta_results = regenned["antismash.modules.tta"]
            assert isinstance(tta_results, tta.TTAResults)
            assert len(tta_results.features) == 174
Exemplo n.º 6
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)