How to use the pyani.pyani_report.write_dbtable function in pyani

To help you get started, we’ve selected a few pyani examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github widdowquinn / pyani / pyani / scripts / subcommands.py View on Github external
data = pyani_db.get_df_genome_runs(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)

    # Report table of comparison results for the indicated runs
    if args.run_results:
        outfstem = os.path.join(args.outdir, "results")
        run_ids = [run_id.strip() for run_id in args.run_results.split(',')]
        logger.info("Attempting to write results tables for runs: %s",
                    run_ids)
        for run_id in run_ids:
            outfname = '_'.join([outfstem, str(run_id)])
            run_data = pyani_db.get_run(args.dbpath, run_id)
            logger.info("Collecting data for run with ID: %s (%s)", run_id,
                        run_data[5])
            data = pyani_db.get_df_comparisons(args.dbpath, run_id)
            pyani_report.write_dbtable(data, outfname, formats)

    # Report matrices of comparison results for the indicated runs
    # For ANIm, all results other than coverage are symmetric matrices,
    # so we only get results in the forward direction.
    if args.run_matrices:
        outfstem = os.path.join(args.outdir, "matrix")
        run_ids = [run_id.strip() for run_id in args.run_matrices.split(',')]
        logger.info("Attempting to write results matrices for runs: %s",
                    run_ids)
        for run_id in run_ids:
            logger.info("Extracting comparison results for run %s", run_id)
            results = pyani_db.ANIResults(args.dbpath, run_id)
            for matname, args in [('identity', {'colour_num': 0.95}),
                                  ('coverage', {'colour_num': 0.95}),
                                  ('aln_lengths', {}),
                                  ('sim_errors', {}),
github widdowquinn / pyani / pyani / scripts / subcommands.py View on Github external
if args.run_matrices:
        outfstem = os.path.join(args.outdir, "matrix")
        run_ids = [run_id.strip() for run_id in args.run_matrices.split(',')]
        logger.info("Attempting to write results matrices for runs: %s",
                    run_ids)
        for run_id in run_ids:
            logger.info("Extracting comparison results for run %s", run_id)
            results = pyani_db.ANIResults(args.dbpath, run_id)
            for matname, args in [('identity', {'colour_num': 0.95}),
                                  ('coverage', {'colour_num': 0.95}),
                                  ('aln_lengths', {}),
                                  ('sim_errors', {}),
                                  ('hadamard', {})]:
                logger.info("Writing %s results", matname)
                outfname = '_'.join([outfstem, matname, str(run_id)])
                pyani_report.write_dbtable(getattr(results, matname),
                                           outfname, formats, show_index=True,
                                           **args)
github widdowquinn / pyani / pyani / scripts / subcommands.py View on Github external
# Report table of all genomes used for each run
    if args.show_runs_genomes:
        outfname = os.path.join(args.outdir, "runs_genomes")
        logger.info("Writing table of pyani runs, with associated genomes " +
                    "to %s.*", outfname)
        data = pyani_db.get_df_run_genomes(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)

    # Report table of all runs in which a genome is involved
    if args.show_genomes_runs:
        outfname = os.path.join(args.outdir, "genomes_runs")
        logger.info("Writing table of genomes, with associated pyani runs" +
                    "to %s.*", outfname)
        data = pyani_db.get_df_genome_runs(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)

    # Report table of comparison results for the indicated runs
    if args.run_results:
        outfstem = os.path.join(args.outdir, "results")
        run_ids = [run_id.strip() for run_id in args.run_results.split(',')]
        logger.info("Attempting to write results tables for runs: %s",
                    run_ids)
        for run_id in run_ids:
            outfname = '_'.join([outfstem, str(run_id)])
            run_data = pyani_db.get_run(args.dbpath, run_id)
            logger.info("Collecting data for run with ID: %s (%s)", run_id,
                        run_data[5])
            data = pyani_db.get_df_comparisons(args.dbpath, run_id)
            pyani_report.write_dbtable(data, outfname, formats)

    # Report matrices of comparison results for the indicated runs
github widdowquinn / pyani / pyani / scripts / subcommands.py View on Github external
# Report genomes in the database
    if args.show_genomes:
        outfname = os.path.join(args.outdir, "genomes")
        logger.info("Writing table of genomes from the database to %s.*",
                    outfname)
        data = pyani_db.get_df_genomes(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats, index='genome ID')

    # Report table of all genomes used for each run
    if args.show_runs_genomes:
        outfname = os.path.join(args.outdir, "runs_genomes")
        logger.info("Writing table of pyani runs, with associated genomes " +
                    "to %s.*", outfname)
        data = pyani_db.get_df_run_genomes(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)

    # Report table of all runs in which a genome is involved
    if args.show_genomes_runs:
        outfname = os.path.join(args.outdir, "genomes_runs")
        logger.info("Writing table of genomes, with associated pyani runs" +
                    "to %s.*", outfname)
        data = pyani_db.get_df_genome_runs(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)

    # Report table of comparison results for the indicated runs
    if args.run_results:
        outfstem = os.path.join(args.outdir, "results")
        run_ids = [run_id.strip() for run_id in args.run_results.split(',')]
        logger.info("Attempting to write results tables for runs: %s",
                    run_ids)
        for run_id in run_ids:
github widdowquinn / pyani / pyani / scripts / subcommands / subcmd_report.py View on Github external
"""Write tabular report of pyani runs from database.

    :param args:  Namespace of command-line arguments
    :param session:  SQLAlchemy database session
    :param formats:  list of output formats
    :param params:  ReportParams namedtuple
    """
    logger = logging.getLogger(__name__)

    outfname = args.outdir / params.name
    logger.debug(
        "Writing table of pyani %s from the database to %s.*", params.name, outfname
    )
    data = pd.read_sql(params.statement, session.bind)
    data.columns = params.headers
    pyani_report.write_dbtable(data, outfname, formats)
github widdowquinn / pyani / pyani / scripts / subcommands / subcmd_report.py View on Github external
for matdata in [
                MatrixData(*_)
                for _ in [
                    ("identity", run.df_identity, {"colour_num": 0.95}),
                    ("coverage", run.df_coverage, {"colour_num": 0.95}),
                    ("aln_lengths", run.df_alnlength, {}),
                    ("sim_errors", run.df_simerrors, {}),
                    ("hadamard", run.df_hadamard, {}),
                ]
            ]:
                logger.debug("Writing %s results", matdata.name)
                matrix = pd.read_json(matdata.data)
                # Matrix rows and columns are labelled if there's a label dictionary,
                # and take the dataframe index otherwise
                matrix = label_results_matrix(matrix, matlabel_dict)
                pyani_report.write_dbtable(
                    matrix,
                    Path(
                        "_".join(
                            [str(args.outdir / "matrix"), matdata.name, str(run_id)]
                        )
                    ),
                    formats,
                    show_index=True,
                    **matdata.graphic_args,
                )

    return 0
github widdowquinn / pyani / pyani / scripts / subcommands.py View on Github external
# Report runs in the database
    if args.show_runs:
        outfname = os.path.join(args.outdir, "runs")
        logger.info("Writing table of pyani runs from the database to %s.*",
                    outfname)
        data = pyani_db.get_df_runs(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats, index='run ID')

    # Report genomes in the database
    if args.show_genomes:
        outfname = os.path.join(args.outdir, "genomes")
        logger.info("Writing table of genomes from the database to %s.*",
                    outfname)
        data = pyani_db.get_df_genomes(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats, index='genome ID')

    # Report table of all genomes used for each run
    if args.show_runs_genomes:
        outfname = os.path.join(args.outdir, "runs_genomes")
        logger.info("Writing table of pyani runs, with associated genomes " +
                    "to %s.*", outfname)
        data = pyani_db.get_df_run_genomes(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)

    # Report table of all runs in which a genome is involved
    if args.show_genomes_runs:
        outfname = os.path.join(args.outdir, "genomes_runs")
        logger.info("Writing table of genomes, with associated pyani runs" +
                    "to %s.*", outfname)
        data = pyani_db.get_df_genome_runs(args.dbpath)
        pyani_report.write_dbtable(data, outfname, formats)