diff --git a/poretools/hist.py b/poretools/hist.py index b16c683..b295bea 100644 --- a/poretools/hist.py +++ b/poretools/hist.py @@ -18,6 +18,10 @@ def plot_hist(sizes, args): """ sizes = [s for s in sizes if args.min_length < s < args.max_length] + if args.saveas is not None: + plt.switch_backend('Agg') # Use non-interactive backend in case this is + # running on a headless system. + if args.theme_bw: sns.set_style("whitegrid") plt.hist(sizes, args.num_bins) diff --git a/poretools/occupancy.py b/poretools/occupancy.py index 532d6c2..009a4cb 100644 --- a/poretools/occupancy.py +++ b/poretools/occupancy.py @@ -25,6 +25,9 @@ def plot_performance(parser, args, pore_measure): """ Plot the pore performance in terms of reads per pore """ + if args.saveas is not None: + plt.switch_backend('Agg') # Use non-interactive backend in case this is + # running on a headless system. flowcell_layout = minion_flowcell_layout() pore_values = [] diff --git a/poretools/poretools_main.py b/poretools/poretools_main.py index a4108e5..af9ed1d 100755 --- a/poretools/poretools_main.py +++ b/poretools/poretools_main.py @@ -445,6 +445,11 @@ def main(): ########## parser_times = subparsers.add_parser('times', help='Return the start times from a set of FAST5 files in tabular format') + parser_times.add_argument('--utc', + dest='utc', + default=False, + action='store_true', + help="Show timestamps in UTC.") parser_times.add_argument('files', metavar='FILES', nargs='+', help='The input FAST5 files.') parser_times.set_defaults(func=run_subtool) diff --git a/poretools/qual_v_pos.py b/poretools/qual_v_pos.py index c310b1e..fc111e4 100644 --- a/poretools/qual_v_pos.py +++ b/poretools/qual_v_pos.py @@ -1,6 +1,7 @@ import Fast5File from collections import defaultdict import pandas +import sys import matplotlib.pyplot as plt #logging @@ -42,6 +43,10 @@ def run(parser, args): fast5.close() + if args.saveas is not None: + plt.switch_backend('Agg') # Use non-interactive backend in case this is + # running on a headless system. + logger.info("Processing data...") data = [qualpos[e] for e in sorted(qualpos.keys())] logger.info("Constructing box plot...") @@ -53,10 +58,10 @@ def run(parser, args): if args.saveas is not None: logger.info("Writing plot to file...") plot_file = args.saveas - if plot_file.endswith(".pdf") or plot_file.endswith(".jpg"): + if plot_file.endswith(".pdf") or plot_file.endswith(".png") or plot_file.endswith(".svg"): plt.savefig(plot_file) else: - logger.error("Unrecognized extension for %s! Try .pdf or .jpg" % (plot_file)) + logger.error("Unrecognized extension for %s! Try .pdf, .png, or .svg" % (plot_file)) sys.exit() else: diff --git a/poretools/squiggle.py b/poretools/squiggle.py index cd8d667..bd567e1 100644 --- a/poretools/squiggle.py +++ b/poretools/squiggle.py @@ -36,6 +36,10 @@ def plot_squiggle(args, filename, start_times, mean_signals): starts = df.groupby('cat')['start'] mins, maxs = list(starts.min()), list(starts.max()) + if args.saveas is not None: + plt.switch_backend('Agg') # Use non-interactive backend in case this is + # running on a headless system. + grid = sns.FacetGrid(df, row="cat", sharex=False, size=8) #plt.gcf().tight_layout() grid.fig.suptitle('Squiggle plot for read: ' + filename + "\nTotal time (sec): " + str(total_time)) diff --git a/poretools/times.py b/poretools/times.py index 39b8bc3..f3d7466 100644 --- a/poretools/times.py +++ b/poretools/times.py @@ -1,5 +1,5 @@ import Fast5File -from time import strftime, localtime +from time import strftime, localtime, gmtime import sys #logging @@ -28,7 +28,10 @@ def run(parser, args): else: read_length = 0 - lt = localtime(start_time) + if args.utc: + lt = gmtime(start_time) + else: + lt = localtime(start_time) print "\t".join([str(fast5.get_channel_number()), fast5.filename, str(read_length), diff --git a/poretools/yield_plot.py b/poretools/yield_plot.py index af4b69b..7024627 100644 --- a/poretools/yield_plot.py +++ b/poretools/yield_plot.py @@ -50,6 +50,10 @@ def plot_collectors_curve(args, start_times, read_lengths): if args.theme_bw: sns.set_style("whitegrid") + if args.saveas is not None: + plt.switch_backend('Agg') # Use non-interactive backend in case this is + # running on a headless system. + # plot plt.plot(df['start'], df['cumul']) plt.xlabel('Time (hours)')