Provides a framework for generating HTML reports from BioLite diagnostics. The typical usage is to extend the BaseReport class for each pipeline, and override the init method to specify lookups and generators.
Lookups are called with self.lookup and specify entities or attributes that should be loaded from the diagnotics into the self.data AttributeDict. For example:
self.lookup('args', diagnostics.INIT)
will load the initialization entity, which includes all of the command-line arguments passed to the pipeline for a given run.
Generators are functions that return lists of HTML lines, which are concatenated together to form the final HTML report, in the order that the generators are attached. A generator function will typically start by checking if a diagnostics value was successfully loaded into self.data, e.g.:
def report_arguments(self):
if 'args' in self.data:
html = [self.header('Arguments')]
html += ['<p>%s</[>' % a for a in self.data.args]
return html
The generator is attached to the report in the init method with the line:
self.generator(self.report_arguments)
Bases: tuple
Field(key, title, type, format)
Alias for field number 3
Alias for field number 0
Alias for field number 1
Alias for field number 2
Applies aggregators (sum or max) to fields in the input profiles list.
Returns a dict of aggregated values.
A base class that provides basic infrastructure for reporting diagnostics via HTML for a given run.
This is intended to be sub-classed within an BioLite pipeline script, to define how the diagnostics for that pipeline should be summarized and plotted.
Override this function with a series of lookup() and generator() calls that specify the diagnostics lookups needed by your report, and the sub-class functions that generate the HTML output.
Lookup data from the diagnotics table for the given entity and store it in the self.data dictoinary.
Parse the ‘command’ attrbute of ‘entity’ to find the value for the argument ‘arg’.
Add functions in your sub-class to the ‘generators’ list, and their list-of-strings output will be appended in order to the output of the object’s __repr__ function.
Check if multiple keys are in the report’s data dictionary. Return true if all exists, otherwise false.
Converts a diagnostics string with key name in self.data into a list, by parsing it as a typical Python list representation [item1, item2, ... ].
Returns a 2-column summary table of a pipeline’s key statistics.
Returns an HTML table with a row for each tuple in rows, and an option header row for the tuple headers. The style string indicates justification for a column as either l (left) or r (right). For example, ‘lr’ prints a table with the first column left-justified and the second column right-justified.
Plots a histogram in dict data with the given number of bins to the file imgname. The keys of the dict should correspond to bins with width 1, and the values to frequencies.
Plots a histogram in dict data to the file imgname, using the keys as categories and values as frequencies.
Plots up to 3 histograms over each other. Histograms are plotted in the order of the hists list, so that the last histogram is the topmost. The histograms are plotted with alpha=0.5 and colors red, blue, green.
Plots bars for a dict data to the file imgname, using the keys as categories and values as heights.
Plots the (X,Y) points given in plot to the file imgname.
plot should be a tuple of the form (x, y, ...) where x and y are list or nparray objects and any additional fields are parameters to the matplotlib plot function (such as color or label).
Plots multiple sets of (X,Y) points given in plots to the file imgname.
plots should be a list of tuples of the form (x, y, color, label) where x and y are list or nparray objects, color is a matplotlib color specification (for instance, ‘r’ for red) and label is a string.
Plots a single line for the values in data to the file imgname.