Formatters

cblaster result formatters.

cblaster.formatters.add_field_whitespace(rows, lengths)

Fills table fields with whitespace to specified lengths.

cblaster.formatters.binary(session, hide_headers=False, delimiter=None, key=<built-in function len>, attr='identity', decimals=4)

Generates a binary summary table from a Session object.

cblaster.formatters.generate_header_string(text, symbol='-')

Generates a 2-line header string with underlined text.

>>> header = generate_header_string("header string", symbol="*")
>>> print(header)
header string
*************
cblaster.formatters.get_cell_values(queries, subjects, key=<built-in function len>, attr=None)

Generates the values of cells in the binary matrix.

This function calls some specified key function (def. max) against all values of a specified attribute (def. None) from Hits inside Subjects which match each query. By default, this function will just count all matching Hits (i.e. len() is called on all Hits whose query attribute matches). To find maximum identities, for example, provide key=max and attr=’identity’ to this function.

Parameters:
  • queries (list) – Names of query sequences.
  • subjects (list) – Subject objects to generate vlaues for.
  • key (callable) – Some callable that takes a list and produces a value.
  • attr (str) – A Hit attribute to calculate values with in key function.
cblaster.formatters.get_maximum_row_lengths(rows)

Finds the longest lengths of fields per column in a collection of rows.

cblaster.formatters.humanise(rows)

Formats a collection of fields as human-readable.

cblaster.formatters.summarise_subjects(subjects, decimals=4, hide_headers=True, delimiter=None)

Generates a summary table for a hit cluster.

Parameters:
  • hits (list) – collection of Hit objects
  • decimals (int) – number of decimal points to show
  • show_headers (bool) – show column headers in output
  • human (bool) – use human-readable format
Returns:

summary table