diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..8a8e854 Binary files /dev/null and b/.DS_Store differ diff --git a/nanoplot/NanoPlot.py b/nanoplot/NanoPlot.py index 1412fd9..f72bbba 100755 --- a/nanoplot/NanoPlot.py +++ b/nanoplot/NanoPlot.py @@ -21,6 +21,7 @@ from nanoget import get_input from nanoplot.filteroptions import filter_and_transform_data from nanoplot.version import __version__ +from nanoplotter.plot import Plot import nanoplotter import pickle import sys @@ -87,6 +88,9 @@ def main(): ) ) + if args.only_report: + Plot.only_report = True + if args.barcoded: main_path = settings["path"] for barc in list(datadf["barcode"].unique()): diff --git a/nanoplot/utils.py b/nanoplot/utils.py index 8de32ac..0ae2cd8 100644 --- a/nanoplot/utils.py +++ b/nanoplot/utils.py @@ -101,6 +101,12 @@ def get_args(): help="Output the stats file as a properly formatted TSV.", action="store_true", ) + general.add_argument( + "--only-report", + help="Output only the report", + action="store_true", + default=False, + ) general.add_argument( "--info_in_report", help="Add NanoPlot run info in the report.", action="store_true" ) diff --git a/nanoplotter/plot.py b/nanoplotter/plot.py index dfbec77..d4b90d7 100644 --- a/nanoplotter/plot.py +++ b/nanoplotter/plot.py @@ -10,6 +10,8 @@ class Plot(object): """A Plot object is defined by a path to the output file and the title of the plot.""" + only_report = False + def __init__(self, path, title): self.path = path self.title = title @@ -38,34 +40,35 @@ def encode2(self): return ''.format(urlquote(string)) def save(self, settings): - if self.html: - with open(self.path, "w") as html_out: - html_out.write(self.html) - if not settings["no_static"]: - try: - for fmt in settings["format"]: - self.save_static(fmt) - except (AttributeError, ValueError) as e: - p = os.path.splitext(self.path)[0] + ".png" - if os.path.exists(p): - os.remove(p) + if not(self.only_report): + if self.html: + with open(self.path, "w") as html_out: + html_out.write(self.html) + if not settings["no_static"]: + try: + for fmt in settings["format"]: + self.save_static(fmt) + except (AttributeError, ValueError) as e: + p = os.path.splitext(self.path)[0] + ".png" + if os.path.exists(p): + os.remove(p) - logging.warning("No static plots are saved due to some kaleido problem:") - logging.warning(e) + logging.warning("No static plots are saved due to some kaleido problem:") + logging.warning(e) - elif self.fig: - # if settings["format"] is a list, save the figure in all formats - if isinstance(settings["format"], list): - for fmt in settings["format"]: - self.fig.savefig( - fname=self.path + "." + fmt, - format=fmt, - bbox_inches="tight", - ) + elif self.fig: + # if settings["format"] is a list, save the figure in all formats + if isinstance(settings["format"], list): + for fmt in settings["format"]: + self.fig.savefig( + fname=self.path + "." + fmt, + format=fmt, + bbox_inches="tight", + ) + else: + self.fig.savefig(fname=self.path, format=settings["format"], bbox_inches="tight") else: - self.fig.savefig(fname=self.path, format=settings["format"], bbox_inches="tight") - else: - sys.exit("No method to save plot object: no html or fig defined.") + sys.exit("No method to save plot object: no html or fig defined.") def show(self): if self.fig: