Skip to content

Commit

Permalink
fix pyani plot so that plots are written to file
Browse files Browse the repository at this point in the history
The change to the command-line interface results in args.method
now having list type, rather than string. We now process only
the first entry in the args.method list.
  • Loading branch information
widdowquinn committed Jan 19, 2022
1 parent a9bd3ae commit 8a59453
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pyani/scripts/subcommands/subcmd_plot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) The James Hutton Institute 2017-2019
# (c) University of Strathclyde 2019-2020
# (c) University of Strathclyde 2019-2022
# Author: Leighton Pritchard
#
# Contact:
Expand All @@ -18,7 +18,7 @@
# The MIT License
#
# Copyright (c) 2017-2019 The James Hutton Institute
# Copyright (c) 2019-2020 University of Strathclyde
# Copyright (c) 2019-2022 University of Strathclyde
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -161,19 +161,18 @@ def write_run_plots(run_id: int, session, outfmts: List[str], args: Namespace) -
)

# Run the plotting commands
logger.debug("Running plotting commands")
for func, options in plotting_commands:
pool.apply_async(func, options, {})
logger.debug("Running %s with options %s", func, options)
pool.apply_async(func, args=options)

# Close worker pool
pool.close()
pool.join()


def write_distribution(
run_id: int,
matdata: MatrixData,
outfmts: List[str],
args: Namespace,
run_id: int, matdata: MatrixData, outfmts: List[str], args: Namespace
) -> None:
"""Write distribution plots for each matrix type.
Expand All @@ -188,7 +187,7 @@ def write_distribution(
for fmt in outfmts:
outfname = Path(args.outdir) / f"distribution_{matdata.name}_run{run_id}.{fmt}"
logger.debug("\tWriting graphics to %s", outfname)
DISTMETHODS[args.method](
DISTMETHODS[args.method[0]](
matdata.data,
outfname,
matdata.name,
Expand Down Expand Up @@ -222,7 +221,7 @@ def write_heatmap(
logger.debug("\tWriting graphics to %s", outfname)
params = pyani_graphics.Params(cmap, result_labels, result_classes)
# Draw heatmap
GMETHODS[args.method](
GMETHODS[args.method[0]](
matdata.data,
outfname,
title=f"matrix_{matdata.name}_run{run_id}",
Expand Down Expand Up @@ -264,7 +263,7 @@ def write_scatter(
logger.debug("\tWriting graphics to %s", outfname)
params = pyani_graphics.Params(cmap, result_labels, result_classes)
# Draw scatterplot
SMETHODS[args.method](
SMETHODS[args.method[0]](
matdata1.data,
matdata2.data,
outfname,
Expand Down

0 comments on commit 8a59453

Please sign in to comment.