Low-level utilities used for or by reading pipelines (indra.tools.reading.util)

General tools to help with bulk reading.

Tools to analyze logs (indra.tools.reading.util.log_analysis_tools)

exception indra.tools.reading.util.log_analysis_tools.GetReadingStatsError[source]
indra.tools.reading.util.log_analysis_tools.analyze_db_reading(job_prefix, reading_queue='run_db_reading_queue')[source]

Run various analysis on a particular reading job.

indra.tools.reading.util.log_analysis_tools.analyze_reach_log(log_fname=None, log_str=None)[source]

Return unifinished PMIDs given a log file name.

indra.tools.reading.util.log_analysis_tools.get_logs_from_db_reading(job_prefix, reading_queue='run_db_reading_queue')[source]

Get the logs stashed on s3 for a particular reading.

indra.tools.reading.util.log_analysis_tools.get_unyielding_tcids(log_str)[source]

Extract the set of tcids for which no statements were created.

indra.tools.reading.util.log_analysis_tools.separate_reach_logs(log_str)[source]

Get the list of reach logs from the overall logs.

Tools to export statements by reach rule (indra.tools.reading.util.export_stmts_by_reach_rule)

Class for generating reports on a Batch reading job (indra.tools.reading.util.reporter)

class indra.tools.reading.util.reporter.Reporter(name)[source]

A class to produce a simple pdf report using the reportlab package.

Parameters:name (str) – A name that will be the name of this file, and the title by default.
add_image(image_path, width=None, height=None, section=None)[source]

Add an image to the document.

Images are shown on the final document in the order they are added, either within the given section or as part of the un-sectioned list of content.

Parameters:
  • image_path (str) – A path to the image on the local file system.
  • width (int or float) – The width of the image in the document in inches.
  • height (int or float) – The height of the image in the document in incehs.
  • section (str) – (This must be a keyword) Select a section in which to place this image. Default is None, in which case the image will be simply be added to a default list of text and images.
add_section(section_name)[source]

Create a section of the report, to be headed by section_name

Text and images can be added by using the section argument of the add_text and add_image methods. Sections can also be ordered by using the set_section_order method.

By default, text and images that have no section will be placed after all the sections, in the order they were added. This behavior may be altered using the sections_first attribute of the make_report method.

add_text(text, *args, **kwargs)[source]

Add text to the document.

Text is shown on the final document in the order it is added, either within the given section or as part of the un-sectioned list of content.

Parameters:
  • text (str) – The text to be added.
  • style (str) – Choose the style of the text. Options include ‘Normal’, ‘Code’, ‘Title’, ‘h1’. For others, see getSampleStyleSheet from reportlab.lib.styles.
  • space (tuple (num spaces, font size)) – The number and size of spaces to follow this section of text. Default is (1, 12).
  • fontsize (int) – The integer font size of the text (e.g. 12 for 12 point font). Default is 12.
  • alignment (str) – The alignment of the text. Options include ‘left’, ‘right’, and ‘center’. Default is ‘left’.
  • section (str) – (This must be a keyword) Select a section in which to place this text. Default is None, in which case the text will be simply be added to a default list of text and images.
make_report(sections_first=True, section_header_params=None)[source]

Create the pdf document with name self.name + ‘.pdf’.

Parameters:
  • sections_first (bool) – If True (default), text and images with sections are presented first and un-sectioned content is appended afterword. If False, sectioned text and images will be placed before the sections.
  • section_header_params (dict or None) – Optionally overwrite/extend the default formatting for the section headers. Default is None.
set_section_order(section_name_list)[source]

Set the order of the sections, which are by default unorderd.

Any unlisted sections that exist will be placed at the end of the document in no particular order.

set_title(title)[source]

Overwrite the default title with a string title of your choosing.

Tools used in creating CLI scripts for reading (indra.tools.reading.util.script_tools)

Useful tools for reading scripts.

indra.tools.reading.util.script_tools.get_parser(description, input_desc)[source]

Get a parser that is generic to reading scripts.

Parameters:
  • description (str) – A description of the tool, usually about one line long.
  • input_desc (str) – A string describing the nature of the input file used by the reading tool.
Returns:

parser – An argument parser object, to which further arguments can be added.

Return type:

argparse.ArgumentParser instance