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.


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


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.

  • 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.

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.

  • 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’.

  • 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 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.


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.

class indra.tools.reading.util.script_tools.StatementData(statement, reading_id=None, db_info_id=None)[source]

Contains metadata for statements, as well as the statement itself.

This, like ReadingData, is primarily designed for use with the database, carrying valuable information and methods for such.

  • statement (an indra Statement instance) – The statement whose extra meta data this object encapsulates.
  • reading_id (int or None) – The id number of the entry in the readings table of the database. None if no such id is available.
classmethod get_cols()[source]

Get the columns for the tuple returned by make_tuple.


Make a tuple for copying into the database.

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

Get a parser that is generic to reading scripts.

  • 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.

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

Return type:

argparse.ArgumentParser instance

indra.tools.reading.util.script_tools.make_statements(reading_data_list, num_proc=1)[source]

Convert a list of ReadingData instances into StatementData instances.